当前位置:   article > 正文

U-Boot启动过程分解 2_uboot please reset the board

uboot please reset the board

2.       初始化函数功能:

       for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {

              if ((*init_fnc_ptr)() != 0) {

                     hang ();

              }

       }

       此处判断init_fnc_t的结构是否清零,否则打印

### ERROR ### Please RESET the board ###\n

 

附:init_fnc_t的结构定义:

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 */

#if defined(CONFIG_DISPLAY_CPUINFO)

     print_cpuinfo,        /* display cpu info (and speed) */

#endif

#if defined(CONFIG_DISPLAY_BOARDINFO)

     checkboard,           /* display board info */

#endif

     dram_init,              /* configure available RAM banks */

     display_dram_config,

     NULL,

};

gd_t的结构定义:

typedef     struct      global_data {

bd_t        *bd;

unsigned long  flags;

unsigned long  baudrate;

unsigned long  have_console; /* serial_init() was called */

unsigned long  reloc_off;       /* Relocation Offset */

unsigned long  env_addr;       /* Address  of Environment struct */

unsigned long  env_valid;       /* Checksum of Environment valid? */

unsigned long  fb_base;  /* base address of frame buffer */

#ifdef CONFIG_VFD

unsigned char vfd_type; /* display type */

#endif

#if 0

unsigned long  cpu_clk;  /* CPU clock in Hz!              */

unsigned long  bus_clk;

unsigned long  ram_size; /* RAM size */

unsigned long  reset_status;   /* reset status register at boot */

#endif

void        **jt;        /* jump table */

} gd_t;

3.       若定义CFG_NO_FLASH,对FLASH初始化:

初始化FLASH,并打印flashsize

此处未涉及,不再追究;

4.       若定义CONFIG_VFD则对其进行初始化:

设置初始化地址,此处未涉及,不再追究;

5.       若定义CONFIG_LCD对其地址初始化:

此处定义LCD页为4096,并将_bss_end 后一页空间设为其地址,并将其清零,再将地址赋值到gd->fb_base

6.       对内存地址初始化:

此处调用void mem_malloc_init(ulong dest_addr);对内存的起始、结束和断点地址设置;

#ifdef CONFIG_MEMORY_UPPER_CODE /* by scsuh */

mem_malloc_init (CFG_UBOOT_BASE + CFG_UBOOT_SIZE - CFG_MALLOC_LEN - CFG_STACK_SIZE);

#else

mem_malloc_init (_armboot_start - CFG_MALLOC_LEN);

#endif

 

附:

static

void mem_malloc_init (ulong dest_addr)

{

mem_malloc_start = dest_addr;

mem_malloc_end = dest_addr + CFG_MALLOC_LEN;

mem_malloc_brk = mem_malloc_start;

 

/* memset ((void *) mem_malloc_start, 0,

               mem_malloc_end - mem_malloc_start); */

}

7.       初始化SDCardnand flash

本文档只针对S3c6410+256M nand flash注释,程序在此处分别判断CONFIG_SMDK6410/CONFIG_SMDK6430CONFIG_SMDK6400/CONFIG_SMDK2450/CONFIG_SMDK2416两类不同cpu进行不同初始化,不相关其余部分忽略;

     /* SD/MMC detecting is on as default */

     puts("SD/MMC:  ");

     movi_set_capacity();            /*设置容量,未作任何处理*/

     movi_set_ofs(MOVI_TOTAL_BLKCNT);    /*填充ofsinfo结构*/

     movi_init();     /*设置gpio、使能位,初始化(设置设备时钟、读写速度、中断使能、检测设备类型等)*/

 

     if (INF_REG3_REG == 1) {

            puts("OneNAND: ");

            onenand_init();

            setenv("bootcmd", "onenand read c0008000 40000 3c0000;bootm c0008000");

     } else {

            puts("NAND:    ");

            nand_init();     /*填充oob_config结构,并打印flash容量*/

            /*打印指令*/

            if (INF_REG3_REG == 0 || INF_REG3_REG == 7)

                   setenv("bootcmd", "movi read kernel c0008000;movi read rootfs c0800000;bootm c0008000");

            else

                   setenv("bootcmd", "nand read c0008000 40000 3c0000;bootm c0008000");    

     }

       该部分内容,首先初始化SD/MMC,然后对nand flash进行初始化,

8.       若定义数据flash CONFIG_HAS_DATAFLASH,对其进行初始化:

该设备暂不涉及,暂不追究;

9.       env_relocate ();未知功能:

10.   设置MAC地址与网卡:

对网络知识欠缺,此部分内容跳过;

11.   设备初始化:

devices_init ();       /* get the devices list going. */

I2Clcdvideokeyboardlogbuffsystemserial devicesusbttynetconsole

12.   不解功能(line431-442):

#ifdef CONFIG_CMC_PU2

    load_sernum_ethaddr ();

#endif /* CONFIG_CMC_PU2 */

 

    jumptable_init ();

 

    console_init_r ();    /* fully init console as a device */

 

#if defined(CONFIG_MISC_INIT_R)

    /* miscellaneous platform dependent initialisations */

    misc_init_r ();

#endif

13.   使能中断:

enable_interrupts ();

该函数调用汇编指令:

mrs %0, cpsr

bic %0, %0, #0x80

msr cpsr_c, %0

14.   网络部分设置内容(line448-466):忽略

15.   boot命令相关,不解(line468-476

16.   void main_loop(void)

命令循环主函数,根据相应命令,执行对应操作;

NotefriendlyARM公司在启动过程中加入了Menu函数和对应数字动作处理功能;

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/899246
推荐阅读
相关标签
  

闽ICP备14008679号