Summary of uboot commonly used commands

table of Contents

Preface

1. Information query commands (bdinfo, printenv, versionn)

2. Environment variable operation commands (setenv, saveenv)

3. Memory operation instructions (md, nm, mm, mw, cp, cmp)

4. Network operation commands (ping, dhcp, nfs, tftp)

5. EMMC and SD card operation commands

6. FAT format file system operation commands (fatinfo, fatls, fstype, fatload, fatwrite)

7. EXT format file system operation commands

8. NAND operation command

9. BOOT operation command

10. Some other commonly used commands (reset, go, run)

Reference


Preface

The following content is a summary of the memos in the chapters of learning the Punctual Atom Alpha Development Board (I.MAX6ULL Linux Development Board) U-BOOT.

1. Information query commands (bdinfo, printenv, versionn)

bdinfo

printenv

version

2. Environment variable operation commands (setenv, saveenv)

setenv is used to set and modify the value of environment variables ; setenv is used to delete the environment when the set content is empty; saveenv is used to save the modified environment variables ; general environment variables are stored in the external flash, which will be used when uboot starts Read environment variables from flash to DRAM. So use the command setenv to modify the value of the environment variables in DRAM. After the modification, you must use the saveenv command to save the modified environment variables to the flash. Otherwise, the next restart of uboot will continue to use the previous environment variable values.

3. Memory operation instructions (md, nm, mm, mw, cp, cmp)

1. .b.w.l means to display in byte, word and long respectively

2, address is the starting address of the memory to be viewed

3. The unit of data length is not bytes, but is related to the display format you choose. For example, if you set the memory length to be viewed as 20 (hexadecimal 0x14), if the display format is .b, it means 20 bytes; if the display format is .w, it means 20 words, which is 20 *2=40 bytes; if the display format is .l, it means 20 longs, that is, 20*4=80 bytes.

4. The numbers in uboot command are all hexadecimal! Not decimal!

(1) Display memory value: md[.b, .w, .l] address [# of objects]

(2) Modify the memory value of the specified address, the address will not increase after modification: nm [.b, .w, .l] address

(3) Modify the memory value of the specified address, the address will increase after modification: mm [.b, .w, .l] address

(4) Fill the memory with the specified data: mw [.b, .w, .l] address value [count]

(5) Data copy: cp [.b, .w, .l] source target count

Copy the data in DRAM from one memory to another, or copy the data in Nor Flash to DRAM

(6) Data comparison: cmp [.b, .w, .l] addr1 addr2 count

4. Network operation commands (ping, dhcp, nfs, tftp)

Before using network operation commands, set up environment variables

Environment variable

description

ipaddr

The ip address of the development board can be left unset. Use the dhcp command to obtain the IP address from the router.

ethaddr

The MAC address of the development board must be set.

gatewayip

Gateway address.

netmask

Subnet mask.

serverip

The server IP address, which is the IP address of the Ubuntu host, is used for debugging code.

(1) View the network connection status: ping

(2) Obtain IP address automatically: dhcp

(3) Download the file from the ubuntu host: nfs [loadAddress] [[hostIPaddr:]bootfilename]

loadAddress is the DRAM address to be saved, [[hostIPaddr:]bootfilename] is the file address to be downloaded

nfs (Network File System) network file system, through nfs can share resources between computers through the network, for example, we put the linux image and device tree file in Ubuntu, and then use the nfs command in uboot to mirror the linux in Ubuntu And the device tree is downloaded to the DRAM of the development board . The purpose of this is to facilitate debugging of the Linux mirror and device tree, that is, network debugging. Network debugging is the most commonly used debugging method in Linux development. The reason is that the development of embedded linux is not like the development of a single-chip microcomputer. The code can be directly programmed into the internal flash of the single-chip microcomputer through emulators such as JLINK or STLink. Embedded Linux is usually programmed to external devices such as EMMC, NAND Flash, SPI Flash, etc. In flash, there is no IDE such as MDK IAR for embedded Linux development, and there is no programming algorithm, so it is impossible to flash the firmware to the external flash by clicking a download button. Although semiconductor manufacturers generally provide a programming Firmware software, but this software is more complicated to use. This programming software is generally used for mass production.

(4) Download the file from the ubuntu host: tftp [loadAddress] [[hostIPaddr:]bootfilename]

loadAddress is the DRAM address to be saved, [[hostIPaddr:]bootfilename] is the address of the file to be downloaded (you don’t need to specify the full name when using TFTP, provided that the tftpd service is enabled on the ubuntu host and the file is placed on the tftp server Folder)

5. EMMC and SD card operation commands

(1) Switch the current mmc device: mmc dev [dev] [part]

[dev]: Used to set the device number of the MMC device to be switched (0 is the SD card, 1 is the eMMC),

[part]: is the partition number. If you do not write the partition number, the default is partition 0.

使用如下命令切换到 SD卡:
mmc dev 0 //切换到 SD卡, 0为 SD卡, 1为 eMMC

(2) View partition: mmc part

比如查看 EMMC的分区情况,输入如下命令: 
mmc dev 1 //切换到 EMMC 
mmc part //查看 EMMC分区

As can be seen in the figure, EMMC has two partitions at this time, sectors 20480~1024000 are the first partition, and sectors 1228800~6504448 are the second partition. If the Linux system is burned in EMMC, EMMC has 3 partitions. The 0th partition stores uboot, the 1st partition stores Linux image files and device trees, and the second partition stores the root file system . However, there are only two partitions in the figure. That is because the 0th partition is not formatted, so it cannot be recognized. In fact, the 0th partition exists.

(3) Read instruction: mmc read addr blk# cnt

addr: is the address where data is read into DRAM

blk: is the starting address of the block to be read (hexadecimal), a block (sector) is 512 bytes, in MMC equipment we usually say sector

cnt: is the number of blocks to be read (hexadecimal)

比如从 EMMC的第 1536(0x600)个块开始,读取 16(0x10)个块的数据到 DRAM的0X80800000地址处,命令如下: 
mmc dev 1 0 //切换到 MMC分区 0 
mmc read 80800000 600 10 //读取数据

(4) Write instruction: mmc write addr blk# cnt

addr is the starting address in DRAM of the data to be written to MMC

blk is the starting address of the block to be written to the MMC (hexadecimal

cnt is the size of the block to be written, one block is 512 bytes

You can use the command "mmc write" to upgrade uboot, that is, update uboot in uboot . Here you need to use the nfs or tftp command. Use the nfs or tftp command to download the new u-boot.bin to the DRAM of the development board, and then use the command "mmc write" to write it to the MMC device.

比如更新EMMC中的uboot: 
mmc dev 1 0 //切换到 EMMC分区 0 
tftp 80800000 u-boot.imx //下载 u-boot.imx到 DRAM 
mmc write 80800000 2 32E //烧写 u-boot.imx到 EMMC中 
mmc partconf 1 1 0 0 //分区配置, EMMC需要这一步!

6. FAT format file system operation commands (fatinfo, fatls, fstype, fatload, fatwrite)

(1) Query the file system information of the specified partition: fatinfo <interface> [<dev[:part]>]

interface: indicates the interface, such as mmc

dev: is the device number to be queried, 0 is SD card, 1 is EMMC

part: is the partition to be queried 

(2) Query the directory and file information of FAT format devices: fatls <interface> [<dev[:part]>] [directory]

interface: indicates the interface, such as mmc

dev: is the device number to be queried, 0 is SD card, 1 is EMMC

part: is the partition to be queried

directory: is the directory to be queried 

(3) Query the file system format of a partition of the MMC device: fstype <interface> <dev>:<part>

interface: indicates the interface, such as mmc

dev: is the device number to be queried, 0 is SD card, 1 is EMMC

part: is the partition to be queried

fstype mmc 1:0 //查看EMMC分区0的文件系统格式 
fstype mmc 1:1 //查看EMMC分区1的文件系统格式 
fstype mmc 1:2 //查看EMMC分区2的文件系统格式

(4) Read the specified file into DRAM: fatload <interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]]

interface: indicates the interface, such as mmc

dev: is the device number to be queried, 0 is SD card, 1 is EMMC

part: is the partition to be queried

addr: starting address stored in DRAM

filename: The name of the file to be read

bytes: indicates how many bytes of data to be read, 0 or omitted means to read the entire file

pos: the offset of the data to be read relative to the first address of the file, 0 or omitted means to start reading from the first address of the file

fatload mmc 1:1 80800000 zImage //将EMMC分区1中的zImage文件读取到DRAM中的80800000地址处

(5) Write the data in DRAM to the MMC device:

fatwrite <interface> <dev[:part]> <addr> <filename> <bytes>

interface: indicates the interface, such as mmc

dev: is the device number to be queried, 0 is SD card, 1 is EMMC

part: is the partition to be queried

addr: the starting address of the data to be written in DRAM

filename: the name of the file to be written

bytes: indicates how many bytes of data to be written, 0 or omitted means to write the entire file

7. EXT format file system operation commands

There are four commonly used commands for file system operation of these two formats, namely: ext2load, ext2ls, ext4load, ext4ls, and ext4write . The meaning and usage of these commands are the same as fatload, fatls and fatwrit, except that ext2 and ext4 are for the ext file system.

 

8. NAND operation command

 

9. BOOT operation command

(1) Start Linux: bootz [addr [initrd[:size]] [fdt]]

addr: is the location of the Linux image file in DRAM,

initrd: is the address of the initrd file in DRAM, if initrd is not used, use'-' instead

fdt: is the address of the device tree file in DRAM.

Example: Download zImage and device tree from ubuntu host to DDR via tftp network:

tftp 80800000 zImage 
tftp 83000000 imx6ull-14x14-emmc-4.3-800x480-c.dtb 
bootz 80800000 - 83000000

Example: Copy zImage and device tree from partition 1 of EMMC to DDR through fatload:

fatload mmc 1:1 80800000 zImage 
fatload mmc 1:1 83000000 imx6ull-14x14-emmc-4.3-800x480-c.dtb 
bootz 80800000 - 83000000

(2) Start Linux: boot

The boot command is also used to start Linux; the boot command reads the bootcmd environment variable to start Linux. The bootcmd environment variable stores the boot command, which is the set of boot commands, and the specific boot command content can be modified.

Example: Download zImage and device tree from ubuntu host to DDR via tftp network:

setenv bootcmd ' 
tftp 80800000 zImage; 
tftp 83000000 imx6ull-14x14-emmc-4.3-800x480-c.dtb; 
bootz 80800000 - 83000000;' //设置bootcmd环境变量 
saveenv //保存环境变量 

boot //启动Linux

Example: Copy zImage and device tree from partition 1 of EMMC to DDR through fatload:

setenv bootcmd '
fatload mmc 1:1 80800000 zImage; 
fatload mmc 1:1 83000000 imx6ull-14x14-emmc-4.3-800x480-c.dtb; 
bootz 80800000 - 83000000;' //设置bootcmd环境变量 
saveenv //保存环境变量 

boot //启动Linux

10. Some other commonly used commands (reset, go, run)

(1) Restart: reset

(2) Jump to the specified address to execute the application: go addr [arg ...] ; mostly used for debugging bare metal programs

addr: the first address used in DRAM

(3) Commands defined in running environment variables: run environment variables; mostly used to run custom environment variables

 

Reference

"[Punctual Atom] i.MX6U Embedded Linux Driver Development Guide V1.3"

 

 

 

Guess you like

Origin blog.csdn.net/m0_37845735/article/details/105922501