加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

MX51 uboot启动流程分析 - stage2

发布时间:2020-12-15 06:24:51 所属栏目:百科 来源:网络整理
导读:start.S的reset中,把uboot的第二部分从NAND或者SD卡复制到外部ram后,就可以分配执行C代码的堆栈,然后调用lib_arm/board.c中的start_armboot开始uboot的C代码部分 start_armboot的作用就是初始化系统硬件,然后进入main_loop等待用户的输入, 272 init_fnc

start.S的reset中,把uboot的第二部分从NAND或者SD卡复制到外部ram后,就可以分配执行C代码的堆栈,然后调用lib_arm/board.c中的start_armboot开始uboot的C代码部分

start_armboot的作用就是初始化系统硬件,然后进入main_loop等待用户的输入,


272 init_fnc_t *init_sequence[] = {
273 #if defined(CONFIG_ARCH_CPU_INIT)
274???? arch_cpu_init,????? /* basic arch cpu dependent setup */
275 #endif
276???? board_init,???? /* basic board dependent setup */
277 #if defined(CONFIG_USE_IRQ)
278???? interrupt_init,???? /* set up exceptions */
279 #endif ?
280???? timer_init,???? /* initialize timer */
281???? env_init,?????? /* initialize environment */
282???? init_baudrate,????? /* initialze baudrate settings */
283???? serial_init,??????? /* serial communications setup */
284???? console_init_f,???? /* stage 1 init of console */
285???? display_banner,???? /* say that we are here */
286 #if defined(CONFIG_DISPLAY_CPUINFO)
287???? print_cpuinfo,????? /* display cpu info (and speed) */
288 #endif
289 #if defined(CONFIG_DISPLAY_BOARDINFO)
290???? checkboard,???? /* display board info */
291 #endif
292 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
293???? init_func_i2c,
294 #endif
295???? dram_init,????? /* configure available RAM banks */
296 #if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI)
297???? arm_pci_init,
298 #endif
299???? display_dram_config,
300???? NULL,
301 };?

硬件初始化函数列表


303 void start_armboot (void)

304 {
305???? init_fnc_t **init_fnc_ptr;
306???? char *s;
307 #if defined(CONFIG_VFD) || defined(CONFIG_LCD)
308???? unsigned long addr;
309 #endif
310
311???? /* Pointer is writable since we allocated a register for it */
312???? gd = (gd_t*)(_armboot_start - CONFIG_SYS_MALLOC_LEN - sizeof(gd_t));
313???? /* compiler optimization barrier needed for GCC >= 3.4 */
314???? __asm__ __volatile__("": : :"memory");
315
316???? memset ((void*)gd,sizeof (gd_t));
317???? gd->bd = (bd_t*)((char*)gd - sizeof(bd_t));
318???? memset (gd->bd,sizeof (bd_t));
319
320???? gd->flags |= GD_FLG_RELOC;
321
322???? monitor_flash_len = _bss_start - _armboot_start;
323
324???? for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
325???????? if ((*init_fnc_ptr)() != 0) {
326???????????? hang ();
327???????? }
328???? }


312 为global_data分配空间,这里并没有使用malloc来分配空间,因为还没有初始化malloc区,所以无法用malloc分配global_data

322 monitor_flash_len就是uboot镜像的大小,uboot中把uboot镜像叫做monitor

324~327 执行初始化序列函数

331 对malloc区进行初始化,其实就是把_armboot_start 到_armboot_start - CONFIG_SYS_MALLOC_LEN这段区域初始化为0


381 #ifdef CONFIG_GENERIC_MMC
382???? puts ("MMC:?? ");
383???? mmc_initialize (gd->bd);
384 #endif

初始化SD/MMC,mmc_initialize会初始化主机端接口,mmc_initialize会调用board_mmc_init,board_mmc_init需要根据项目对系统内的sdhc接口进行初始化


499???? for (;;) { 500???????? main_loop (); 501???? } main_loop等待用户输入或者直接启动kernel

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读