当前位置:网站首页>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
......
边栏推荐
- [algorithm post interview] interview questions of a small factory
- Vscode editor
- 摄像头的MIPI接口、DVP接口和CSI接口
- 达梦数据库全部
- Marvell 88e1515 PHY loopback mode test
- Orin 安装CUDA环境
- The difference between new and malloc
- Sum of two numbers, the numbers in the array are converted to decimal, added, and output inversely
- window navicat连接阿里云服务器mysql步骤及常见问题
- [Chongqing Guangdong education] National Open University 2018 autumn 0702-22t contemporary Chinese political system reference questions
猜你喜欢
随机推荐
Mipi interface, DVP interface and CSI interface of camera
Technical conference arrangement
LSA Type Explanation - detailed explanation of lsa-2 (type II LSA network LSA) and lsa-3 (type III LSA network Summary LSA)
iNFTnews | 喝茶送虚拟股票?浅析奈雪的茶“发币”
Lexin interview process
Speedtree01 generator properties
The differences and connections among cookies, sessions, JWT, and tokens
Unity UGUI不同的UI面板或者UI之间如何进行坐标匹配和变换
ROS2——安装ROS2(三)
数据库Mysql全部
Some classic recursion problems
IPage能正常显示数据,但是total一直等于0
Sre core system understanding
1290_FreeRTOS中prvTaskIsTaskSuspended()接口实现分析
Integer to 8-bit binary explanation (including positive and negative numbers) scope of application -127~+127
Huawei bracelet, how to add medicine reminder?
ROS2——功能包(六)
.net core踩坑实践
Error: “MountVolume.SetUp failed for volume pvc 故障处理
Vscode editor