u-boot startup process:
From the file level, the main processes are in two files: cpu/arm920t/start.s, lib_arm/board.c,
1)start.s
The boot code executed in flash, which is stage1 in bootloader, is responsible for initializing the hardware environment, loading u-boot from flash into RAM, and then jumping to start_armboot in lib_arm/board.c for execution.
1.1.6u-boot start.s process:
Hardware environment initialization:
Enter svc mode; turn off watch dog; shield all IRQ masks; set clock frequencies FCLK, HCLK, PCLK; clear I/D cache; disable MMU and CACHE; configure memory control;
reset:
If the current code is not at the address specified by the connection (0x3f000000 for smdk2410), u-boot needs to be copied from the current location to the RAM specified location;
Establish a stack. The stack must be initialized before entering the C function.
Clear the .bss area.
Jump to the start_armboot function for execution. (lib_arm/board.c)
2)lib_arm/board.c:
start_armboot is the first C language function executed by U-Boot. It completes the system initialization work, enters the main loop, and processes the commands entered by the user. Here is only a brief list of the main executed function flows:
void start_armboot (void)
{
//The global data variable pointer gd occupies r8.
DECLARE_GLOBAL_DATA_PTR;
/* Arrange space for the global data variable gd*/
gd = (gd_t*)(_armboot_start - CFG_MALLOC_LEN - sizeof(gd_t));
memset ((void*)gd, 0, sizeof (gd_t));
/* Arrange space for the board data variable gd->bd*/
gd->bd = (bd_t*)((char*)gd - sizeof(bd_t));
memset (gd->bd, 0, sizeof (bd_t));
monitor_flash_len = _bss_start - _armboot_start;//Get the length of u-boot.
/* Execute the initialization functions in the init_sequence array sequentially*/
for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
if ((*init_fnc_ptr)() != 0) {
hang();
}
}
/*Configure available Flash */
size = flash_init ();
…
/*Initialize heap space*/
mem_malloc_init (_armboot_start - CFG_MALLOC_LEN);
/* Relocate environment variables, */
env_relocate ();
/* Get the IP address from the environment variable */
gd->bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
/* Ethernet interface MAC address */
…
devices_init (); /* device initialization*/
jumptable_init (); //Jump table initialization
console_init_r (); /* Completely initialize the console device*/
enable_interrupts (); /* Enable interrupt processing*/
/* Initialize through environment variables */
if ((s = getenv ("loadaddr")) != NULL) {
load_addr = simple_strtoul (s, NULL, 16);
}
/* main_loop() loop is executed continuously*/
for (;;) {
main_loop (); /* The main loop function processes and executes user commands-- common/main.c */
}
}
Initialization function sequence init_sequence[]
The init_sequence[] array stores basic initialization function pointers. The names of these functions and the program files that implement them are in the comments below.
init_fnc_t *init_sequence[] = {
cpu_init, /* Basic processor related configuration--cpu/arm920t/cpu.c */
board_init, /* Basic board-level configuration-- board/smdk2410/smdk2410.c */
interrupt_init, /* Initialization exception handling--cpu/arm920t/s3c24x0/interrupt.c */
env_init, /* Initialize environment variables--common/env_flash.c */
init_baudrate, /* Initialize baud rate setting-- lib_arm/board.c */
serial_init, /* Serial communication settings--cpu/arm920t/s3c24x0/serial.c */
console_init_f, /* Console initialization phase 1 -- common/console.c */
display_banner, /* print u-boot information-- lib_arm/board.c */
dram_init, /* Configure available RAM -- board/smdk2410/smdk2410.c */
display_dram_config, /* Display RAM configuration size-- lib_arm/board.c */
NULL,
};
The execution of the entire u-boot enters an infinite loop of waiting for the user to enter a command, parsing and executing the command.
Previous article:U-Boot transplantation (9) u-boot main data structure
Next article:U-Boot transplantation (7) summarizes the overall structure of the U-Boot project
- 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
- FPGA Image Processing Series - Implementing Window Processing
- Micro open source USB development board
- I have some circuit design questions.
- 【AT-START-F425 Review】TMR Servo Driver
- The air conditioner has been too cold recently. Do you turn on the air conditioner when you work?
- Two PyCon AU 2019 talks
- MSP430 Flash Emulation Tool
- Smart MM32F0270 timer DMA mode output PWM
- If the input power may be 12V or 24V, how should the TVS diode be selected?
- About Lithium Battery Pack Monitoring, SOC and Battery Balancing Technology