20161222_jeffrey - silenceuncrio/diary GitHub Wiki
Index
- 0930 - review
- 1100 - 把需要的 image 作打包
- 1205 - 回憶之前買的 USB DAC - 使用 pcm2706
- 1310 - 盤一下 firmware upgrade shell script 需要哪些動作
- 1425 - Extract all files from images.tar
- 1435 - burn the uboot to NAND
- 1500 - burn the kernel to NAND
- 1520 - burn the dtb to NAND
- 1540 - burn the rootfs to NAND
- 1620 - chnage uboot env
- 1700 - commit
- 1755 - 目前的 firmware upgrade shell script
0930
review
參考 https://community.nxp.com/thread/254021
setenv 'uboot=u-boot.bin'
setenv 'kernel=uImage'
setenv 'bootargs_base=setenv bootargs console=ttymxc0,115200'
setenv 'loadaddr=0x90800000'
setenv 'bootargs_nand=setenv bootargs ${bootargs} ip=none ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs rootwait rw'
setenv 'bootcmd_nand=run bootargs_base bootargs_nand;nand read ${loadaddr} 0x1000000 0x300000;bootm'
setenv 'bootcmd=run bootcmd_nand'
這樣的寫法會讓 bootenv 整齊許多
不過目前我需要先搞定 linux 端的 firmware upgrade shell script
1100
先把需要的 image 作打包
➜ build_small git:(nandflash) ls -a images
...
core-image-minimal-imx6ulevk-20161221092717.rootfs.tar.bz2
u-boot.imx
zImage
zImage-imx6ul-14x14-evk.dtb
...
目的是打包 所以先用簡單的方式就好了
➜ build_small git:(nandflash) tar -cfh images.tar images/u-boot.imx images/zImage images/zImage-imx6ul-14x14-evk.dtb images/core-image-minimal-imx6ulevk.tar.bz2
就先假設我們的 firmware 叫做 image.tar
假設我們把 image.tar
放在 m300 的 /tmp
下
盤一下我們的 firmware upgrade shell script 需要幫我們做哪些動作
1205
回憶之前買的 USB DAC
使用 pcm2706
win10 目前聽音樂的環境如下
- Ploytec USB ASIO Driver 2.8.40
- foobar2000 v1.3.13
- ASIO support
- Effect DSP
- Monkey's Audio Decoder
1310
假設我們把 image.tar
放在 m300 的 /tmp
下
盤一下我們的 firmware upgrade shell script 需要幫我們做哪些動作
- 解開
image.tar
- burn the uboot to NAND
- burn the kernel to NAND
- burn the dtb to NAND
- burn the rootfs to NAND
- chnage uboot env
1425
一步一步來
root@M300:/tmp# cat test1.sh
#!/bin/bash
# test firmware upgrade
if [ -n "$1" ]
then
echo "Extract all files from $1"
tar -xf $1
else
echo "Please offer archive .tar"
exit 1
fi
如果沒有提供任何參數的話
# ./test1.sh
Please offer archive .tar
正常狀況是這樣
root@M300:/tmp# ./test1.sh images.tar
Extract all files from images.tar
1435
先練習 burn the uboot to NAND
root@M300:/tmp# cat test2.sh
#!/bin/bash
# test firmware upgrade
if [ -n "$1" ]
then
echo "Extract all files from $1"
tar -xf $1
else
echo "Please offer archive .tar"
exit 1
fi
echo "Burn the uboot to NAND..."
echo "Erasing Boot partition"
flash_erase /dev/mtd0 0 0
echo "Flashing Bootloader"
kobs-ng init -x -v --chip_0_device_path=/dev/mtd0 /tmp/images/u-boot.imx
這邊作的假設是 uboot image 在 /tmp/images/u-boot.imx
試試看
root@M300:/tmp# ./test2.sh images.tar
Extract all files from images.tar
Burn the uboot to NAND...
Erasing Boot partition
Erasing 128 Kibyte @ 2e0000 -- 100 % complete
Flashing Bootloader
MTD CONFIG:
chip_0_device_path = "/dev/mtd0"
chip_1_device_path = "(null)"
search_exponent = 2
data_setup_time = 80
data_hold_time = 60
address_setup_time = 25
data_sample_time = 6
row_address_size = 3
column_address_size = 2
read_command_code1 = 0
read_command_code2 = 48
boot_stream_major_version = 1
boot_stream_minor_version = 0
boot_stream_sub_version = 0
ncb_version = 3
boot_stream_1_address = 0
boot_stream_2_address = 0
-- We add the 1k-padding to the uboot.
.tmp_kobs_ng: verifying using key '00000000000000000000000000000000'
.tmp_kobs_ng: is a valid bootstream for key '00000000000000000000000000000000'
mtd: opening: "/dev/mtd0"
NFC geometry :
ECC Strength : 4
Page Size in Bytes : 2084
Metadata size : 10
ECC Chunk Size in byte : 512
ECC Chunk count : 4
Block Mark Byte Offset : 2018
Block Mark Bit Offset : 4
====================================================
mtd: opened '/dev/mtd0' - '(null)'
mtd: max_boot_stream_size_in_bytes = 1048576
mtd: boot_stream_size_in_bytes = 532480
mtd: boot_stream_size_in_pages = 260
mtd: #1 0x00100000 - 0x00200000 (0x00182000)
mtd: #2 0x00200000 - 0x00300000 (0x00282000)
FCB
m_u32Checksum = 0x00000000
m_u32FingerPrint = 0x20424346
m_u32Version = 0x01000000
m_NANDTiming.m_u8DataSetup = 80
m_NANDTiming.m_u8DataHold = 60
m_NANDTiming.m_u8AddressSetup = 25
m_NANDTiming.m_u8DSAMPLE_TIME = 6
m_u32PageDataSize = 2048
m_u32TotalPageSize = 2112
m_u32SectorsPerBlock = 64
m_u32NumberOfNANDs = 0
m_u32TotalInternalDie = 0
m_u32CellType = 0
m_u32EccBlockNEccType = 2
m_u32EccBlock0Size = 512
m_u32EccBlockNSize = 512
m_u32EccBlock0EccType = 2
m_u32MetadataBytes = 10
m_u32NumEccBlocksPerPage = 3
m_u32EccBlockNEccLevelSDK = 0
m_u32EccBlock0SizeSDK = 0
m_u32EccBlockNSizeSDK = 0
m_u32EccBlock0EccLevelSDK = 0
m_u32NumEccBlocksPerPageSDK = 0
m_u32MetadataBytesSDK = 0
m_u32EraseThreshold = 0
m_u32Firmware1_startingPage = 512
m_u32Firmware2_startingPage = 1024
m_u32PagesInFirmware1 = 260
m_u32PagesInFirmware2 = 260
m_u32DBBTSearchAreaStartAddress = 256
m_u32BadBlockMarkerByte = 2018
m_u32BadBlockMarkerStartBit = 4
m_u32BBMarkerPhysicalOffset = 2048
m_u32BCHType = 0
m_NANDTMTiming.m_u32TMTiming2_ReadLatency = 0
m_NANDTMTiming.m_u32TMTiming2_PreambleDelay = 0
m_NANDTMTiming.m_u32TMTiming2_CEDelay = 0
m_NANDTMTiming.m_u32TMTiming2_PostambleDelay = 0
m_NANDTMTiming.m_u32TMTiming2_CmdAddPause = 0
m_NANDTMTiming.m_u32TMTiming2_DataPause = 0
m_NANDTMTiming.m_u32TMSpeed = 0
m_NANDTMTiming.m_u32TMTiming1_BusyTimeout = 0
m_u32DISBBM = 0
m_u32BBMarkerPhysicalOffsetInSpareData = 0
m_u32OnfiSyncEnable = 0
m_NANDONFITiming.m_u32ONFISpeed = 0
m_NANDONFITiming.m_u32ONFITiming_ReadLatency = 0
m_NANDONFITiming.m_u32ONFITiming_CEDelay = 0
m_NANDONFITiming.m_u32ONFITiming_PreambleDelay = 0
m_NANDONFITiming.m_u32ONFITiming_PostambleDelay = 0
m_NANDONFITiming.m_u32ONFITiming_CmdAddPause = 0
m_NANDONFITiming.m_u32ONFITiming_DataPause = 0
m_NANDONFITiming.m_u32ONFITiming_BusyTimeout = 0
m_u32DISBBSearch = 0
m_u32RandomizerEnable = 0
m_u32ReadRetryEnable = 0
m_u32ReadRetrySeqLength = 0
DBBT
m_u32Checksum = 0x00000000
m_u32FingerPrint = 0x54424244
m_u32Version = 0x01000000
m_u32DBBTNumOfPages = 0
Firmware: image #0 @ 0x100000 size 0x82000 - available 0x100000
Firmware: image #1 @ 0x200000 size 0x82000 - available 0x100000
-------------- Start to write the [ FCB ] -----
mtd: erasing @0:0x0-0x20000
mtd: Writing FCB0 [ @0:0x0 ] (840) *
mtd: erasing @0:0x20000-0x40000
mtd: Writing FCB1 [ @0:0x20000 ] (840) *
mtd: erasing @0:0x40000-0x60000
mtd: Writing FCB2 [ @0:0x40000 ] (840) *
mtd: erasing @0:0x60000-0x80000
mtd: Writing FCB3 [ @0:0x60000 ] (840) *
mtd_commit_bcb(FCB): status 0
-------------- Start to write the [ DBBT ] -----
mtd: erasing @0:0x80000-0xa0000
mtd: Writing DBBT0 [ @0:0x80000 ] (800) *
mtd: erasing @0:0xa0000-0xc0000
mtd: Writing DBBT1 [ @0:0xa0000 ] (800) *
mtd: erasing @0:0xc0000-0xe0000
mtd: Writing DBBT2 [ @0:0xc0000 ] (800) *
mtd: erasing @0:0xe0000-0x100000
mtd: Writing DBBT3 [ @0:0xe0000 ] (800) *
mtd_commit_bcb(DBBT): status 0
---------- Start to write the [ .tmp_kobs_ng ]----
mtd: Writting .tmp_kobs_ng: #0 @0: 0x00100000 - 0x00182000
mtd: erasing @0:0x100000-0x120000
mtd: erasing @0:0x120000-0x140000
mtd: erasing @0:0x140000-0x160000
mtd: erasing @0:0x160000-0x180000
mtd: erasing @0:0x180000-0x1a0000
mtd: We write one page for save guard. *
mtd: Writting .tmp_kobs_ng: #1 @0: 0x00200000 - 0x00282000
mtd: erasing @0:0x200000-0x220000
mtd: erasing @0:0x220000-0x240000
mtd: erasing @0:0x240000-0x260000
mtd: erasing @0:0x260000-0x280000
mtd: erasing @0:0x280000-0x2a0000
mtd: We write one page for save guard. *
重開機試試
開機是正常
不過覺得既然都換掉 uboot 了
那 mtd1 這個 boot_env
應該也要清掉比較好
root@M300:/tmp# cat test2.sh
#!/bin/bash
# test firmware upgrade
if [ -n "$1" ]
then
echo "Extract all files from $1"
tar -xf $1
else
echo "Please offer archive .tar"
exit 1
fi
echo "Burn the uboot to NAND..."
echo "Erasing boot partition"
flash_erase /dev/mtd0 0 0
echo "Erasing boot env partition"
flash_erase /dev/mtd1 0 0
echo "Flashing Bootloader"
kobs-ng init -x -v --chip_0_device_path=/dev/mtd0 /tmp/images/u-boot.imx
1500
再來練習 burn the kernel to NAND
root@M300:/tmp# cat test3.sh
#!/bin/bash
# test firmware upgrade
# burn the kernel to NAND
if [ -n "$1" ]
then
echo "Extract all files from $1"
tar -xf $1
else
echo "Please offer archive .tar"
exit 1
fi
echo "Burn the kernel to NAND..."
if df | grep rootfs_a
then
echo "Erasing kernel_b partition - MTD device 7 (/dev/mtd7)"
flash_erase /dev/mtd7 0 0
echo "Flashing Kernel"
nandwrite -p /dev/mtd7 -p /tmp/images/zImage
else
echo "Erasing kernel_a partition - MTD device 2 (/dev/mtd2)"
flash_erase /dev/mtd2 0 0
echo "Flashing Kernel"
nandwrite -p /dev/mtd2 -p /tmp/images/zImage
fi
試試看
root@M300:/tmp# ./test3.sh images.tar
Extract all files from images.tar
Burn the kernel to NAND...
ubi0:rootfs_a 81080 30032 46872 39% /
Erasing kernel_b partition - MTD device 7 (/dev/mtd7)
Erasing 128 Kibyte @ 9e0000 -- 100 % complete
Flashing Kernel
Writing data to block 0 at offset 0x0
Writing data to block 1 at offset 0x20000
Writing data to block 2 at offset 0x40000
Writing data to block 3 at offset 0x60000
Writing data to block 4 at offset 0x80000
Writing data to block 5 at offset 0xa0000
Writing data to block 6 at offset 0xc0000
Writing data to block 7 at offset 0xe0000
Writing data to block 8 at offset 0x100000
Writing data to block 9 at offset 0x120000
Writing data to block 10 at offset 0x140000
Writing data to block 11 at offset 0x160000
Writing data to block 12 at offset 0x180000
Writing data to block 13 at offset 0x1a0000
Writing data to block 14 at offset 0x1c0000
Writing data to block 15 at offset 0x1e0000
Writing data to block 16 at offset 0x200000
Writing data to block 17 at offset 0x220000
Writing data to block 18 at offset 0x240000
Writing data to block 19 at offset 0x260000
Writing data to block 20 at offset 0x280000
Writing data to block 21 at offset 0x2a0000
Writing data to block 22 at offset 0x2c0000
Writing data to block 23 at offset 0x2e0000
Writing data to block 24 at offset 0x300000
Writing data to block 25 at offset 0x320000
Writing data to block 26 at offset 0x340000
Writing data to block 27 at offset 0x360000
Writing data to block 28 at offset 0x380000
Writing data to block 29 at offset 0x3a0000
Writing data to block 30 at offset 0x3c0000
Writing data to block 31 at offset 0x3e0000
Writing data to block 32 at offset 0x400000
Writing data to block 33 at offset 0x420000
Writing data to block 34 at offset 0x440000
Writing data to block 35 at offset 0x460000
1520
把 burn the dtb to NAND
的部分也加一加
root@M300:/tmp# cat test4.sh
#!/bin/bash
# test firmware upgrade
# burn the kernel to NAND
# burn the dtb to NAND
if [ -n "$1" ]
then
echo "Extract all files from $1"
tar -xf $1
else
echo "Please offer archive .tar"
exit 1
fi
echo "Burn the kernel to NAND..."
if df | grep rootfs_a
then
echo "Erasing kernel_b partition - MTD device 7 (/dev/mtd7)"
flash_erase /dev/mtd7 0 0
echo "Flashing Kernel"
nandwrite -p /dev/mtd7 -p /tmp/images/zImage
else
echo "Erasing kernel_a partition - MTD device 2 (/dev/mtd2)"
flash_erase /dev/mtd2 0 0
echo "Flashing Kernel"
nandwrite -p /dev/mtd2 -p /tmp/images/zImage
fi
echo "Burn the dtb to NAND..."
if df | grep rootfs_a
then
echo "Erasing dtb_b partition - MTD device 8 (/dev/mtd8)"
flash_erase /dev/mtd8 0 0
echo "Flashing dtb"
nandwrite -p /dev/mtd8 -p /tmp/images/zImage-imx6ul-14x14-evk.dtb
else
echo "Erasing dtb_a partition - MTD device 3 (/dev/mtd3)"
flash_erase /dev/mtd3 0 0
echo "Flashing dtb"
nandwrite -p /dev/mtd3 -p /tmp/images/zImage-imx6ul-14x14-evk.dtb
fi
試試看
root@M300:/tmp# ./test4.sh images.tar
Extract all files from images.tar
Burn the kernel to NAND...
ubi0:rootfs_a 81080 30136 46768 39% /
Erasing kernel_b partition - MTD device 7 (/dev/mtd7)
Erasing 128 Kibyte @ 9e0000 -- 100 % complete
Flashing Kernel
Writing data to block 0 at offset 0x0
Writing data to block 1 at offset 0x20000
Writing data to block 2 at offset 0x40000
Writing data to block 3 at offset 0x60000
Writing data to block 4 at offset 0x80000
Writing data to block 5 at offset 0xa0000
Writing data to block 6 at offset 0xc0000
Writing data to block 7 at offset 0xe0000
Writing data to block 8 at offset 0x100000
Writing data to block 9 at offset 0x120000
Writing data to block 10 at offset 0x140000
Writing data to block 11 at offset 0x160000
Writing data to block 12 at offset 0x180000
Writing data to block 13 at offset 0x1a0000
Writing data to block 14 at offset 0x1c0000
Writing data to block 15 at offset 0x1e0000
Writing data to block 16 at offset 0x200000
Writing data to block 17 at offset 0x220000
Writing data to block 18 at offset 0x240000
Writing data to block 19 at offset 0x260000
Writing data to block 20 at offset 0x280000
Writing data to block 21 at offset 0x2a0000
Writing data to block 22 at offset 0x2c0000
Writing data to block 23 at offset 0x2e0000
Writing data to block 24 at offset 0x300000
Writing data to block 25 at offset 0x320000
Writing data to block 26 at offset 0x340000
Writing data to block 27 at offset 0x360000
Writing data to block 28 at offset 0x380000
Writing data to block 29 at offset 0x3a0000
Writing data to block 30 at offset 0x3c0000
Writing data to block 31 at offset 0x3e0000
Writing data to block 32 at offset 0x400000
Writing data to block 33 at offset 0x420000
Writing data to block 34 at offset 0x440000
Writing data to block 35 at offset 0x460000
Burn the dtb to NAND...
ubi0:rootfs_a 81080 30140 46764 39% /
Erasing dtb_b partition - MTD device 8 (/dev/mtd8)
Erasing 128 Kibyte @ 1e0000 -- 100 % complete
Flashing dtb
Writing data to block 0 at offset 0x0
1540
重頭戲 burn the rootfs to NAND
root@M300:/tmp# cat test5.sh
#!/bin/bash
# test firmware upgrade
# burn the rootfs to NAND
if [ -n "$1" ]
then
echo "Extract all files from $1"
tar -xf $1
else
echo "Please offer archive .tar"
exit 1
fi
echo "Burn the rootfs to NAND..."
if df | grep rootfs_a
then
echo "Attach rootfs_b patition to UBI - MTD device 9"
ubiattach /dev/ubi_ctrl -m 9
echo "Create derectory /mnt/rootfs_b"
mkdir -p /mnt/rootfs_b
echo "Mount /mnt/rootfs_b with node ubi2:rootfs_b"
mount -t ubifs ubi2:rootfs_b /mnt/rootfs_b
echo "Writting rootfs"
tar -jxv -C /mnt/rootfs_b -f /tmp/images/core-image-minimal-imx6ulevk.tar.bz2
echo "Unmount /mnt/rootfs_b"
umount /mnt/rootfs_b
else
echo "Attach rootfs_a patition to UBI - MTD device 5"
ubiattach /dev/ubi_ctrl -m 5
echo "Create derectory /mnt/rootfs_a"
mkdir -p /mnt/rootfs_a
echo "Mount /mnt/rootfs_a with node ubi2:rootfs_a"
mount -t ubifs ubi2:rootfs_a /mnt/rootfs_a
echo "Writting rootfs"
tar -jxv -C /mnt/rootfs_a -f /tmp/images/core-image-minimal-imx6ulevk.tar.bz2
echo "Unmount /mnt/rootfs_a"
umount /mnt/rootfs_a
fi
試試看
root@M300:/tmp# ./test5.sh images.tar
Extract all files from images.tar
Burn the rootfs to NAND...
ubi0:rootfs_a 81080 31024 45880 40% /
Attach rootfs_b patition to UBI - MTD device 9
UBI device number 2, total 767 LEBs (97390592 bytes, 92.9 MiB), available 0 LEBs (0 bytes), LEB size 126976 bytes (124.0 KiB)
Create derectory /mnt/rootfs_b
Mount /mnt/rootfs_b with node ubi2:rootfs_b
Writting rootfs
...
Unmount /mnt/rootfs_b
root@M300:/tmp#
1620
再來是 chnage uboot env
我們需要根據目前的 rootfs 來修改 boot env 的 bootargs
和 bootcmd
root@M300:/tmp# cat test6.sh
#!/bin/bash
# test firmware upgrade
# chnage uboot env
echo "Change uboot env..."
if df | grep rootfs_a
then
echo "The active firmware is a, switch to b"
echo "Modify uboot env 'bootargs'"
fw_setenv bootargs "console=ttymxc0,115200 ubi.mtd=9 root=ubi0:rootfs_b rootfstype=ubifs mtdparts=gpmi-nand:3m(boot),1m(boot_env),10m(kernel_a),2m(dtb_a),96m(rootfs_a),16m(config_a),4m(misc),10m(kernel_b),2m(dtb_b),96m(rootfs_b),-(config_b)"
echo "Modify uboot env 'bootcmd'"
fw_setenv bootcmd "saveenv;nand read \${loadaddr} \${kernel_b_addr} 0x800000;nand read \${fdt_addr} \${dtb_b_addr} 0x100000;bootz \${loadaddr} - \${fdt_addr}"
else
echo "The active firmware is b, switch to a"
echo "Modify uboot env 'bootargs'"
fw_setenv bootargs "console=ttymxc0,115200 ubi.mtd=4 root=ubi0:rootfs_a rootfstype=ubifs mtdparts=gpmi-nand:3m(boot),1m(boot_env),10m(kernel_a),2m(dtb_a),96m(rootfs_a),16m(config_a),4m(misc),10m(kernel_b),2m(dtb_b),96m(rootfs_b),-(config_b)"
echo "Modify uboot env 'bootcmd'"
fw_setenv bootcmd "saveenv;nand read \${loadaddr} \${kernel_a_addr} 0x800000;nand read \${fdt_addr} \${dtb_a_addr} 0x100000;bootz \${loadaddr} - \${fdt_addr}"
fi
這邊要注意的是要用雙引號把 bootcmd
的值包起來
以及 ${loadaddr}
寫在 shell script 要寫成 \${loadaddr}
fw_setenv bootcmd "saveenv;nand read \${loadaddr} \${kernel_b_addr} 0x800000;nand read \${fdt_addr} \${dtb_b_addr} 0x100000;bootz \${loadaddr} - \${fdt_addr}"
重開機發現 /etc/rc.local
寫錯了
1700
修正一下順便 commit
commit f65b2127f2b4e6e144454275ce621d77138bc29e
Author: Jeffrey Lee <[email protected]>
Date: Thu Dec 22 16:48:16 2016 +0800
config_b is MTD device 10
diff --git a/fsl-release-bsp/proscend/base_fs/default/rootfs/etc/rc.local b/fsl-release-bsp/proscend/base_fs/default/rootfs/etc/rc.local
index 2b97345..d73f354 100644
--- a/fsl-release-bsp/proscend/base_fs/default/rootfs/etc/rc.local
+++ b/fsl-release-bsp/proscend/base_fs/default/rootfs/etc/rc.local
@@ -60,8 +60,8 @@ echo 1 > /proc/sys/net/ipv4/ip_forward
ubiattach -m 5
mount -t ubifs ubi1:config_a /mnt/data
else
- echo "attach MTD device 9 (mtd9) to UBI - ubi1:config_b"
- ubiattach -m 9
+ echo "attach MTD device 10 (mtd10) to UBI - ubi1:config_b"
+ ubiattach -m 10
mount -t ubifs ubi1:config_b /mnt/data
fi
build image... ok
mfgtool flash firmware... ok
重新打包 images.tar
➜ build_small git:(nandflash) tar -cfh images.tar images/u-boot.imx images/zImage images/zImage-imx6ul-14x14-evk.dtb images/core-image-minimal-imx6ulevk.tar.bz2
整理一下 firmware upgrade shell script
不做 Burn the uboot to NAND...
#!/bin/bash
# firmware upgrade shell script
if [ -n "$1" ]
then
echo "Extract all files from $1"
tar -xf $1
else
echo "Please offer archive .tar"
exit 1
fi
echo "Burn the kernel to NAND..."
if df | grep rootfs_a
then
echo "Erasing kernel_b partition - MTD device 7 (/dev/mtd7)"
flash_erase /dev/mtd7 0 0
echo "Flashing Kernel"
nandwrite -p /dev/mtd7 -p /tmp/images/zImage
else
echo "Erasing kernel_a partition - MTD device 2 (/dev/mtd2)"
flash_erase /dev/mtd2 0 0
echo "Flashing Kernel"
nandwrite -p /dev/mtd2 -p /tmp/images/zImage
fi
echo "Burn the dtb to NAND..."
if df | grep rootfs_a
then
echo "Erasing dtb_b partition - MTD device 8 (/dev/mtd8)"
flash_erase /dev/mtd8 0 0
echo "Flashing dtb"
nandwrite -p /dev/mtd8 -p /tmp/images/zImage-imx6ul-14x14-evk.dtb
else
echo "Erasing dtb_a partition - MTD device 3 (/dev/mtd3)"
flash_erase /dev/mtd3 0 0
echo "Flashing dtb"
nandwrite -p /dev/mtd3 -p /tmp/images/zImage-imx6ul-14x14-evk.dtb
fi
echo "Burn the rootfs to NAND..."
if df | grep rootfs_a
then
echo "Attach rootfs_b patition to UBI - MTD device 9"
ubiattach /dev/ubi_ctrl -m 9
echo "Create derectory /mnt/rootfs_b"
mkdir -p /mnt/rootfs_b
echo "Mount /mnt/rootfs_b with node ubi2:rootfs_b"
mount -t ubifs ubi2:rootfs_b /mnt/rootfs_b
echo "Writting rootfs"
tar -jxv -C /mnt/rootfs_b -f /tmp/images/core-image-minimal-imx6ulevk.tar.bz2
echo "Unmount /mnt/rootfs_b"
umount /mnt/rootfs_b
else
echo "Attach rootfs_a patition to UBI - MTD device 4"
ubiattach /dev/ubi_ctrl -m 4
echo "Create derectory /mnt/rootfs_a"
mkdir -p /mnt/rootfs_a
echo "Mount /mnt/rootfs_a with node ubi2:rootfs_a"
mount -t ubifs ubi2:rootfs_a /mnt/rootfs_a
echo "Writting rootfs"
tar -jxv -C /mnt/rootfs_a -f /tmp/images/core-image-minimal-imx6ulevk.tar.bz2
echo "Unmount /mnt/rootfs_a"
umount /mnt/rootfs_a
fi
echo "Change uboot env..."
if df | grep rootfs_a
then
echo "The active firmware is a, switch to b"
echo "Modify uboot env 'bootargs'"
fw_setenv bootargs "console=ttymxc0,115200 ubi.mtd=9 root=ubi0:rootfs_b rootfstype=ubifs mtdparts=gpmi-nand:3m(boot),1m(boot_env),10m(kernel_a),2m(dtb_a),96m(rootfs_a),16m(config_a),4m(misc),10m(kernel_b),2m(dtb_b),96m(rootfs_b),-(config_b)"
echo "Modify uboot env 'bootcmd'"
fw_setenv bootcmd "saveenv;nand read \${loadaddr} \${kernel_b_addr} 0x800000;nand read \${fdt_addr} \${dtb_b_addr} 0x100000;bootz \${loadaddr} - \${fdt_addr}"
else
echo "The active firmware is b, switch to a"
echo "Modify uboot env 'bootargs'"
fw_setenv bootargs "console=ttymxc0,115200 ubi.mtd=4 root=ubi0:rootfs_a rootfstype=ubifs mtdparts=gpmi-nand:3m(boot),1m(boot_env),10m(kernel_a),2m(dtb_a),96m(rootfs_a),16m(config_a),4m(misc),10m(kernel_b),2m(dtb_b),96m(rootfs_b),-(config_b)"
echo "Modify uboot env 'bootcmd'"
fw_setenv bootcmd "saveenv;nand read \${loadaddr} \${kernel_a_addr} 0x800000;nand read \${fdt_addr} \${dtb_a_addr} 0x100000;bootz \${loadaddr} - \${fdt_addr}"
fi
實際操作看看
writing rootfs 的時候會看到
...
tar: ./etc/rc2.d: time stamp 2016-12-22 09:36:06 is 1139.610433314 s in the future
tar: ./etc/rcS.d: time stamp 2016-12-22 09:36:05 is 1138.610248648 s in the future
tar: ./etc/rc3.d: time stamp 2016-12-22 09:36:06 is 1139.610061314 s in the future
...
參考 http://www.cnblogs.com/eric-geoffrey/p/3256506.html
多個 -m
即可
1755
目前的 firmware upgrade shell script 如下
不包含 burn the uboot to NAND
#!/bin/bash
# firmware upgrade shell script
if [ -n "$1" ]
then
echo "Extract all files from $1"
tar -xf $1
else
echo "Please offer archive .tar"
exit 1
fi
echo "Burn the kernel to NAND..."
if df | grep rootfs_a
then
echo "Erasing kernel_b partition - MTD device 7 (/dev/mtd7)"
flash_erase /dev/mtd7 0 0
echo "Flashing Kernel"
nandwrite -p /dev/mtd7 -p /tmp/images/zImage
else
echo "Erasing kernel_a partition - MTD device 2 (/dev/mtd2)"
flash_erase /dev/mtd2 0 0
echo "Flashing Kernel"
nandwrite -p /dev/mtd2 -p /tmp/images/zImage
fi
echo "Burn the dtb to NAND..."
if df | grep rootfs_a
then
echo "Erasing dtb_b partition - MTD device 8 (/dev/mtd8)"
flash_erase /dev/mtd8 0 0
echo "Flashing dtb"
nandwrite -p /dev/mtd8 -p /tmp/images/zImage-imx6ul-14x14-evk.dtb
else
echo "Erasing dtb_a partition - MTD device 3 (/dev/mtd3)"
flash_erase /dev/mtd3 0 0
echo "Flashing dtb"
nandwrite -p /dev/mtd3 -p /tmp/images/zImage-imx6ul-14x14-evk.dtb
fi
echo "Burn the rootfs to NAND..."
if df | grep rootfs_a
then
echo "Attach rootfs_b patition to UBI - MTD device 9"
ubiattach /dev/ubi_ctrl -m 9
echo "Create derectory /mnt/rootfs_b"
mkdir -p /mnt/rootfs_b
echo "Mount /mnt/rootfs_b with node ubi2:rootfs_b"
mount -t ubifs ubi2:rootfs_b /mnt/rootfs_b
echo "Writting rootfs"
tar -jxv -C /mnt/rootfs_b -f /tmp/images/core-image-minimal-imx6ulevk.tar.bz2
echo "Unmount /mnt/rootfs_b"
umount /mnt/rootfs_b
else
echo "Attach rootfs_a patition to UBI - MTD device 4"
ubiattach /dev/ubi_ctrl -m 4
echo "Create derectory /mnt/rootfs_a"
mkdir -p /mnt/rootfs_a
echo "Mount /mnt/rootfs_a with node ubi2:rootfs_a"
mount -t ubifs ubi2:rootfs_a /mnt/rootfs_a
echo "Writting rootfs"
tar -jxvm -C /mnt/rootfs_a -f /tmp/images/core-image-minimal-imx6ulevk.tar.bz2
echo "Unmount /mnt/rootfs_a"
umount /mnt/rootfs_a
fi
echo "Change uboot env..."
if df | grep rootfs_a
then
echo "The active firmware is a, switch to b"
echo "Modify uboot env 'bootargs'"
fw_setenv bootargs "console=ttymxc0,115200 ubi.mtd=9 root=ubi0:rootfs_b rootfstype=ubifs mtdparts=gpmi-nand:3m(boot),1m(boot_env),10m(kernel_a),2m(dtb_a),96m(rootfs_a),16m(config_a),4m(misc),10m(kernel_b),2m(dtb_b),96m(rootfs_b),-(config_b)"
echo "Modify uboot env 'bootcmd'"
fw_setenv bootcmd "saveenv;nand read \${loadaddr} \${kernel_b_addr} 0x800000;nand read \${fdt_addr} \${dtb_b_addr} 0x100000;bootz \${loadaddr} - \${fdt_addr}"
else
echo "The active firmware is b, switch to a"
echo "Modify uboot env 'bootargs'"
fw_setenv bootargs "console=ttymxc0,115200 ubi.mtd=4 root=ubi0:rootfs_a rootfstype=ubifs mtdparts=gpmi-nand:3m(boot),1m(boot_env),10m(kernel_a),2m(dtb_a),96m(rootfs_a),16m(config_a),4m(misc),10m(kernel_b),2m(dtb_b),96m(rootfs_b),-(config_b)"
echo "Modify uboot env 'bootcmd'"
fw_setenv bootcmd "saveenv;nand read \${loadaddr} \${kernel_a_addr} 0x800000;nand read \${fdt_addr} \${dtb_a_addr} 0x100000;bootz \${loadaddr} - \${fdt_addr}"
fi
實際操作了幾次
firmware 在 a 和 b 之間也切換了幾次
目前算還蠻順利的
不過目前的 shell script 中間出錯還是會一路走完
一直走到 Change uboot env...