1. Command format description
There is a lot of information on how to use the command on the Internet. I will just briefly explain it here:
Each command of U-Boot is defined by the U_Boot_CMD macro. This macro is defined in the #ifdef CFG_LONGHELP #define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep,cmd, usage, help} #else / no long help info*/ #define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep,cmd, usage} #endif / CFG_LONGHELP */ Each command defines a cmd_tbl_t structure, and cmd_tbl_t is just a typedef of cmd_tbl_s, as shown below: typedef struct cmd_tbl_s cmd_tbl_t; The definition of cmd_tbl_s is in the same file struct cmd_tbl_s { char *name; / Command Name */ int maxargs; /maximum number of arguments */ int repeatable; / autorepeat allowed? */ /Implementation function */ int (*cmd)(struct cmd_tbl_s *, int, int,char *[]); char *usage; / Usage message (short) */ #ifdef CFG_LONGHELP char *help; / Help message (long) */ #endif #ifdef CONFIG_AUTO_COMPLETE / do auto completion onthe arguments */ Int (*complete)(int argc, char *argv[], charlast_char, nt maxv, char *cmdv[]); #endif }; Let's briefly explain the meaning of each variable in U_BOOT_CMD, or cmd_tbl_s structure: 1. name: the name of the command. Note that it is not a string (do not enclose it in commas). 2. maxargs: the maximum number of parameters. 2. Repeatable: Whether the command can be repeated. Repeatable means that after running a command, you can run it again by pressing Enter next time. 4. cmd: corresponding function pointer, type is (*cmd)(strunt cmd_tbl_s *, int,int,char *[]). 5. usage: a brief description of usage, this is a string 6. help: more detailed instructions for use, which is also a string. In this way, each U-Boot command has a structure to describe it. The member variables of the structure include: command name, maximum number of parameters, number of repetitions, command execution function, usage, and help. The commands entered from the console are interpreted and executed by the program in common/command.c. find_cmd() is responsible for matching the entered command, finding the corresponding command structure from the list and returning a pointer to this structure. Based on the basic framework of U-Boot commands, the following briefly describes how to add Cleanlcd operation commands. 2. Add the cleanlcd command 1. Define the cleanlcd command The flags of all commands supported by UBOOT are defined in #define CONFIG_CMD_CLEANLCD /*add by zth*/ Among them, the commands defined in #define CONFIG_CMD_CLEANLCD /*add by zth*/ Of course, you can also write this definition statement directly in 2. Add cmd_cleanlcd.c file The content is as follows: /* add by zth this command use to clean the LcD */ #include #include #include #include #include #include #if defined(CONFIG_CMD_CLEANLCD) static int do_clean_lcd(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { unsigned intcolour_value; if (argc < 2) { printf("Yourcommand not right! Please chcek help; n"); return -1; } colour_value =simple_strtoul(argv[1], NULL, 16); colour_value=colour_value & 0xFFFFFF; //printf("colour_value=%sn",argv[1]); //printf("colour_value=%xn",colour_value); memset_int(LCD_VIDEO_ADDR, colour_value,VIDEO_MEM_SIZE); return 0; } U_BOOT_CMD( cleanlcd, 5, 1, do_clean_lcd, "this just use toclean the lcd with a colour", "add by zth n" "commandformat:n" "cleanlcdcolour_valuen " "colour_value youcan use an 24bit valuen" ); #endif The first line of code in the file is: memset_int(LCD_VIDEO_ADDR, colour_value,VIDEO_MEM_SIZE); Why didn't I use memset()? This is because when I debugged, I found that the program called void * memset(void * s,char c,size_t count) instead of: void * memset(void * s,int c,size_t count) In this case, the LCD display result is not what we want. In order to solve this problem, I directly used the memset_int in the bare metal program I wrote before. Here we need to define this function. In fact, it has already been written in our code, but it has been commented. The following two lines of code define it. 3. Modify zth_tiny4412_lcd.h and zth_tiny4412_lcd.c and files Open zth_tiny4412_lcd.h, locate around line 24: remove the comments and modify it to: extern void memset_int(unsigned int * s, int c,unsigned int count); Open zth_tiny4412_lcd.c and locate around line 46: remove the comments and modify it to void memset_int(unsigned int * s, int c,unsigned int count) { unsigned int *xs =(unsigned int *) s; while (count--) *xs++ = c; //return s; } Then locate around line 262 and modify it to: memset_int((void *)pGD->frameAdrs, 0xFF00, pGD->memSize); 4. Modify /common/makefile Open /common/makefile, locate around line 83, and add: COBJS-$(CONFIG_CMD_CLEANLCD) +=cmd_cleanlcd.o After completing the above 4 steps, you can compile, burn and run. The following commands are provided for reference: cp -R /media/sf_share/u-boot_zth . chmod 777 -R u-boot_zth / cd u-boot_zth make distclean make zthtiny4412_config make cd sd_fuse/ make cd zthtiny4412/ ./sd_fusing.sh /dev/sdb After running, enter the help command in the serial debugging terminal, and you can find the newly added cleanlcd command, as shown in the following figure: Figure 20-1. Newly added command running effect diagram Use the cleanlcd command to display a color, for example, the command: cleanlcd0x995500, the running effect is as shown in the figure below: Figure 20-2 LCD effect of command execution
Previous article:Chapter 8. Timing and Principle of Eight SDRAM Transplantation in Tiny4412 U-BOOT
Next article:tiny4412 UART sends and receives data
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- A little skill can satisfy high return income. Let's share a product repair with super high click rate
- Why use ultrasonic testing for flow meters?
- How KiCAD schematics and PCB interact
- About Power
- Usage of $test$plusargs
- Amplifier Expert Design Experience
- Flathead RVB2601 board-web playback
- After magnifying the CPU internals 10,000 times
- [Modification] Both the boost board and the purifier are troublesome in voltage
- Where does the magnetic flux go in this case and what is its impact?