Linux学习笔记(7)——u-boot常用指令

  1. 信息查询命令
    1.1. bdinfo命令:命令用于查看板子信息
    如正点原子linux alpha开发板信息
=> bdinfo
arch_number = 0x00000000
boot_params = 0x80000100
DRAM bank   = 0x00000000
-> start    = 0x80000000
-> size     = 0x20000000
eth0name    = FEC1
ethaddr     = (not set)
current eth = FEC1
ip_addr     = 
baudrate    = 115200 bps
TLB addr    = 0x9FFF0000
relocaddr   = 0x9FF48000
reloc off   = 0x18748000
irq_sp      = 0x9EF45EA0
sp start    = 0x9EF45E90
FB base     = 0x00000000

1.2. printenv命令:用于输出环境变量信息

=> printenv
baudrate=115200
board_name=EVK
board_rev=14X14
boot_fdt=try
bootargs=console=ttymxc0,115200 root=/dev/nfs ip=dhcp nfsroot=:,v3,tcp
bootcmd=run findfdt;mmc dev ${mmcdev};mmc dev ${mmcdev}; if mmc rescan; then if run loadbootscript; then run bootscript; else if run loadimage; then run mmcboot; else run netboot; fi; fi; else run netboot; fi
bootcmd_mfg=run mfgtool_args;bootz ${loadaddr} ${initrd_addr} ${fdt_addr};
bootdelay=3
bootscript=echo Running bootscript from mmc ...; source
console=ttymxc0
ethact=FEC1
ethprime=FEC
fdt_addr=0x83000000
fdt_file=imx6ull-14x14-emmc-4.3-480x272-c.dtb
fdt_high=0xffffffff
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;
get_cmd=dhcp
image=zImage
initrd_addr=0x83800000
initrd_high=0xffffffff
ip_dyn=yes
loadaddr=0x80800000
loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};
loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
logo_file=alientek.bmp
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=0
mmcpart=1
mmcroot=/dev/mmcblk0p2 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;
panel=ATK-LCD-4.3-480x272
script=boot.scr
splashimage=0x88000000
splashpos=m,m

Environment size: 2624/8188 bytes

1.3. version命令:用于查看 uboot 的版本号

U-Boot 2016.03 (Dec 08 2019 - 19:34:40 +0800)
arm-linux-gnueabihf-gcc (Linaro GCC 7.4-2019.02) 7.4.1 20181213 [linaro-7.4-2019.02 revision 56ec6f6b99cc167ff0c2f8e1a2eed33b1edc85d4]
GNU ld (Linaro_Binutils-2019.02) 2.28.2.20170706
  1. 环境变量操作命令
    2.1. setenv命令:设置环境变量
    2.2. saveenv命令:保存环境变量
=> ? setenv
setenv - set environment variables

Usage:
setenv [-f] name value ...
    - [forcibly] set environment variable 'name' to 'value ...'
setenv [-f] name
    - [forcibly] delete environment variable 'name'

先查看一下其应用信息,即通过环境变量的名称对此变量设置相应的值,[-f]是强制设置参数,属可选项。

设置启动延时

=> setenv bootdelay 5
=> saveenv          
Saving Environment to MMC...
Writing to MMC(0)... done

设置bootcmd信息

=> setenv bootcmd 'console=ttymxc0,115200 root=/dev/mmcblk1p2 rootwait rw'
=> saveenv
Saving Environment to MMC...
Writing to MMC(0)... done
  1. 内存操作命令
    3.1. md命令:用于显示内存值,格式如下
=> ? md
md - memory display

Usage:
md [.b, .w, .l] address [# of objects]

如以几种格式显示内存指令:

=> md.b 87800000 10
87800000: b8 00 00 ea 14 f0 9f e5 14 f0 9f e5 14 f0 9f e5
=> md.w 87800000 10
87800000: 00b8 ea00 f014 e59f f014 e59f f014 e59f    
87800010: f014 e59f f014 e59f f014 e59f f014 e59f    
=> md.l 87800000 10
87800000: ea0000b8 e59ff014 e59ff014 e59ff014    
87800010: e59ff014 e59ff014 e59ff014 e59ff014    
87800020: 87800060 878000c0 87800120 87800180 
87800030: 878001e0 87800240 878002a0 deadbeef  

3.2 nm命令:用于修改指定地址的内存值,命令格式如下:

=> ? nm
nm - memory modify (constant address)

Usage:
nm [.b, .w, .l] address

以下以长整型显示并修改0x80000000地址的内容

=> md.l 80000000 1
80000000: ffffffff                               ....
=> nm.l 80000000
80000000: ffffffff ? 12345678
80000000: 12345678 ? q
=> md.l 80000000 1
80000000: 12345678

3.3. mm命令:修改指定地址的内存值,其地址会自增。其指令格式如下

=> ? mm
mm - memory modify (auto-incrementing address)

Usage:
mm [.b, .w, .l] address

以下以长整型显示并修改0x80000000起始地址的4个字内容

=> mm.l 80000000
80000000: 12345678 ? 
80000004: ffffffff ? 87654321
80000008: ffffffff ? 34127856
8000000c: ffffffff ? 78563412
80000010: ffffffff ? q
=> md.l 80000000 4
80000000: 12345678 87654321 34127856 78563412

3.4. mw命令,用于使用一个指定的数据填充一段内存,命令格式如下

=> ? mw
mw - memory write (fill)

Usage:
mw [.b, .w, .l] address value [count]

使用.l 格式将以 0X80000000 为起始地址的 4 个
内存块(4 * 4=16 字节)填充为 0x55AA55AA

=> mw.l 80000000 0x55AA55AA 4
=> md.l 80000000 4
80000000: 55aa55aa 55aa55aa 55aa55aa 55aa55aa

3.5. cp命令,用于将数据从一段存储空间拷贝到另一段存储空间,命令格式如下

=> ? cp 
cp - memory copy

Usage:
cp [.b, .w, .l] source target count

使用.l 格式将 0x80000000 处的地址拷贝到 0X80000100 处,长度为 4 个

=> cp.l 80000000 80000100 4 
=> md.l 80000000 4
80000000: 55aa55aa 55aa55aa 55aa55aa 55aa55aa    .U.U.U.U.U.U.U.U
=> md.l 80000100 4
80000100: 55aa55aa 55aa55aa 55aa55aa 55aa55aa

3.6 cmp命令,用于比较两段内存的数据是否相等,命令格式如下

=> ? cmp
cmp - memory compare

Usage:
cmp [.b, .w, .l] addr1 addr2 count

这里以,l格式比较0x80000000起始地址与0x80000100起始地址的6个存储空间是否相等

=> cmp.l 80000000 80000100 6
Total of 6 word(s) were the same
  1. 网络操作命令
    4.1 nfs命令,使用NFS协议通过网络加载镜像文件到指定地址。
    命令格式如下:
=> ? nfs 
nfs - boot image via network using NFS protocol

Usage:
nfs [loadAddress] [[hostIPaddr:]bootfilename]

这里将配置好的zImage镜像文件加载到0x80800000地址,执行卡壳了,查了几天了,没有找到原因(有朋友说需要把nfs服务版本改为v2的就可以了,还没有验证)。

=> nfs 80800000 192.168.1.55:/home/glen/linux/nfs/zImage
FEC1 Waiting for PHY auto negotiation to complete... done
Using FEC1 device
File transfer via NFS from server 192.168.1.55; our IP address is 192.168.1.56
Filename '/home/glen/linux/nfs/zImage'.
Load address: 0x80800000
Loading: *** ERROR: File lookup fail
T T T T T T 

4.2 tftp命令,使用TFTP协议通过网络加载镜像文件到指定地址。
命令格式如下:

=> ? tftp
tftpboot - boot image via network using TFTP protocol

Usage:
tftpboot [loadAddress] [[hostIPaddr:]bootfilename]

linux主机需要安装tftp服务,并且进行相应地配置,这里就不写了。这里将配置好的zImage镜像文件加载到0x80800000地址。

=> tftp 80800000 zImage
Using FEC1 device
TFTP from server 192.168.1.55; our IP address is 192.168.1.56
Filename 'zImage'.
Load address: 0x80800000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #######
         1.7 MiB/s
done
Bytes transferred = 6777096 (676908 hex)
  1. EMMC操作命令
    5.1 mmc info命令,用于输出当前选中的mmc info信息。
    执行命令如下:
=> mmc info
Device: FSL_SDHC
Manufacturer ID: 15
OEM: 100
Name: 8GTF4 
Tran Speed: 52000000
Rd Block Len: 512
MMC version 4.0
High Capacity: Yes
Capacity: 7.3 GiB
Bus Width: 8-bit
Erase Group Size: 512 KiB

5.2 mmc rescan命令,用于扫描目标板上所有的MMC设备,包括EMMC和SD卡。
执行命令如下,执行后无回复信息。

=> mmc rescan

5.3 mmc list命令,列出目标板上所有的MMC设备。
执行命令如下:

=> mmc list
FSL_SDHC: 0
FSL_SDHC: 1 (eMMC)

注:FSL_SDHC: 0是目标板的SD卡,FSL_SDHC: 1(eMMC)是核心板上焊接的8GiB的emmc存储芯片。

5.4 mmc dev命令,用于切换当前MMC设备。
执行命令如下:

=> mmc dev
switch to partitions #0, OK
mmc1(part 0) is current device
=> mmc dev 0
switch to partitions #0, OK
mmc0 is current device
=> mmc dev 1
switch to partitions #0, OK
mmc1(part 0) is current device

5.4 mmc part命令,用于查看当前MMC设备的分区情况。
执行命令如下:

=> mmc part

Partition Map for MMC device 1  --   Partition Type: DOS

Part    Start Sector    Num Sectors     UUID            Type
  1     20480           262144          06478912-01     0c
  2     282624          14987264        06478912-02     83

注:这里显示emmc存储芯片有两个分区。

5.6 mmc read命令,用于读到mmc设备的数据,命令格式如下:

mmc read addr blk# cnt

addr 是数据读取到 DRAM 中的地址, blk 是要读取的块起始地址(十六进制),一个块是 512字节,这里的块和扇区是一个意思,在 MMC 设备中我们通常说扇区, cnt 是要读取的块数量(十六进制)。比如从 EMMC 的第 1536(0x600)个块开始,读取 16(0x10)个块的数据到 DRAM 的0x80800000 地址处,命令如下:

=> mmc dev 1 0
switch to partitions #0, OK
mmc1(part 0) is current device
=> mmc read 80800000 600 10
MMC read: dev # 1, block # 1536, count 16 ... 16 blocks read: OK

这里切换到emmc的第0个分区,并读取第0x600个起始块的0x10个块的内容到0x80800000地址处。

=> md.b 80800000 2000
80800000: 08 45 0d 8b 62 61 75 64 72 61 74 65 3d 31 31 35    .E..baudrate=115
80800010: 32 30 30 00 62 6f 61 72 64 5f 6e 61 6d 65 3d 45    200.board_name=E
80800020: 56 4b 00 62 6f 61 72 64 5f 72 65 76 3d 31 34 58    VK.board_rev=14X
80800030: 31 34 00 62 6f 6f 74 5f 66 64 74 3d 74 72 79 00    14.boot_fdt=try.
80800040: 62 6f 6f 74 63 6d 64 3d 72 75 6e 20 66 69 6e 64    bootcmd=run find
80800050: 66 64 74 3b 6d 6d 63 20 64 65 76 20 24 7b 6d 6d    fdt;mmc dev ${mm
80800060: 63 64 65 76 7d 3b 6d 6d 63 20 64 65 76 20 24 7b    cdev};mmc dev ${
80800070: 6d 6d 63 64 65 76 7d 3b 20 69 66 20 6d 6d 63 20    mmcdev}; if mmc 
80800080: 72 65 73 63 61 6e 3b 20 74 68 65 6e 20 69 66 20    rescan; then if 
80800090: 72 75 6e 20 6c 6f 61 64 62 6f 6f 74 73 63 72 69    run loadbootscri
808000a0: 70 74 3b 20 74 68 65 6e 20 72 75 6e 20 62 6f 6f    pt; then run boo
808000b0: 74 73 63 72 69 70 74 3b 20 65 6c 73 65 20 69 66    tscript; else if
808000c0: 20 72 75 6e 20 6c 6f 61 64 69 6d 61 67 65 3b 20     run loadimage; 
808000d0: 74 68 65 6e 20 72 75 6e 20 6d 6d 63 62 6f 6f 74    then run mmcboot
808000e0: 3b 20 65 6c 73 65 20 72 75 6e 20 6e 65 74 62 6f    ; else run netbo
808000f0: 6f 74 3b 20 66 69 3b 20 66 69 3b 20 65 6c 73 65    ot; fi; fi; else
80800100: 20 72 75 6e 20 6e 65 74 62 6f 6f 74 3b 20 66 69     run netboot; fi
80800110: 00 62 6f 6f 74 63 6d 64 5f 6d 66 67 3d 72 75 6e    .bootcmd_mfg=run
80800120: 20 6d 66 67 74 6f 6f 6c 5f 61 72 67 73 3b 62 6f     mfgtool_args;bo
80800130: 6f 74 7a 20 24 7b 6c 6f 61 64 61 64 64 72 7d 20    otz ${loadaddr} 
80800140: 24 7b 69 6e 69 74 72 64 5f 61 64 64 72 7d 20 24    ${initrd_addr} $
80800150: 7b 66 64 74 5f 61 64 64 72 7d 3b 00 62 6f 6f 74    {fdt_addr};.boot
80800160: 64 65 6c 61 79 3d 33 00 62 6f 6f 74 73 63 72 69    delay=3.bootscri
80800170: 70 74 3d 65 63 68 6f 20 52 75 6e 6e 69 6e 67 20    pt=echo Running 
80800180: 62 6f 6f 74 73 63 72 69 70 74 20 66 72 6f 6d 20    bootscript from 
80800190: 6d 6d 63 20 2e 2e 2e 3b 20 73 6f 75 72 63 65 00    mmc ...; source.
808001a0: 63 6f 6e 73 6f 6c 65 3d 74 74 79 6d 78 63 30 00    console=ttymxc0.
808001b0: 65 74 68 61 63 74 3d 46 45 43 31 00 65 74 68 61    ethact=FEC1.etha
808001c0: 64 64 72 3d 30 30 3a 30 34 3a 33 35 3a 35 36 3a    ddr=00:04:35:56:
808001d0: 39 46 3a 33 33 00 65 74 68 70 72 69 6d 65 3d 46    9F:33.ethprime=F
808001e0: 45 43 00 66 64 74 5f 61 64 64 72 3d 30 78 38 33    EC.fdt_addr=0x83
808001f0: 30 30 30 30 30 30 00 66 64 74 5f 66 69 6c 65 3d    000000.fdt_file=
80800200: 69 6d 78 36 75 6c 6c 2d 31 34 78 31 34 2d 65 6d    imx6ull-14x14-em
80800210: 6d 63 2d 37 2d 31 30 32 34 78 36 30 30 2d 63 2e    mc-7-1024x600-c.
80800220: 64 74 62 00 66 64 74 5f 68 69 67 68 3d 30 78 66    dtb.fdt_high=0xf
80800230: 66 66 66 66 66 66 66 00 66 69 6e 64 66 64 74 3d    fffffff.findfdt=
80800240: 69 66 20 74 65 73 74 20 24 66 64 74 5f 66 69 6c    if test $fdt_fil
80800250: 65 20 3d 20 75 6e 64 65 66 69 6e 65 64 3b 20 74    e = undefined; t
80800260: 68 65 6e 20 69 66 20 74 65 73 74 20 24 62 6f 61    hen if test $boa
80800270: 72 64 5f 6e 61 6d 65 20 3d 20 45 56 4b 20 26 26    rd_name = EVK &&
80800280: 20 74 65 73 74 20 24 62 6f 61 72 64 5f 72 65 76     test $board_rev
80800290: 20 3d 20 39 58 39 3b 20 74 68 65 6e 20 73 65 74     = 9X9; then set
808002a0: 65 6e 76 20 66 64 74 5f 66 69 6c 65 20 69 6d 78    env fdt_file imx
808002b0: 36 75 6c 6c 2d 39 78 39 2d 65 76 6b 2e 64 74 62    6ull-9x9-evk.dtb
808002c0: 3b 20 66 69 3b 20 69 66 20 74 65 73 74 20 24 62    ; fi; if test $b
808002d0: 6f 61 72 64 5f 6e 61 6d 65 20 3d 20 45 56 4b 20    oard_name = EVK 
808002e0: 26 26 20 74 65 73 74 20 24 62 6f 61 72 64 5f 72    && test $board_r
808002f0: 65 76 20 3d 20 31 34 58 31 34 3b 20 74 68 65 6e    ev = 14X14; then
80800300: 20 73 65 74 65 6e 76 20 66 64 74 5f 66 69 6c 65     setenv fdt_file
80800310: 20 69 6d 78 36 75 6c 6c 2d 31 34 78 31 34 2d 65     imx6ull-14x14-e
80800320: 76 6b 2e 64 74 62 3b 20 66 69 3b 20 69 66 20 74    vk.dtb; fi; if t
80800330: 65 73 74 20 24 66 64 74 5f 66 69 6c 65 20 3d 20    est $fdt_file = 
80800340: 75 6e 64 65 66 69 6e 65 64 3b 20 74 68 65 6e 20    undefined; then 
80800350: 65 63 68 6f 20 57 41 52 4e 49 4e 47 3a 20 43 6f    echo WARNING: Co
80800360: 75 6c 64 20 6e 6f 74 20 64 65 74 65 72 6d 69 6e    uld not determin
80800370: 65 20 64 74 62 20 74 6f 20 75 73 65 3b 20 66 69    e dtb to use; fi
80800380: 3b 20 66 69 3b 00 67 61 74 65 77 61 79 69 70 3d    ; fi;.gatewayip=
80800390: 31 39 32 2e 31 36 38 2e 31 2e 31 00 69 6d 61 67    192.168.1.1.imag
808003a0: 65 3d 7a 49 6d 61 67 65 00 69 6e 69 74 72 64 5f    e=zImage.initrd_
808003b0: 61 64 64 72 3d 30 78 38 33 38 30 30 30 30 30 00    addr=0x83800000.
808003c0: 69 6e 69 74 72 64 5f 68 69 67 68 3d 30 78 66 66    initrd_high=0xff
808003d0: 66 66 66 66 66 66 00 69 70 5f 64 79 6e 3d 79 65    ffffff.ip_dyn=ye
808003e0: 73 00 69 70 61 64 64 72 3d 31 39 32 2e 31 36 38    s.ipaddr=192.168
808003f0: 2e 31 2e 35 36 00 6c 6f 61 64 61 64 64 72 3d 30    .1.56.loadaddr=0
80800400: 78 38 30 38 30 30 30 30 30 00 6c 6f 61 64 62 6f    x80800000.loadbo
80800410: 6f 74 73 63 72 69 70 74 3d 66 61 74 6c 6f 61 64    otscript=fatload
80800420: 20 6d 6d 63 20 24 7b 6d 6d 63 64 65 76 7d 3a 24     mmc ${mmcdev}:$
80800430: 7b 6d 6d 63 70 61 72 74 7d 20 24 7b 6c 6f 61 64    {mmcpart} ${load
80800440: 61 64 64 72 7d 20 24 7b 73 63 72 69 70 74 7d 3b    addr} ${script};
80800450: 00 6c 6f 61 64 66 64 74 3d 66 61 74 6c 6f 61 64    .loadfdt=fatload
80800460: 20 6d 6d 63 20 24 7b 6d 6d 63 64 65 76 7d 3a 24     mmc ${mmcdev}:$
80800470: 7b 6d 6d 63 70 61 72 74 7d 20 24 7b 66 64 74 5f    {mmcpart} ${fdt_
80800480: 61 64 64 72 7d 20 24 7b 66 64 74 5f 66 69 6c 65    addr} ${fdt_file
80800490: 7d 00 6c 6f 61 64 69 6d 61 67 65 3d 66 61 74 6c    }.loadimage=fatl
808004a0: 6f 61 64 20 6d 6d 63 20 24 7b 6d 6d 63 64 65 76    oad mmc ${mmcdev
808004b0: 7d 3a 24 7b 6d 6d 63 70 61 72 74 7d 20 24 7b 6c    }:${mmcpart} ${l
808004c0: 6f 61 64 61 64 64 72 7d 20 24 7b 69 6d 61 67 65    oadaddr} ${image
808004d0: 7d 00 6c 6f 67 6f 5f 66 69 6c 65 3d 61 6c 69 65    }.logo_file=alie
808004e0: 6e 74 65 6b 2e 62 6d 70 00 6d 66 67 74 6f 6f 6c    ntek.bmp.mfgtool
808004f0: 5f 61 72 67 73 3d 73 65 74 65 6e 76 20 62 6f 6f    _args=setenv boo
80800500: 74 61 72 67 73 20 63 6f 6e 73 6f 6c 65 3d 24 7b    targs console=${
80800510: 63 6f 6e 73 6f 6c 65 7d 2c 24 7b 62 61 75 64 72    console},${baudr
80800520: 61 74 65 7d 20 72 64 69 6e 69 74 3d 2f 6c 69 6e    ate} rdinit=/lin
80800530: 75 78 72 63 20 67 5f 6d 61 73 73 5f 73 74 6f 72    uxrc g_mass_stor
80800540: 61 67 65 2e 73 74 61 6c 6c 3d 30 20 67 5f 6d 61    age.stall=0 g_ma
80800550: 73 73 5f 73 74 6f 72 61 67 65 2e 72 65 6d 6f 76    ss_storage.remov
80800560: 61 62 6c 65 3d 31 20 67 5f 6d 61 73 73 5f 73 74    able=1 g_mass_st
80800570: 6f 72 61 67 65 2e 66 69 6c 65 3d 2f 66 61 74 20    orage.file=/fat 
80800580: 67 5f 6d 61 73 73 5f 73 74 6f 72 61 67 65 2e 72    g_mass_storage.r
80800590: 6f 3d 31 20 67 5f 6d 61 73 73 5f 73 74 6f 72 61    o=1 g_mass_stora
808005a0: 67 65 2e 69 64 56 65 6e 64 6f 72 3d 30 78 30 36    ge.idVendor=0x06
808005b0: 36 46 20 67 5f 6d 61 73 73 5f 73 74 6f 72 61 67    6F g_mass_storag
808005c0: 65 2e 69 64 50 72 6f 64 75 63 74 3d 30 78 33 37    e.idProduct=0x37
808005d0: 46 46 20 67 5f 6d 61 73 73 5f 73 74 6f 72 61 67    FF g_mass_storag
808005e0: 65 2e 69 53 65 72 69 61 6c 4e 75 6d 62 65 72 3d    e.iSerialNumber=
808005f0: 22 22 20 63 6c 6b 5f 69 67 6e 6f 72 65 5f 75 6e    "" clk_ignore_un
80800600: 75 73 65 64 20 00 6d 6d 63 61 72 67 73 3d 73 65    used .mmcargs=se
80800610: 74 65 6e 76 20 62 6f 6f 74 61 72 67 73 20 63 6f    tenv bootargs co
80800620: 6e 73 6f 6c 65 3d 24 7b 63 6f 6e 73 6f 6c 65 7d    nsole=${console}
80800630: 2c 24 7b 62 61 75 64 72 61 74 65 7d 20 72 6f 6f    ,${baudrate} roo
80800640: 74 3d 24 7b 6d 6d 63 72 6f 6f 74 7d 00 6d 6d 63    t=${mmcroot}.mmc
80800650: 61 75 74 6f 64 65 74 65 63 74 3d 79 65 73 00 6d    autodetect=yes.m
80800660: 6d 63 62 6f 6f 74 3d 65 63 68 6f 20 42 6f 6f 74    mcboot=echo Boot
80800670: 69 6e 67 20 66 72 6f 6d 20 6d 6d 63 20 2e 2e 2e    ing from mmc ...
80800680: 3b 20 72 75 6e 20 6d 6d 63 61 72 67 73 3b 20 69    ; run mmcargs; i
80800690: 66 20 74 65 73 74 20 24 7b 62 6f 6f 74 5f 66 64    f test ${boot_fd
808006a0: 74 7d 20 3d 20 79 65 73 20 7c 7c 20 74 65 73 74    t} = yes || test
808006b0: 20 24 7b 62 6f 6f 74 5f 66 64 74 7d 20 3d 20 74     ${boot_fdt} = t
808006c0: 72 79 3b 20 74 68 65 6e 20 69 66 20 72 75 6e 20    ry; then if run 
808006d0: 6c 6f 61 64 66 64 74 3b 20 74 68 65 6e 20 62 6f    loadfdt; then bo
808006e0: 6f 74 7a 20 24 7b 6c 6f 61 64 61 64 64 72 7d 20    otz ${loadaddr} 
808006f0: 2d 20 24 7b 66 64 74 5f 61 64 64 72 7d 3b 20 65    - ${fdt_addr}; e
80800700: 6c 73 65 20 69 66 20 74 65 73 74 20 24 7b 62 6f    lse if test ${bo
80800710: 6f 74 5f 66 64 74 7d 20 3d 20 74 72 79 3b 20 74    ot_fdt} = try; t
80800720: 68 65 6e 20 62 6f 6f 74 7a 3b 20 65 6c 73 65 20    hen bootz; else 
80800730: 65 63 68 6f 20 57 41 52 4e 3a 20 43 61 6e 6e 6f    echo WARN: Canno
80800740: 74 20 6c 6f 61 64 20 74 68 65 20 44 54 3b 20 66    t load the DT; f
80800750: 69 3b 20 66 69 3b 20 65 6c 73 65 20 62 6f 6f 74    i; fi; else boot
80800760: 7a 3b 20 66 69 3b 00 6d 6d 63 64 65 76 3d 31 00    z; fi;.mmcdev=1.
80800770: 6d 6d 63 70 61 72 74 3d 31 00 6d 6d 63 72 6f 6f    mmcpart=1.mmcroo
80800780: 74 3d 2f 64 65 76 2f 6d 6d 63 62 6c 6b 31 70 32    t=/dev/mmcblk1p2
80800790: 20 72 6f 6f 74 77 61 69 74 20 72 77 00 6e 65 74     rootwait rw.net
808007a0: 61 72 67 73 3d 73 65 74 65 6e 76 20 62 6f 6f 74    args=setenv boot
808007b0: 61 72 67 73 20 63 6f 6e 73 6f 6c 65 3d 24 7b 63    args console=${c
808007c0: 6f 6e 73 6f 6c 65 7d 2c 24 7b 62 61 75 64 72 61    onsole},${baudra
808007d0: 74 65 7d 20 72 6f 6f 74 3d 2f 64 65 76 2f 6e 66    te} root=/dev/nf
808007e0: 73 20 69 70 3d 64 68 63 70 20 6e 66 73 72 6f 6f    s ip=dhcp nfsroo
808007f0: 74 3d 24 7b 73 65 72 76 65 72 69 70 7d 3a 24 7b    t=${serverip}:${
80800800: 6e 66 73 72 6f 6f 74 7d 2c 76 33 2c 74 63 70 00    nfsroot},v3,tcp.
80800810: 6e 65 74 62 6f 6f 74 3d 65 63 68 6f 20 42 6f 6f    netboot=echo Boo
80800820: 74 69 6e 67 20 66 72 6f 6d 20 6e 65 74 20 2e 2e    ting from net ..
80800830: 2e 3b 20 72 75 6e 20 6e 65 74 61 72 67 73 3b 20    .; run netargs; 
80800840: 69 66 20 74 65 73 74 20 24 7b 69 70 5f 64 79 6e    if test ${ip_dyn
80800850: 7d 20 3d 20 79 65 73 3b 20 74 68 65 6e 20 73 65    } = yes; then se
80800860: 74 65 6e 76 20 67 65 74 5f 63 6d 64 20 64 68 63    tenv get_cmd dhc
80800870: 70 3b 20 65 6c 73 65 20 73 65 74 65 6e 76 20 67    p; else setenv g
80800880: 65 74 5f 63 6d 64 20 74 66 74 70 3b 20 66 69 3b    et_cmd tftp; fi;
80800890: 20 24 7b 67 65 74 5f 63 6d 64 7d 20 24 7b 69 6d     ${get_cmd} ${im
808008a0: 61 67 65 7d 3b 20 69 66 20 74 65 73 74 20 24 7b    age}; if test ${
808008b0: 62 6f 6f 74 5f 66 64 74 7d 20 3d 20 79 65 73 20    boot_fdt} = yes 
808008c0: 7c 7c 20 74 65 73 74 20 24 7b 62 6f 6f 74 5f 66    || test ${boot_f
808008d0: 64 74 7d 20 3d 20 74 72 79 3b 20 74 68 65 6e 20    dt} = try; then 
808008e0: 69 66 20 24 7b 67 65 74 5f 63 6d 64 7d 20 24 7b    if ${get_cmd} ${
808008f0: 66 64 74 5f 61 64 64 72 7d 20 24 7b 66 64 74 5f    fdt_addr} ${fdt_
80800900: 66 69 6c 65 7d 3b 20 74 68 65 6e 20 62 6f 6f 74    file}; then boot
80800910: 7a 20 24 7b 6c 6f 61 64 61 64 64 72 7d 20 2d 20    z ${loadaddr} - 
80800920: 24 7b 66 64 74 5f 61 64 64 72 7d 3b 20 65 6c 73    ${fdt_addr}; els
80800930: 65 20 69 66 20 74 65 73 74 20 24 7b 62 6f 6f 74    e if test ${boot
80800940: 5f 66 64 74 7d 20 3d 20 74 72 79 3b 20 74 68 65    _fdt} = try; the
80800950: 6e 20 62 6f 6f 74 7a 3b 20 65 6c 73 65 20 65 63    n bootz; else ec
80800960: 68 6f 20 57 41 52 4e 3a 20 43 61 6e 6e 6f 74 20    ho WARN: Cannot 
80800970: 6c 6f 61 64 20 74 68 65 20 44 54 3b 20 66 69 3b    load the DT; fi;
80800980: 20 66 69 3b 20 65 6c 73 65 20 62 6f 6f 74 7a 3b     fi; else bootz;
80800990: 20 66 69 3b 00 6e 65 74 6d 61 73 6b 3d 32 35 35     fi;.netmask=255
808009a0: 2e 32 35 35 2e 32 35 35 2e 30 00 70 61 6e 65 6c    .255.255.0.panel
808009b0: 3d 41 54 4b 2d 4c 43 44 2d 37 2d 31 30 32 34 78    =ATK-LCD-7-1024x
808009c0: 36 30 30 00 73 63 72 69 70 74 3d 62 6f 6f 74 2e    600.script=boot.
808009d0: 73 63 72 00 73 65 72 76 65 72 69 70 3d 31 39 32    scr.serverip=192
808009e0: 2e 31 36 38 2e 31 2e 35 35 00 73 70 6c 61 73 68    .168.1.55.splash
808009f0: 69 6d 61 67 65 3d 30 78 38 38 30 30 30 30 30 30    image=0x88000000
80800a00: 00 73 70 6c 61 73 68 70 6f 73 3d 6d 2c 6d 00 00    .splashpos=m,m..
80800a10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
......

这里显示出读取的内容,可以看出,这就是uboot的环境变量信息。
5.7 mmc write命令,将数据写到MMC设备里面。命令格式如下:

mmc write addr blk# cnt

addr 是要写入 MMC 中的数据在 DRAM 中的起始地址, blk 是要写入 MMC 的块起始地址(十六进制), cnt 是要写入的块大小,一个块为 512 字节。我们可以使用命令“mmc write”来升级 uboot,也就是在 uboot 中更新 uboot。这里要用到 nfs 或者 tftp 命令,通过 nfs 或者 tftp 命令将新的 u-boot.bin 下载到开发板的 DRAM 中,然后再使用命令“mmc write”将其写入到 MMC设备中。

=> mmc dev 0
switch to partitions #0, OK
mmc0 is current device

切换到SD卡,查看版本号

=> version

U-Boot 2016.03-g9bd38ef (Oct 23 2019 - 09:31:47 +0800)
arm-poky-linux-gnueabi-gcc (GCC) 5.3.0
GNU ld (GNU Binutils) 2.26.0.20160214

加载重新编译的u-boot文件,

=> tftp 80800000 u-boot.imx
Using FEC1 device
TFTP from server 192.168.1.55; our IP address is 192.168.1.56
Filename 'u-boot.imx'.
Load address: 0x80800000
Loading: #############################
         1.7 MiB/s
done
Bytes transferred = 424960 (67c00 hex)

切换到SD卡的0分区,并将第2个起始块开始的33E(424960 /512=830=0x33E, 424960为新编译的u-boot.imx文件的大小)个块写入到SD当中。

=> mmc dev 0 0
switch to partitions #0, OK
mmc0 is current device
=> mmc write 80800000 2 33E

MMC write: dev # 0, block # 2, count 814 ... 814 blocks written: OK

将目标板设置为SD卡启动,重新启动,显示的启动信息为当前编译日期。

=> 

U-Boot 2016.03 (Dec 15 2019 - 23:45:46 +0800)

CPU:   Freescale i.MX6ULL rev1.1 69 MHz (running at 396 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 59C
Reset cause: POR
Board: MX6ULL 14x14 EVK
I2C:   ready
DRAM:  512 MiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Display: ATK-LCD-7-1024x600 (1024x600)
Video: 1024x600x24
reading alientek.bmp
** Unable to read file alientek.bmp **
Error: no valid bmp image at 88000000
In:    serial
Out:   serial
Err:   serial
switch to partitions #0, OK
mmc1(part 0) is current device
Net:   FEC1
Normal Boot
Hit any key to stop autoboot:  0 
  1. FAT格式文件系统操作命令
    6.1 fatinfo命令,用于输出指定介质分区的文件系统相关信息。命令格式如下:
=> ? fatinfo
fatinfo - print information about filesystem

Usage:
fatinfo  []
    - print information about filesystem from 'dev' on 'interface'

以下是我的目标板两个MMC介质的分区信息

=> fatinfo mmc 1:1
Interface:  MMC
  Device 1: Vendor: Man 000015 Snr f565de41 Rev: 0.6 Prod: 8GTF4R
            Type: Removable Hard Disk
            Capacity: 7456.0 MB = 7.2 GB (15269888 x 512)
Filesystem: FAT32 "NO NAME    "
=> fatinfo mmc 0:1
Interface:  MMC
  Device 0: Vendor: Man 000003 Snr 511f1b01 Rev: 6.9 Prod: SC16G           Type: Removable Hard Disk
            Capacity: 15193.5 MB = 14.8 GB (31116288 x 512)
Filesystem: FAT32 "NO NAME    "

6.2 fatls命令,用于查询 FAT文件系统设备介质根目录和文件信息,命令格式如下:

=> ? fatls
fatls - list files in a directory (default /)

Usage:
fatls  [] [directory]
    - list files from 'dev' on 'interface' in a 'directory'

这里显示我的目标板第1个MMC设备(eMMC存储芯片)的第1个分区的信息

=> fatls mmc 1:1 
  6777096   zimage 
    38270   imx6ull-14x14-emmc-4.3-480x272-c.dtb 
    38270   imx6ull-14x14-emmc-4.3-800x480-c.dtb 
    38270   imx6ull-14x14-emmc-7-800x480-c.dtb 
    38270   imx6ull-14x14-emmc-7-1024x600-c.dtb 
    38270   imx6ull-14x14-emmc-10.1-1280x800-c.dtb 

6 file(s), 0 dir(s)

6.3 fstype命令,查看存储介质某个分区的文件系统,命令格式如下:

=> ? fstype
fstype - Look up a filesystem type

Usage:
fstype  :
- print filesystem type
fstype  : 
- set environment variable to filesystem type

这里显示目标板的几个分区的文件系统格式

=> fstype mmc 1:0
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
=> fstype mmc 1:1
fat
=> fstype mmc 1:2
ext4
=> fstype mmc 0:0
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
=> fstype mmc 0:1
fat
=> fstype mmc 0:2
** Invalid partition 2 **

6.4 fatload命令,用于将指定的文件读取RAM中,命令格式如下:

=> ? fatload
fatload - load binary file from a dos filesystem

Usage:
fatload  [ [ [ [bytes [pos]]]]]
    - Load binary file 'filename' from 'dev' on 'interface'
      to address 'addr' from dos filesystem.
      'pos' gives the file position to start loading from.
      If 'pos' is omitted, 0 is used. 'pos' requires 'bytes'.
      'bytes' gives the size to load. If 'bytes' is 0 or omitted,
      the load stops on end of file.
      If either 'pos' or 'bytes' are not aligned to
      ARCH_DMA_MINALIGN then a misaligned buffer warning will
      be printed and performance will suffer for the load.

这里把第1个MMC设备的第1个分区的zImage文件读取到0x80800000地址

=> fatload mmc 1:1 80800000 zImage
reading zImage
6777096 bytes read in 221 ms (29.2 MiB/s)

6.5 fatwrite命令,用于将DRAM中的数据定入到存储介质中。命令格式在我手头的目标板上未查到,以下不作演示了。

=> ? fatwrite
Unknown command 'fatwrite' - try 'help' without arguments for list of all known commands
  1. EXT格式文件系统操作命令
    uboot有ext2load、 ext2ls、 ext4load、 ext4ls 和 ext4write命令,与fat命令类似,此处不再演示。

  2. boot操作命令
    8.1 bootz命令,用于启动linux系统镜像文件,其命令格式如下:

=> ? bootz
bootz - boot Linux zImage image from memory

Usage:
bootz [addr [initrd[:size]] [fdt]]
    - boot Linux zImage stored in memory
        The argument 'initrd' is optional and specifies the address
        of the initrd in memory. The optional argument ':size' allows
        specifying the size of RAW initrd.
        When booting a Linux kernel which requires a flat device-tree
        a third argument is required which is the address of the
        device-tree blob. To boot that kernel without an initrd image,
        use a '-' for the second argument. If you do not pass a third
        a bd_info struct will be passed instead

如从RAM(需先把linux系统镜像和设备树加载到RAM中去)启动内核

=> bootz 80800000 - 83000000
Kernel image @ 0x80800000 [ 0x000000 - 0x676908 ]
## Flattened Device Tree blob at 83000000
   Booting using the fdt blob at 0x83000000
   Using Device Tree in place at 83000000, end 8300c57d

Starting kernel ...

8.2 bootm命令,bootm 和 bootz 功能类似,但是 bootm 用于启动 uImage 镜像文件。

=> ? bootm
bootm - boot application image from memory

Usage:
bootm [addr [arg ...]]
    - boot application image stored in memory
        passing arguments 'arg ...'; when booting a Linux kernel,
        'arg' can be the address of an initrd image
        When booting a Linux kernel which requires a flat device-tree
        a third argument is required which is the address of the
        device-tree blob. To boot that kernel without an initrd image,
        use a '-' for the second argument. If you do not pass a third
        a bd_info struct will be passed instead

Sub-commands to do part of the bootm sequence.  The sub-commands must be
issued in the order below (it's ok to not issue all sub-commands):
        start [addr [arg ...]]
        loados  - load OS image
        ramdisk - relocate initrd, set env initrd_start/initrd_end
        fdt     - relocate flat device tree
        cmdline - OS specific command line processing/setup
        bdt     - OS specific bd_t processing
        prep    - OS specific prep before relocation or go
        go      - start OS

8.3 boot命令,boot 命令也是用来启动 Linux 系统的,只是 boot 会读取环境变量 bootcmd 来启动 Linux 系统, bootcmd 是一个很重要的环境变量!

=> ? boot
boot - boot default, i.e., run 'bootcmd'

Usage:
boot 

你可能感兴趣的:(Linux)