【驱动】uboot环境变量分析

0、bootcmd

0.1 飞凌原设置
bootcmd=if mmc rescan; then if run loadbootscript; then run bootscript; else if test ${bootdev} = sd1; then echo update firmware.........;run update_from_sd;else echo mmc boot..........;if run loadimage; then run mmcboot; else run netboot; fi; fi; fi; else run netboot; fi;

0.1.1 bootcmd解析
if mmc rescan; then //mmc rescan:重新搜索mmc设备。如果有mmc设备
    if run loadbootscript; then //如果是uboot脚本启动,则执行脚本,参见0.1.2
        run bootscript;         //参见0.1.3
    else
        if test ${bootdev} = sd1; then //如果是从sd1启动,
            echo update firmware.........;    
            run update_from_sd;                //则执行更新固件的脚本,参见0.1.4
        else
            echo mmc boot..........;
            if run loadimage; then         //参见0.1.5
                run mmcboot;             //参见0.1.6
            else
                run netboot;
            fi;
        fi;
    fi;
else
    run netboot;
fi;

0.1.2 loadbootscript解析
loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};
a)fatload 该命令用于从 FAT 文件系统设备中读取指定文件放入指定内存中,用法介绍如下:
    usage: fatload [bytes]  
如介绍所述,当要读取文件时,需要设备已经完成初始化并注册到文件系统中,读取时用法如: fatload mmc 1 0x81000000 boot.img[size],其中 mmc 1 为文件 boot.img 保存的设备,0x81000000 为读取的内容存放的内存地址。
b)去变量后的命令
mmcdev=1
mmcpart=1
loadaddr=0x80800000
script=boot.scr
fatload mmc 1:1 0x80800000 boot.scr

0.1.3 bootscript解析
bootscript=echo Running bootscript from mmc ...; source    //source运行脚本boot.scr

0.1.4 update_from_sd
update_from_sd=run update_emmc;
update_emmc=mmc rescan;fatload mmc 0 ${loadaddr} /bin/${image}; fatload mmc 0 ${initrd_addr} /bin/ramdisk.img.u; fatload mmc 0 ${fdt_addr} /bin/${fdt_file}; set bootargs console=${console},${baudrate} cma=320M rdinit=/linuxrc; bootz ${loadaddr} ${initrd_addr} ${fdt_addr};

0.1.4.1 解析update_emmc
mmc rescan;
fatload mmc 0 ${loadaddr} /bin/${image};             ------>fatload mmc 0 0x80800000 /bin/zImage;
fatload mmc 0 ${initrd_addr} /bin/ramdisk.img.u;     ------>fatload mmc 0 0x83800000 /bin/ramdisk.img.u
fatload mmc 0 ${fdt_addr} /bin/${fdt_file};          ------>fatload mmc 0 0x83000000 /bin/imx6ul-14x14-evk.dtb
set bootargs console=${console},${baudrate} cma=320M rdinit=/linuxrc;      ------> set bootargs console=ttymxc0,115200 cma=320M rdinit=/linuxrc
bootz ${loadaddr} ${initrd_addr} ${fdt_addr};          ------>bootz 0x80800000 0x83800000 0x83000000

0.1.5 loadimage解析
loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
--------> fatload mmc 1:1 0x80800000 zImage

0.1.6 mmc启动解析
0.1.6.1 mmcboot变量
mmcboot=echo Booting from mmc ...; run mmcargs; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then bootz ${loadaddr} - ${fdt_addr}; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi;

0.6.1.2 mmcboot解析
echo Booting from mmc ...;
run mmcargs;
if test ${boot_fdt} = yes || test ${boot_fdt} = try; then
    if run loadfdt; then
        bootz ${loadaddr} - ${fdt_addr};
    else
        if test ${boot_fdt} = try; then
            bootz;
        else
            echo WARN: Cannot load the DT;
        fi;
    fi;
else
    bootz;
fi;

0.6.1.3 mmcargs设置bootargs参数
mmcargs=setenv bootargs console=${console},${baudrate} calibrate=${calibrate} cma=320M root=${mmcroot}
------->setenv bootargs console==ttymxc0,115200 calibrate=【空】  cma=320M root=/dev/mmcblk1p2 rootwait rw
//rw是声明启动权限,即以读写方式启动;rootwait是指等待设备/dev/mmcblk0p2设备就绪后才尝试挂载rootfs。如果没有此参数,linux内核启动时可能会在存储设备尚未就绪是就尝试挂载rootfs,此时肯定挂载失败,那么启动也就失败了。

0.2 试验设置
bootcmd=if 0; then if run loadbootscript; then run bootscript; else if test ${bootdev} = sd1; then echo update firmware.........;run update_from_sd;else echo mmc boot..........;if run loadimage; then run mmcboot; else run netboot; fi; fi; fi; else run netboot; fi;

设置命令 setenv bootcmd "if 0; then if run loadbootscript; then run bootscript; else if test ${bootdev} = sd1; then echo update firmware.........;run update_from_sd;else echo mmc boot..........;if run loadimage; then run mmcboot; else run netboot; fi; fi; fi; else run netboot; fi;"

1、netboot

1.1 飞凌原设置
netboot=echo Booting from net ...; run netargs; if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; ${get_cmd} ${image}; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if ${get_cmd} ${fdt_addr} ${fdt_file}; then bootz ${loadaddr} - ${fdt_addr}; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi;

1.1.1 解析
echo Booting from net ...;
run netargs;
if test ${ip_dyn} = yes; then     //-------->ip_dyn=yes
    setenv get_cmd dhcp;
else
    setenv get_cmd tftp;
fi;
${get_cmd} ${image};                                         //-------->dhcp zImage ;是否需要改为tftp 0x80800000 zImage????即ip_dyn=no;${get_cmd} ${loadaddr} ${image};
if test ${boot_fdt} = yes || test ${boot_fdt} = try; then     //-------->boot_fdt=try
    if ${get_cmd} ${fdt_addr} ${fdt_file}; then             //-------->dhcp 0x83000000 imx6ul-14x14-evk.dtb
        bootz ${loadaddr} - ${fdt_addr};                     //-------->bootz  0x80800000 - 0x83000000
    else
        if test ${boot_fdt} = try; then
            bootz;
        else
            echo WARN: Cannot load the DT;
        fi;
    fi;
else
    bootz;
fi;

1.1.1.1 netargs
netargs=setenv bootargs console=${console},${baudrate} root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp
----------->setenv bootargs console==ttymxc0,115200 root=/dev/nfs  ip=dhcp nfsroot=【空】:【空】,v3,tcp

1.1.1.2 需要设置${serverip}:${nfsroot}


二、设置命令
1、飞凌原设置
setenv bootcmd "if mmc rescan; then if run loadbootscript; then run bootscript; else if test ${bootdev} = sd1; then echo update firmware.........;run update_from_sd;else echo mmc boot..........;if run loadimage; then run mmcboot; else run netboot; fi; fi; fi; else run netboot; fi;"
setenv ip_dyn=yes
setenv serverip
setenv nfsroot

2、试验修改
setenv bootcmd "if 0; then if run loadbootscript; then run bootscript; else if test ${bootdev} = sd1; then echo update firmware.........;run update_from_sd;else echo mmc boot..........;if run loadimage; then run mmcboot; else run netboot; fi; fi; fi; else run netboot; fi;"
setenv ip_dyn no
setenv serverip 172.16.12.89
setenv nfsroot "/home/lisa/3-nfsrootfs/im6ul_rootfs"


你可能感兴趣的:(linux驱动)