04-S3C2440u-boot学习之u-boot分析(3)之源码第1、2阶段
2017-02-09 11:39
399 查看
参考《韦东山1期视频》第09课第3节 u-boot分析之源码第1阶段.WMV
一:第一阶段
b reset(跳转到reset):
1.设置SVC32 模式;
2.关看门狗;
3.关中断;
4.cpu_init_crit(SDRAM初始化);
5.设置栈;
6.时钟初始化clock_init;
8.清bss段
9.调用C函数start_armboot
以上9部称为硬件相关初始化。
前8部称为第一阶段。
第二阶段从start_armboot开始。
1.gd指针指向(128字节内存)
2.一系列初始化
CPU初始化
单板初始化
flash初始化:
倒计时:
一:第一阶段
(1)打开u-boot-1.1.6_JZ2440\cpu\arm920t\start.S
_start:b reset(跳转到reset):
1.设置SVC32 模式;
reset: /* * set the cpu to SVC32 mode */ mrs r0,cpsr bic r0,r0,#0x1f orr r0,r0,#0xd3 msr cpsr,r0
2.关看门狗;
/* turn off the watchdog */ #if defined(CONFIG_S3C2400) # define pWTCON 0x15300000 # define INTMSK 0x14400008 /* Interupt-Controller base addresses */ # define CLKDIVN 0x14800014 /* clock divisor register */ #elif defined(CONFIG_S3C2410) # define pWTCON 0x53000000 # define INTMOD 0X4A000004 # define INTMSK 0x4A000008 /* Interupt-Controller base addresses */ # define INTSUBMSK 0x4A00001C # define CLKDIVN 0x4C000014 /* clock divisor register */ #endif #if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) ldr r0, =pWTCON mov r1, #0x0 str r1, [r0]
3.关中断;
/* * mask all IRQs by setting all bits in the INTMR - default */ mov r1, #0xffffffff ldr r0, =INTMSK str r1, [r0] # if defined(CONFIG_S3C2410) ldr r1, =0x3ff ldr r0, =INTSUBMSK str r1, [r0] # endif #if 0 /* FCLK:HCLK:PCLK = 1:2:4 */ /* default FCLK is 120 MHz ! */ ldr r0, =CLKDIVN mov r1, #3 str r1, [r0] #endif #endif /* CONFIG_S3C2400 || CONFIG_S3C2410 */ /* * we do sys-critical inits only at reboot, * not when booting from ram! */
4.cpu_init_crit(SDRAM初始化);
#ifndef CONFIG_SKIP_LOWLEVEL_INIT adr r0, _start /* r0 <- current position of code */ ldr r1, _TEXT_BASE /* test if we run from flash or RAM */ cmp r0, r1 /* don't reloc during debug */ blne cpu_init_crit #endif
5.设置栈;
6.时钟初始化clock_init;
#ifndef CONFIG_SKIP_LOWLEVEL_INIT bl clock_init #endif7.重定位:把代码从flash读到SDRAM里面去,读到链接地址去。
#ifndef CONFIG_SKIP_RELOCATE_UBOOT relocate: /* relocate U-Boot to RAM */ adr r0, _start /* r0 <- current position of code */ ldr r1, _TEXT_BASE /* test if we run from flash or RAM */ cmp r0, r1 /* don't reloc during debug */ beq clear_bss ldr r2, _armboot_start ldr r3, _bss_start sub r2, r3, r2 /* r2 <- size of armboot */
8.清bss段
9.调用C函数start_armboot
以上9部称为硬件相关初始化。
前8部称为第一阶段。
第二阶段从start_armboot开始。
1.gd指针指向(128字节内存)
2.一系列初始化
for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { if ((*init_fnc_ptr)() != 0) { hang (); } }
CPU初始化
单板初始化
init_fnc_t *init_sequence[] = { cpu_init, /* basic cpu dependent setup */ board_init, /* basic board dependent setup */ interrupt_init, /* set up exceptions */ env_init, /* initialize environment */ init_baudrate, /* initialze baudrate settings */ serial_init, /* serial communications setup */ console_init_f, /* stage 1 init of console */ display_banner, /* say that we are here */
flash初始化:
#ifndef CFG_NO_FLASH /* configure available FLASH banks */ size = flash_init (); display_flash_config (size); #endif /* CFG_NO_FLASH */malloc初始化(192K)
/* armboot_start is defined in the board-specific linker script */ mem_malloc_init (_armboot_start - CFG_MALLOC_LEN);nand 初始化
#if (CONFIG_COMMANDS & CFG_CMD_NAND) puts ("NAND: "); nand_init(); /* go init the NAND */ #endif环境变量初始化:默认值或者在flash上存储的值
/* initialize environment */ env_relocate ();死循环:
for (;;) { main_loop (); }s = getenv ("bootcmd");
倒计时:
if (bootdelay >= 0 && s && !abortboot (bootdelay)) { # ifdef CONFIG_AUTOBOOT_KEYED int prev = disable_ctrlc(1); /* disable Control C checking */ # endif # ifndef CFG_HUSH_PARSER { printf("Booting Linux ...\n"); run_command (s, 0); } # else parse_string_outer(s, FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP); # endif
相关文章推荐
- 04-S3C2440u-boot学习之u-boot分析(1)编译体验
- 04-S3C2440u-boot学习之u-boot分析(4)之u-boot命令实现
- 04-S3C2440u-boot学习之u-boot分析(5)_uboot启动内核
- 04-S3C2440u-boot学习之u-boot分析(2)之Makefile结构分析
- 伟东山视频自学笔记——第9课第3节 u-boot分析之源码第1阶段(2增加一个命令)
- u-boot启动过程源码分析之第一阶段(S3C24XX系列)
- TQ2440 学习笔记—— 31、移植U-Boot【U-Boot 的启动过程第二阶段源码分析】
- TQ2440 学习笔记—— 30、移植U-Boot【U-Boot 的启动过程第一阶段源码分析】
- 伟东山视频自学笔记——第9课第3节 u-boot分析之源码第1阶段(1)
- u-boot启动过程源码分析之第二阶段(S3C24XX系列)
- U-boot在开发板上移植过程详解(2)---U-boot实现源码分析(第一阶段)
- 图解U-Boot:第一阶段源码分析
- u-boot-2010.06 源码分析<3>--第二阶段
- u-boot源码分析 --- 启动第二阶段002
- u-boot源码分析 --- 启动第二阶段007
- U-Boot 启动过程和源码分析(第二阶段)
- linux内核学习初笔记(5)uboot第一阶段我的分析
- 图解U-Boot:第一阶段源码分析
- u-boot-2010.06 源码分析<3>--第二阶段
- u-boot源码分析 --- 启动第二阶段005