上接uboot启动第二阶段1
一、初始化nor flash
#ifndef CFG_NO_FLASH
/* configure available FLASH banks */
size = flash_init ();
display_flash_config (size);
#endif /* CFG_NO_FLASH */
typedef struct {
ulong size; /* total bank size in bytes */
ushort sector_count; /* number of erase units */
ulong flash_id; /* combined device & manufacturer code */
ulong start[CFG_MAX_FLASH_SECT]; /* physical sector start addresses */
uchar protect[CFG_MAX_FLASH_SECT]; /* sector protection status */
#ifdef CFG_FLASH_CFI
uchar portwidth; /* the width of the port */
uchar chipwidth; /* the width of the chip */
ushort buffer_size; /* # of bytes in write buffer */
ulong erase_blk_tout; /* maximum block erase timeout */
ulong write_tout; /* maximum write timeout */
ulong buffer_write_tout; /* maximum buffer write timeout */
ushort vendor; /* the primary vendor id */
ushort cmd_reset; /* Vendor specific reset command */
ushort interface; /* used for x8/x16 adjustments */
ushort legacy_unlock; /* support Intel legacy (un)locking */
#endif
} flash_info_t;
二,堆的初始化。初始化后才能调用内存分配、释放函数。
/* armboot_start is defined in the board-specific linker script */
mem_malloc_init (_armboot_start - CFG_MALLOC_LEN);
三、对nand flash进行初始化。
内容涉及mtd 存储技术设备。目前没有分析明白,一会有相关博客更新
#if (CONFIG_COMMANDS & CFG_CMD_NAND)
puts ("NAND: ");
nand_init(); /* go init the NAND */
#endif
四、环境变量的重定位
/* initialize environment */
env_relocate ();
主要讲flash中的环境变量赋值到内存中。
五、查找IP地址与MAC地址
/* IP Address */
gd->bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
/* MAC Address */
{
int i;
ulong reg;
char *s, *e;
char tmp[64];
i = getenv_r ("ethaddr", tmp, sizeof (tmp));
s = (i > 0) ? tmp : NULL;
for (reg = 0; reg < 6; ++reg) {
gd->bd->bi_enetaddr[reg] = s ? simple_strtoul (s, &e, 16) : 0;
if (s)
s = (*e) ? e + 1 : e;
}
六、设备初始化:
主要进行串口的初始化,其他没有要初始化的内容。
devices_init (); /* get the devices list going. */
七、跳转表初始化,对一些函数重定义。
jumptable_init ();
console_init_r (); /* fully init console as a device */
控制台初始化,对输出输出进行标记。
八、中断、网口初始化
/* enable exceptions */
enable_interrupts ();
/* Perform network card initialisation if necessary */
#ifdef CONFIG_DRIVER_CS8900
cs8900_get_enetaddr (gd->bd->bi_enetaddr);
#endif
九、下面读取loadaddr环境变量。调用main_loop ();函数如果设置了延时,在延时内是否有串口输入,如果没有直接调用loadaddr加载内核。如果有数据输入,进入循环一直对串口数据进行解析、分析、调用响应的函数