Uboot startup process analysis

U-Boot U-Boot, short for Universal Boot Loader, is an open-source project released under the GPL license. Its primary role is to boot systems, particularly in embedded environments. U-Boot evolved from earlier projects such as FADSROM, 8xxROM, and PPCBOOT. The source code structure and compilation process of U-Boot are very similar to the Linux kernel. In fact, many parts of the U-Boot codebase are derived from the Linux kernel, especially device drivers. This can be seen in the comments within the code. U-Boot not only supports booting embedded Linux systems but also other operating systems like NetBSD, VxWorks, QNX, RTEMS, ARTOS, LynxOS, and Android. It currently supports a wide range of operating systems, including OpenBSD, NetBSD, FreeBSD, 4.4BSD, Linux, SVR4, Esix, Solaris, Irix, SCO, Dell, NCR, VxWorks, LynxOS, pSOS, QNX, RTEMS, ARTOS, and Android. This versatility reflects the "Universal" aspect of U-Boot. Another key feature is its support for various processor architectures, such as PowerPC, MIPS, x86, ARM, NIOS, and XScale. These two characteristics—supporting multiple processors and operating systems—are core goals of the U-Boot project. Initially, U-Boot had the most extensive support for PowerPC processors and the best support for Linux. After being renamed from PPCBOOT to U-Boot in November 2002, support for other processors and OSes gradually expanded. The smooth transition was largely due to the dedication and expertise of Wolfgang Denk, the maintainer from DENX Software Engineering in Germany. Today, U-Boot continues to grow under his leadership, with many developers contributing to expand its compatibility across different embedded platforms.

Uboot startup process analysis

Uboot Startup Process Analysis The entry point of the program is at `_start`, which can be found in `u-boot-2016.05\arch\arm\lib\vectors.S` using SourceInsight. ```assembly ENTRY(_start) SECTIONS { . = 0x00000000; . = ALIGN(4); .text : { *(.__image_copy_start) *(.vectors) CPUDIR/start.o (.text*) *(.text*) } . = ALIGN(4); .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } . = ALIGN(4); .data : { *(.data*) } . = ALIGN(4); . = . ; . = ALIGN(4); .bss_start __rel_dyn_start (OVERLAY) : { KEEP(*(.__bss_start)); __bss_base = . ; } .bss __bss_base (OVERLAY) : { *(.bss*) . = ALIGN(4); __bss_limit = . ; } .bss_end __bss_limit (OVERLAY) : { KEEP(*(.__bss_end)); } } ``` After jumping from `_start`, the code jumps to `reset` for execution: ```assembly .globl _start _start: #ifdef CONFIG_SYS_DV_NOR_BOOT_CFG .word CONFIG_SYS_DV_NOR_BOOT_CFG #endif b reset Ldr pc, _undefined_instruction Ldr pc, _software_interrupt Ldr pc, _prefetch_abort Ldr pc, _data_abort Ldr pc, _not_used Ldr pc, _irq Ldr pc, _fiq ``` **1. Reset from u-boot-2016.05\arch\arm\cpu\arm920t\start.S** The main execution flow is: `reset -> cpu_init_crit -> lowlevel_init -> _main`. ```assembly reset: #ifndef CONFIG_SKIP_LOWLEVEL_INIT Bl cpu_init_crit #endif Bl _main ``` **2. Jump from `bl _main` to `u-boot-2016.05\arch\arm\lib\crt0.S`** The main execution flow is: `board_init_f -> relocate_code -> board_init_r`. ```assembly ENTRY(_main) Bl board_init_f_alloc_reserve Bl board_init_f_init_reserve Bl board_init_f #if !defined(CONFIG_SPL_BUILD) b relocate_code #endif ``` There are three key points in this section: (1) `board_init_f` in `u-boot-2016.05\common\board_f.c` executes a series of initialization functions through `initcall_run_list(init_sequence_f)` to complete the first half of board-level initialization. (2) `relocate_code` in `u-boot-2016.05\arch\arm\lib\relocate.S` handles the relocation of U-Boot code. (3) There are two paths to relocate U-Boot: one is by setting `gd->flags` to 0 and calling `jump_to_copy`, and the other is by skipping `CONFIG_SPL_BUILD`. **3. Enter `board_init_r` in `u-boot-2016.05\common\board_r.c`** Through `ldr pc, =board_init_r`, the function calls `initcall_run_list(init_sequence_r)` to execute the second half of the board-level initialization and then enters `run_main_loop`. ```c void board_init_r(gd_t *new_gd, ulong dest_addr) { if (initcall_run_list(init_sequence_r)) Hang(); /* NOTREACHED - run_main_loop() does not return */ Hang(); } ``` **4. Enter `main_loop` in `u-boot-2016.05\common\main.c`** Before entering `main_loop`, initialization is complete, and the system is ready to process commands. ```c static int run_main_loop(void) { for (;;) main_loop(); return 0; } ``` In the `main_loop` function, two important processes occur: (1) `bootdelay_process()` retrieves the `bootcmd` parameter. (2) `autoboot_command(s)` passes the `bootcmd` to `run_command_list`, which eventually executes the command. **5. Execute the Command via `board_run_command`** The `run_command_list` function calls `board_run_command`, which executes the command. For example, when the `bootm` command is used, it triggers the `do_bootm` function in `u-boot-2016.05\cmd\bootm.c`. ```c U_BOOT_CMD( bootm, CONFIG_SYS_MAXARGS, 1, do_bootm, "boot application image from memory", bootm_help_text ); ``` This allows the system to load and boot the kernel image located at address `30000000`.

For Huawei Oca

For Huawei Oca,Huawei Oca Sheet,Huawei Optical Clear Adhesive Glue,Huawei P60 Oca Sheet Paper

Dongguan Jili Electronic Technology Co., Ltd. , https://www.jlglassoca.com