bootm 0x100000 0x240000
(其中:0x100000是linux内核在flash中的地址,0x240000是initrd在flash中的地址)
setenv bootargs console=ttyS0,115200n8 root=/dev/ram rw mem=32M
当u-boot使用上面的设置时,能够正常引导linux加载initrd !
注意:
u-boot和linux内核之间是通过ATAG-TAG方式来传递启动参数的。u-boot根据下面的命令:
bootm 0x100000 0x240000
通过调用setup_initrd_tag()在 params = (struct tag *) bd->bi_boot_params内存相应位置建立initd的TAG表项,向linux传递了关于initrd的内核参数,因此,不用在bootargs中再次指定initrd的相关参数了!
void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
ulong addr, ulong *len_ptr, int verify)
{
ulong initrd_start, initrd_end;
......
data = addr + sizeof (image_header_t);
len = ntohl (hdr->ih_size);
......
#if defined(CONFIG_B2) || defined(CONFIG_OSK_OMAP5912)
memmove ((void *) ntohl(hdr->ih_load), (uchar *)data, len);
data = ntohl(hdr->ih_load);
#endif
......
if (data) {
initrd_start = data;
initrd_end = initrd_start + len;
}
......
#if defined (CONFIG_SETUP_MEMORY_TAGS) || \
defined (CONFIG_CMDLINE_TAG) || \
defined (CONFIG_INITRD_TAG) || \
setup_start_tag (bd);
......
#ifdef CONFIG_INITRD_TAG
if (initrd_start && initrd_end)
setup_initrd_tag (bd, initrd_start, initrd_end);
#endif
......
setup_end_tag (bd);
#endif
......
theKernel (0, bd->bi_arch_number, bd->bi_boot_params);
}
#ifdef CONFIG_INITRD_TAG
static void setup_initrd_tag (bd_t *bd, ulong initrd_start, ulong initrd_end)
{
params->hdr.tag = ATAG_INITRD2;
params->hdr.size = tag_size (tag_initrd);
params->u.initrd.start = initrd_start;
params->u.initrd.size = initrd_end - initrd_start;
params = tag_next (params);
}
#endif
#if defined (CONFIG_SETUP_MEMORY_TAGS) || \
defined (CONFIG_CMDLINE_TAG) || \
defined (CONFIG_INITRD_TAG) || \
......
static void setup_start_tag (bd_t *bd)
{
params = (struct tag *) bd->bi_boot_params;
......
params = tag_next (params);
}
int board_init (void)
{
DECLARE_GLOBAL_DATA_PTR;
gd->bd->bi_arch_number = 234;
gd->bd->bi_boot_params = 0x10000100;
......
}