如何在Uboot下读取ubifs中的更新档更新SPINAND

Nuvoton_N329 |浏览178次
收藏|2023/09/15 00:28

满意回答

2023/09/15 00:30

1、替换附件2个文件

mtd.c  -->uboot-custom/cmd/mtd.c

ma35d1.dts -->uboot-custom/arch/arm/dts/ma35d1.dts

2、修改uboot-env.txt文件

board/nuvoton/ma35d1/uboot-env.txt

添加

1. fw_upgrade=0

2. 在spinandboot命令下添加 if test ${fw_upgrade} = '1' ; then echo "fw_upgrade... ..."; ubi part rootfs; ubifsmount ubi:rootfs; ubifsload 0x80800000 uboot-update-cmd.img; source 0x80800000; setenv fw_upgrade 0; saveenv; reset;fi; 

spinandboot=if test ${fw_upgrade} = '1' ; then echo "fw_upgrade... ..."; ubi part rootfs; ubifsmount ubi:rootfs; ubifsload 0x80800000 uboot-update-cmd.img; source 0x80800000; setenv fw_upgrade 0; saveenv; reset;fi; if test ${mtdids} = 'spi-nand0=spi-nand0' ;then echo "Booting from spinand ... ..."; mtd list; setenv bootargs noinitrd ubi.mtd=${spinand_ubiblock} root=ubi0:rootfs rootfstype=ubifs rw rootwait=1 console=ttyS0,115200n8 rdinit=/sbin/init mem=${kernelmem}; mtd read kernel ${kernel_addr_r}; mtd read device-tree ${fdt_addr_r}; booti ${kernel_addr_r} - ${fdt_addr_r}; fi

然后编译:

make uboot-rebuild

make arm-tursted-firmware-rebuild

make 

烧录,以这个为基础

3、新建一个文件uboot-update.script,里面是下面的命令:(根据要更新的内容调整其中的命令)

mtd erase device-tree

mtd erase kernel

mtd erase rootfs

ubifsload 0x80800000 dtb

mtd write device-tree 0x80800000

ubifsload 0x80800000 kernel

mtd write kernel 0x80800000

ubifsload 0x80800000 rootfs

mtd write rootfs 0x80800000

4、用output/host/bin目录下的mkimage工具将文件uboot-update.script转换成image(uboot-update-cmd.img)

 ./mkimage -A arm -O linux -T script -C none -n "uboot-script" -d ~/workspace/uboot-update-cmd.script ~/workspace/uboot-update-cmd.img


5, 更新

在Linux下,把dtb,kernel,rootfs,uboot-update-cmd.img放到定义的upgrade ubi patition(这个partion的volume和在env中的挂载ubi part "volume"和ubifsmount ubi:volume相一致,当前举例中是rootfs)

使用fw_setenv设置fw_upgrade = 1


cat /proc/mtd 确认env所在的partition

dev:    size   erasesize  name

mtd0: 00300000 00020000 "nand-uboot"

mtd1: 000c0000 00020000 "nand-uboot-env"

mtd2: 00040000 00020000 "nand-device-tree"

mtd3: 01800000 00020000 "nand-kernel"

mtd4: 06400000 00020000 "nand-rootfs"

mtd5: 00300000 00020000 "spinand-uboot"

mtd6: 00300000 00020000 "spinand-uboot-env"

mtd7: 00100000 00020000 "spinand-device-tree"

mtd8: 01800000 00020000 "spinand-kernel"

mtd9: 06400000 00020000 "spinand-rootfs"

这里是mtd6

ubiattach -m 6

fw_setenv fw_upgrade 1


6、reboot升级,升级后uboot更新后中将 fw_upgrade设置为0


nuvoton2022

其他回答(0)
0人关注该问题
+1
 加载中...