当前位置:网站首页>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
......
边栏推荐
- Get class files and attributes by reflection
- Rehabilitation type force deduction brush question notes D3
- SolidWorks template and design library are convenient for designers to call
- Error: “MountVolume.SetUp failed for volume pvc 故障处理
- Vant Weapp SwipeCell設置多個按鈕
- Integer to 8-bit binary explanation (including positive and negative numbers) scope of application -127~+127
- [untitled]
- The differences and connections among cookies, sessions, JWT, and tokens
- Log4qt usage of logbase in QT project
- Executealways of unity is replacing executeineditmode
猜你喜欢

Skywalking全部

docker安装mysql并使用navicat连接

【软件测试】03 -- 软件测试概述

Qt项目中的日志库log4qt使用

在本地搭建一个微服务集群环境,学习自动化部署

Literacy Ethernet MII interface types Daquan MII, RMII, smii, gmii, rgmii, sgmii, XGMII, XAUI, rxaui

Pycahrm reports an error: indentation error: unindent does not match any outer indentation

Get class files and attributes by reflection

U-Boot初始化及工作流程分析

【无标题】
随机推荐
Database mysql all
cgroup_ memcg
namespace
【MySQL8.0不支持表名大写-对应方案】
postmessage通信
Technology blog learning website
数学分析_笔记_第8章:重积分
扫盲-以太网MII接口类型大全-MII、RMII、SMII、GMII、RGMII、SGMII、XGMII、XAUI、RXAUI
[algorithm post interview] interview questions of a small factory
能量守恒和打造能量缺口
In C language, int a= 'R'
Literacy Ethernet MII interface types Daquan MII, RMII, smii, gmii, rgmii, sgmii, XGMII, XAUI, rxaui
Page type
CGroup CPU group source code analysis
达梦数据库全部
【软件测试】05 -- 软件测试的原则
Preemption of CFS scheduling
解读最早的草图-图像翻译工作SketchyGAN
Special training of C language array
Cookie、Session、JWT、token四者间的区别与联系