Introduction to embedded Linux uboot knowledge

uboot is the universal bootloader (universal boot code).

1. The role of uboot

(1) The main function of uboot is to start the operating system kernel;

(2) uboot is also responsible for deploying the entire computer system;

(3) There are also drivers for operating the hard disks on the boards such as flash in uboot ;

(4) uboot must also provide a command line interface for human operation.

 

2. Problems that uboot must solve

(1) It can be started directly by itself

(2) Can boot the operating system kernel to start and pass parameters to the kernel

(3) Ability to provide system deployment functions

(4) Able to manage soc -level and class hardware

 

3. How uboot works

(1) uboot is an open source project, which consists of several .c files and .h files. After configuration and compilation, a uboot.bin will be generated , which is the image file of the bare metal program uboot . Then the image file is properly burned to the boot medium and given to the soc to start. That is to say, uboot is realized as uboot.bin when it is not running, and it usually lies in the boot medium.

(2) When uboot is running, it will be loaded into the memory, and then one instruction will be given to the CPU to run.

 

Fourth, uboot 's imperative shell interface

(1) The bare metal program of the ordinary program is directly executed when it runs, and the execution effect is related to the code.

(2) Some programs need to interact with people, so a shell is implemented in the program (a shell is an interface that provides human-computer interaction), and uboot implements a shell .

(3) The working mode of the shell in uboot is very similar to the terminal shell in Linux , but the command set is different.

 

5. Common commands of uboot

(1) Some commands have simplified aliases, such as the printenv command can be simplified to print , such as setenv can be simplified to set

(2) Special symbols (such as single quotation marks) in commands, some commands of uboot have very long parameters, in order to tell uboot that this very long string with many spaces in the middle is a whole parameter for him, so use single quotation marks Induce this long parameter separated by spaces.

(3) Command printenv/print

The print command does not take parameters, its function is to print out all the environment variables in the system. The environment variable is stored in a special area of ​​Flash (there is an environment variable partition on the Flash ). Once the environment variable is saved in the program, the value of the environment variable will maintain the value after the last change when the program is turned on next time.

(4) Set (add / change) environment variables: setenv/set

Usage: set name value

(5) Save changes to environment variables: saveenv/save

The save command takes no parameters and is executed directly. The function is to synchronously save the value of the environment variable in the memory to the partition of the environment variable in the Flash . Note: The preservation of environment variables is the overall overwrite preservation, that is to say, all the environment variables in the memory will overwrite the original content of the environment variable partition in the Flash as a whole.

Completely change the value of the environment variable: The first step is to use the set command to change the environment variable in memory, and the second step is to use the save command to synchronize it to the partition of the environment variable in Flash .

 

6. Network test command: ping

(1) Command usage: ping ip address

Ping is to test the network connection between the development board and the host. The steps are as follows:

1) Plug in the internet cable

2) The local connection IPv4 address of the device host is 192.168.1.10

3) Confirm that the values ​​of several network-related environment variables in uboot on the development board are correct. The most important ipaddr (this environment variable represents the IP address of the current development board), this address must be in the same network segment as the IP address of the host.

 

The concept of network segment: an IP address is divided into two parts, one part is the network segment address, and the other part is the host address (which part is the network segment and which part is the IP address by the subnet mask). In the case of a subnet mask of 225.255.255.0 , the first three parts ( 192.168.1. ) of the IP address 192.168.1.10 belong to the network segment address, and the fourth part ( 10 ) belongs to the host address.

 

Seven, uboot common command tftp

(1) The main goal of uboot itself is to start the kernel. In order to start the kernel, it must be able to deploy the kernel. In order to deploy the kernel, uboot needs to download the kernel image from the host and burn it into the local flash . How does uboot download the image from the host to the development board? There are many ways, the mainstream way is: fastboot and tftp .

(2) The way of fastboot is to transfer data through the USB cable.

(3) tftp method :

1) Ubuntu builds a tftp server

2) Set the environment variable of the development board uboot , note that the serverip must be set to the ip address of the virtual machine ubuntu . ( The meaning of the environment variable serverip is the ip address of the host tftp server )

3) Ping ubuntu, then start downloading: tftp 0x30000000 zImage-qt (meaning to download the file named zImage-qt on the server to the address 0x30000000 of the development board memory )

4) After the image is downloaded to the DDR of the development board, uboot can use the movi command to program the image.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324732766&siteId=291194637