当前位置:网站首页>U-boot initialization and workflow analysis
U-boot initialization and workflow analysis
2022-07-05 07:02:00 【Linux and SOC】
0. summary
U-Boot Usually from the architecture related assembly file ( Suffixed with capital S Assembly file of means linkable ) Get the first executed instruction in , for example :
- arch/arm/cpu/armv7/start.S
- arch/powerpc/cpu/mpc83xx/start.S
- arch/mips/cpu/start.S
In the assembly file listed above , It mainly performs the following three functions :
lowlevel_init()
board_init_f()
board_init_r()
The complete execution process is shown in the figure below :
1. lowlevel_init()
Processors of different architecture types will be defined separately lowlevel_init.S
file , for example :
./arch/arm/cpu/armv7/lowlevel_init.S
./arch/arm/cpu/armv8/lowlevel_init.S
./arch/mips/mach-ath79/ar933x/lowlevel_init.S
The basic function of this function is to make CPU Can get 、 Execute to board_init_f()
function . There is no stack information in this function , Cannot set SDRAM And the console .
.pushsection .text.lowlevel_init, "ax"
WEAK(lowlevel_init)
#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_STACK)
ldr sp, =CONFIG_SPL_STACK
#else
ldr sp, =CONFIG_SYS_INIT_SP_ADDR
#endif
bic sp, sp, #7 /* 8-byte alignment for ABI compliance */
#ifdef CONFIG_SPL_DM
mov r9, #0
#else
#ifdef CONFIG_SPL_BUILD
ldr r9, =gdata
#else
sub sp, sp, #GD_SIZE
bic sp, sp, #7
mov r9, sp
#endif
#endif
push {ip, lr}
bl s_init
pop {ip, pc}
ENDPROC(lowlevel_init)
.popsection
2. board_init_f()
To carry out board_init_r
To prepare for , Two key functions need to be initialized :SDRAM And serial port .
At this stage ,global_data
Already available , Stack information is located in SRAM in . because BSS The segment is still unusable , therefore , You cannot use global / Static variables .
if U-Boot It turns on SPL function , It's in common/spl.c
This function can be implemented in the code , otherwise , Usually, the common/board_f.c
Implementation in .
board_init_f()
The function called in array init_sequence_f[]
In the definition of :
static const init_fnc_t init_sequence_f[] = {
setup_mon_len,
......
env_init, /* initialize environment */
init_baud_rate, /* initialze baudrate settings */
serial_init, /* serial communications setup */
console_init_f, /* stage 1 init of console */
display_options, /* say that we are here */
display_text_info, /* show debugging info if required */
checkcpu,
#if defined(CONFIG_SYSRESET)
print_resetinfo,
#endif
#if defined(CONFIG_DISPLAY_CPUINFO)
print_cpuinfo, /* display cpu info (and speed) */
#endif
#if defined(CONFIG_DTB_RESELECT)
embedded_dtb_select,
#endif
#if defined(CONFIG_DISPLAY_BOARDINFO)
show_board_info,
#endif
INIT_FUNC_WATCHDOG_INIT
#if defined(CONFIG_MISC_INIT_F)
misc_init_f,
#endif
INIT_FUNC_WATCHDOG_RESET
#if defined(CONFIG_SYS_I2C)
init_func_i2c,
#endif
#if defined(CONFIG_VID) && !defined(CONFIG_SPL)
init_func_vid,
#endif
announce_dram_init,
dram_init, /* configure available RAM banks */
#ifdef CONFIG_POST
post_init_f,
#endif
......
#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \ !CONFIG_IS_ENABLED(X86_64)
jump_to_copy,
#endif
NULL,
};
3. board_init_r()
U-Boot Execute here , It has entered the normal function code call process , For example, device driver 、 Command line 、 Image moving, loading and other functions .
if U-Boot It turns on SPL function , It's in common/spl.c
This function can be implemented in the code , otherwise , Usually, the common/board_r.c
Implementation in .
board_init_r()
The function called in array init_sequence_r[]
In the definition of :
static init_fnc_t init_sequence_r[] = {
initr_trace,
initr_reloc,
......
#ifdef CONFIG_MMC
initr_mmc,
#endif
......
run_main_loop,
};
All the above functions are related to initialization ,CPU The relevant initialization code is usually located in the following path :
[email protected]$ ls arch/arm/
config.mk lib mach-davinci mach-keystone mach-orion5x mach-snapdragon mach-tegra mach-zynqmp-r5
cpu mach-aspeed mach-exynos mach-kirkwood mach-owl mach-socfpga mach-uniphier Makefile
dts mach-at91 mach-highbank mach-mediatek ......
[email protected]$
The initialization code related to the board level is usually located in the following path :
[email protected]$ ls board/
abilis bluewater corscience ge lg qca sifive toradex
advantech bosch creative geekbuying l+g qemu-mips silica tplink
alliedtelesis boundary cssi google liebherr qualcomm sks-kinkel tqc
altera broadcom CZ.NIC grinn logicpd quipos socrates ucRobotics
......
边栏推荐
猜你喜欢
Database mysql all
What is linting
LSA Type Explanation - detailed explanation of lsa-2 (type II LSA network LSA) and lsa-3 (type III LSA network Summary LSA)
Ros2 - configuration development environment (V)
GDB code debugging
ROS2——初识ROS2(一)
Rehabilitation type force deduction brush question notes D2
【MySQL8.0不支持表名大写-对应方案】
MySQL (UDF authorization)
ROS2——常用命令行(四)
随机推荐
ROS2——Service服务(九)
[nvidia] CUDA_ VISIBLE_ DEVICES
Volcano 资源预留特性
LSA Type Explanation - lsa-5 (type 5 LSA - autonomous system external LSA) and lsa-4 (type 4 LSA - ASBR summary LSA) explanation
网易To B,柔外刚中
MySQL setting trigger problem
Skywalking全部
Log4qt usage of logbase in QT project
Skywalking all
6-3 find the table length of the linked table
Ros2 - configuration development environment (V)
The “mode“ argument must be integer. Received an instance of Object
PowerManagerService(一)— 初始化
Error: "mountvolume.setup failed for volume PVC fault handling
Interpretation of the earliest sketches - image translation work sketchygan
逻辑结构与物理结构
【软件测试】04 -- 软件测试与软件开发
Written examination notes
The problem of Chinese garbled code in the vscode output box can be solved once for life
ROS2——常用命令行(四)