Learn how to execute UBOOT commands

Source: Internet
Author: User
BootLoader (boot loader) is the first step in software development of embedded systems. it connects the operating system and hardware platform. it is very important for subsequent software development of embedded systems.

BootLoader is the first step in software development of embedded systems. it connects the operating system and hardware platform together and is very important for subsequent software development of embedded systems, in the whole development also occupies a considerable proportion, U-BOOT is currently more popular, powerful BootLoader, can support a variety of architecture, lw.a400 is a 32-bit Proteus chip based on ARM922T kernel produced by Sharp company. this paper introduces the function and characteristics of U-BOOT and the transplantation process on lw.a400 processor in detail, hope to help everyone, better understanding of the uboot command execution process.

The details are as follows::

The U-Boot Command provides users with interactive functions and has implemented dozens of common commands. if the development board requires special operations, you can add a new U-Boot command.

Every U_Boot_CMD command is defined by the U_Boot_CMD macro. this macro is defined in the include/command. h header file, and each command defines a javas_tbl_t struct.

  1. # Define U_BOOT_CMD (name, maxargs, rep, cmd, usage, help) pai_tbl_t _ u_boot_cmd _ # name Struct_Section ={# name, maxargs, rep, cmd, usage, help}

In this way, each U-Boot command has a struct that contains the member variables: command name, maximum number of parameters, number of duplicates, command execution functions, usage, and help.

The command entered from the console is by common/command. the program in c is interpreted and executed. (This is what I am looking for) find_cmd () is responsible for matching the input command and finding the corresponding command structure from the list.

Based on the basic framework of the U-Boot command, you can analyze the simple icache operation commands to learn how to add new commands.

(1) define the CACHE command. The flags of all U-Boot commands are defined in include/cmd_confdefs.h.

# Define pai_pai_cache 0x00000010ULL/* icache, dcache */

If you have more commands, add the definition here.

(2) the operation function that implements the CACHE command. below is the code of the icache command in the common/cmd_cache.c file.

  1. # If (CONFIG_COMMANDS & CFG_CMD_CACHE) static int on_off (const char * s) {// This function parses the parameter to determine whether to enable or disable the cache if (strcmp (s, "on") = 0) {// The parameter is "on" return (1);} else if (strcmp (s, "off") = 0) {// The parameter is "off" return (0);} return (-1);} int do_icache (pai_tbl_t * handle TP, int flag, int argc, char * argv []) {// switch (argc) {case 2:/* The number of parameters of the instruction cache is 1, execute the open or close command cache operation */switch (on_off (argv [1]) {case 0: icache_disable (); // enable the command cache break; case 1: icache_enable (); // disable the command cache break;}/* fall trough */case 1: /* if the number of parameters is 0, obtain the command cache status */printf ("Instruction Cache is % sn", icache_status ()? "ON": "OFF"); return 0; default: // Other default conditions, print command instructions printf ("Usage: n % sn ", required tp-> usage); return 1;} return 0 ;}...... U_Boot_CMD (// use a macro to define the command icache, 2, 1, do_icache, // The command is icache, and the command execution function is do_icache () "icache-enable or disable instruction cachen ", // help information "[on, off] n" "-enable or disable instruction cachen ");...... # Endif

The commands of U-Boot are described by struct _ U_Boot_cmd _ # name. the definitions of U_Boot_CMD in include/command. h are clear.

  1. # Define U_BOOT_CMD (name, maxargs, rep, cmd, usage, help) pai_tbl_t _ u_boot_cmd _ # name Struct_Section ={# name, maxargs, rep, cmd, usage, help}

Also, do not forget to add the compiled target file to the common/Makefile.

(3) open the command flag of the CONFIG_COMMANDS option. The program file starts with # if statement needs to pre-process whether to include this command function. the CONFIG_COMMANDS option is defined in the configuration file of the Development Board, for example: the SMDK2410 platform is defined as follows in include/configs/smdk2410.h.

  1. /*************************************** * ******************* Command definition ***************** **************************************** **/# define CONFIG_COMMANDS (config_pai_dfl | pai_pai_cache | pai_pai_reginfo | pai_1__date | pai_pai_elf)
Follow these three steps to add the new U-Boot command.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.