为了满足升级系统的需要,uboot环境变量的组织主要包括:
a. 支持failsafe和app两个程序的分区
b. 支持bootchoice设定和启动区分

下面以Elgakingdom板子为例,
uldr, uboot, env --- 存储在nor中
failsafe, app --- 各分16m存储在nand中

下面是环境变量的组织,暂时未考虑root从flash中mount的问题:
====================================================================
# TODO
# bootmode2 and bootmode4 => should mount root from flash
#

# board special
setenv altflash NAND
setenv mtdids 'nor0=nx_2016,nand0=nx_2017'
setenv mtdparts 'mtdparts=nx_2017:16m(k0),16m(k1),-(extra)'
setenv nandboot1 'nand read 0 0x500000; go 0x8000'
setenv nandboot2 'nand read 0x1000000 0x500000; go 0x8000'

# for eth boot
setenv ethport 'eth0'

setenv addrootpath 'setenv rootpath /home/qianjiang/nfsroot/rootfs'
setenv addnfs 'setenv bootargs ${bootargs} root=/dev/nfs rw nfsroot=${serverip}:${rootpath},tcp'
setenv addapppath 'setenv apppath /home/qianjiang/nfsroot/appfs'
setenv addappfs 'setenv bootargs ${bootargs} APPFS=${serverip}:${apppath}'

# common envs
setenv setargs 'setenv bootargs noinitrd ip=${ipaddr}:${serverip}::::${ethport} console=ttyS1,115200n8 ${mtdparts}'

# bootchoice
# 1: kernel from flash and root on nfs
# 2: kernel from flash and root on flash
# 3: kernel from tftp and root on nfs
# 4: failsafe from flash
setenv bootchoice 1

# define boot
setenv bootcmd 'echo "Boot mode is :"; run bootmode${bootchoice}'

# define bootmode
setenv bootmode1 'run setargs; run addrootpath; run addnfs; run addapppath; run addappfs; run nandboot2'
setenv bootmode2 'run setargs; run addrootpath; run addnfs; run addapppath; run addappfs; run nandboot2'
setenv bootmode3 'run setargs; run addrootpath; run addnfs; run addapppath; run addappfs; tftpboot; go 0x8000'
setenv bootmode4 'run setargs; run addrootpath; run addnfs; run addapppath; run addappfs; run nandboot1'

setenv uboot_cmdline 1
saveenv
====================================================================
实验方法:
擦除env,通过expect写入,载入k0和k1如下:
tftp vmlinux.bin
nand erase k0
nand write k0

tftp vmlinux.bin
nand erase k1
nand write k1

通过uboot改变bootchoice可以看到不同的启动方式。

Note: same will be for rootfs and appfs
tftp rootfs.arm.jffs2.nand
nand erase root
nand write root

tftp appfs.jffs2.nand
nand erase appfs
nand write appfs

最后,该设置应该置入默认设置中。