UBOOT环境配置及系统烧写
+ -

uboot默认参数信息

2025-08-06 95 0

输出信息

CPU:   Freescale i.MX6ULL rev1.1 792 MHz (running at 396 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 47C
Reset cause: POR
Board: I.MX6U ALPHA|MINI
I2C:   ready
DRAM:  512 MiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
In:    serial
Out:   serial
Err:   serial
switch to partitions #0, OK
mmc1(part 0) is current device
Net:   FEC1
Error: FEC1 address 11:22:33:44:55:99 illegal value

配置信息

=> printenv
baudrate=115200
board_name=EVK
board_rev=14X14
boot_fdt=try #yes:必须成功加载设备树才能启动,no:不使用设备树启动,try:尝试加载设备树,如果失败则不使用设备树继续启动
bootargs=console=ttymxc0,115200 root=/dev/nfs \
nfsroot=192.168.0.3:/home/zzmt/Desktop/nfs/rootfs,proto=tcp rw \
ip=192.168.0.66:192.168.0.3:192.168.0.1:255.255.255.0::eth0:off 
bootcmd=tftp 80800000 zImage; tftp 83000000 imx6ull-14x14-evk-emmc.dtb;bootz 80800000 - 83000000
bootcmd_mfg=run mfgtool_args;bootz ${loadaddr} ${initrd_addr} ${fdt_addr};
bootdelay=3
bootscript=echo Running bootscript from mmc ...; source
console=ttymxc0
ethact=FEC1 #表示Fast Ethernet Controller,i.MX6ULL的以太网控制器
ethaddr=11:22:33:44:55:99
ethprime=FEC
fdt_addr=0x83000000
fdt_file=imx6ull-14x14-emmc-4.3-480x272-c.dtb
fdt_high=0xffffffff #限制设备树和initrd在内存中的加载位置,xffffffff 表示不限制
findfdt=if test $fdt_file = undefined; then if test $board_name = EVK && test $board_rev = 9X9; then setenv fdt_file imx6ull-9x9-evk.dtb; fi; if test $board_name = EVK && test $board_rev = 14X14; then setenv fdt_file imx6ull-14x14-evk.dtb; fi; if test $fdt_file = undefined; then echo WARNING: Could not determine dtb to use; fi; fi;
gatewayip=192.168.0.1
image=zImage  #内核镜像文件名
initrd_addr=0x83800000
initrd_high=0xffffffff #xffffffff 表示不限制
ip_dyn=yes  #yes:使用DHCP获取IP,no:使用静态IP
ipaddr=192.168.0.66
loadaddr=0x80800000
loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};FAT文件系统加载boot.scr
loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file} #从MMC加载设备树文件
loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image} #从MMC加载内核镜像。
logo_file=alientek.bmp ##启动logo图片文件名
mfgtool_args=setenv bootargs console=${console},${baudrate} rdinit=/linuxrc g_mass_storage.stall=0 g_mass_storage.removable=1 g_mass_storage.file=/fat g_mass_storage.ro=1 g_mass_storage.idVendor=0x066F g_mass_storage.idProduct=0x37FF g_mass_storage.iSerialNumber="" clk_ignore_unused 
mmcargs=setenv bootargs console=${console},${baudrate} root=${mmcroot}
mmcautodetect=yes
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;
mmcdev=1 #1 通常表示eMMC,0 通常表示SD卡
mmcpart=1 #表示第一个分区
mmcroot=/dev/mmcblk1p2 rootwait rw
netargs=setenv bootargs console=${console},${baudrate} root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp
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;
netmask=255.255.255.0
panel=ATK-LCD-4.3-480x272 ##LCD面板型号,用于显示驱动配置
script=boot.scr
serverip=192.168.0.3
splashimage=0x88000000
splashpos=m,m #屏幕中央显示(middle)
stderr=serial
stdin=serial
stdout=serial

Environment size: 2772/8188 bytes
基本配置
baudrate=115200                    # 串口波特率
board_name=EVK                     # 板卡名称
board_rev=14X14                    # 板卡版本
bootdelay=3                        # 启动延时3秒
console=ttymxc0                    # 控制台设备
网络配置
baudrate=115200                    # 串口波特率
board_name=EVK                     # 板卡名称
board_rev=14X14                    # 板卡版本
bootdelay=3                        # 启动延时3秒
console=ttymxc0                    # 控制台设备
内存地址定义
loadaddr=0x80800000               # 内核加载地址
fdt_addr=0x83000000               # 设备树加载地址
initrd_addr=0x83800000            # 初始RAM磁盘加载地址
splashimage=0x88000000            # 启动画面地址
默认启动命令bootcmd

bootcmd 保存着 uboot 默认命令, uboot 倒计时结束以后就会执行 bootcmd 中的命令.

bootcmd=tftp 80800000 zImage; tftp 83000000 imx6ull-14x14-evk-emmc.dtb; bootz 80800000 - 83000000
  1. 通过 TFTP 下载内核 zImage 到 0x80800000
  2. 通过 TFTP 下载设备树 imx6ull-14x14-evk-emmc.dtb 到 0x83000000
  3. 使用 bootz 命令启动内核
mmc dev 1 //切换到 EMMC
fatload mmc 1:1 0x80800000 zImage //读取 zImage 到 0x80800000 处
fatload mmc 1:1 0x83000000 imx6ull-14x14-evk.dtb //读取设备树到 0x83000000 处
bootz 0x80800000 - 0x83000000 //启动 Linux

信息

=> ls mmc 1:1
    39459   imx6ull-14x14-emmc-10.1-1280x800-c.dtb 
    39459   imx6ull-14x14-emmc-4.3-480x272-c.dtb 
    39459   imx6ull-14x14-emmc-4.3-800x480-c.dtb 
    39459   imx6ull-14x14-emmc-7-1024x600-c.dtb 
    39459   imx6ull-14x14-emmc-7-800x480-c.dtb 
    40295   imx6ull-14x14-emmc-hdmi.dtb 
    40203   imx6ull-14x14-emmc-vga.dtb 
  6785480   zimage
网络启动配置
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;

格式化后

echo Booting from net ...;
run netargs;

if test ${ip_dyn} = yes; then  //dhcp
    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

EMMC启动配置

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;

格式化后

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
设备树选择逻辑
findfdt=if test $fdt_file = undefined; then 
    if test $board_name = EVK && test $board_rev = 9X9; then 
        setenv fdt_file imx6ull-9x9-evk.dtb; 
    fi; 
    if test $board_name = EVK && test $board_rev = 14X14; then 
        setenv fdt_file imx6ull-14x14-evk.dtb; 
    fi; 
    if test $fdt_file = undefined; then 
        echo WARNING: Could not determine dtb to use; 
    fi; 
fi;
网络文件系统启动参数
bootargs=console=ttymxc0,115200 root=/dev/nfs \
nfsroot=192.168.0.3:/home/zzmt/Desktop/nfs/rootfs,proto=tcp rw \
ip=192.168.0.66:192.168.0.3:192.168.0.1:255.255.255.0::eth0:off
  • root=/dev/nfs:使用NFS作为根文件系统
  • nfsroot=192.168.0.3:/home/zzmt/Desktop/nfs/rootfs:NFS服务器路径
  • ip=192.168.0.66:192.168.0.3:192.168.0.1:静态IP配置

bootargs 环境变量是由 mmcargs 设置的,默认mmcargs内容如下:

mmcargs=setenv bootargs console=${console},${baudrate} root=${mmcroot}

展开后

mmcargs=setenv bootargs console= ttymxc0, 115200 root=/dev/mmcblk1p2 rootwait rw
  • console 用来设置 linux 终端
  • root 用来设置根文件系统的位置
  • rootwait 表示等待 mmc 设备初始化完成以后再挂载
  • rw 表示根文件系统是可以读写的,不加rw 的话可能无法在根文件系统中进行写操作,只能进行读操作
=> ls mmc 1:2
<DIR>       4096 .
<DIR>       4096 ..
<DIR>      16384 lost+found
<DIR>       4096 sys
<DIR>       4096 boot
<DIR>       4096 mnt
<DIR>       4096 lib
<DIR>       4096 run
<DIR>       4096 proc
<DIR>       4096 usr
<DIR>       4096 home
<DIR>       4096 sbin
<DIR>       4096 dev
<DIR>       4096 opt
<DIR>       4096 etc
<DIR>       4096 bin
<DIR>       4096 var
<DIR>       4096 media
<SYM>          8 tmp
<DIR>       4096 .cache
<DIR>       4096 .config
EMMC启动参数
mmcroot=/dev/mmcblk1p2 rootwait rw
  • 从EMMC的第2个分区启动

制造工具相关

bootcmd_mfg=run mfgtool_args;bootz ${loadaddr} ${initrd_addr} ${fdt_addr};

解析后

mfgtool_args=setenv bootargs console=${console},${baudrate} rdinit=/linuxrc g_mass_storage.stall=0 g_mass_storage.removable=1 g_mass_storage.file=/fat g_mass_storage.ro=1 g_mass_storage.idVendor=0x066F g_mass_storage.idProduct=0x37FF g_mass_storage.iSerialNumber="" clk_ignore_unused
  • g_mass_storage.:Linux USB Gadget驱动参数,将设备模拟为U盘
  • rdinit=/linuxrc:指定初始进程
  • clk_ignore_unused:忽略未使用的时钟,防止功耗管理关闭必要时钟

0 篇笔记 写笔记

关注公众号
取消
感谢您的支持,我会继续努力的!
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

您的支持,是我们前进的动力!