1、 setenv bootargs noinitrd mem=192M console=ttyAMA0,115200 root=/dev/mtdblock2 rw rootfstype=yaffs2 init=/sbin/init mtdparts=hinand:1M(boot)ro,5M(kernel),125M(firstfs),125M(secondfs);saveenv;reset
2、setenv bootargs noinitrd mem=192M console=ttyAMA0,115200 root=/dev/mtdblock2 rw rootfstype=yaffs2 mtdparts=hinand:1M(boot)ro,5M(kernel),125M(firstfs),125M(secondfs);saveenv;reset
第一个与第二个区别就在有没有指定init进程!
一、当指定init的时候,内核不会运行下面代码:
static noinline int init_post(void)
{
/*joseph feed wdg by kj */
joseph_wdg_reset_line(__LINE__);
/* need to finish all async __init code before freeing the memory */
async_synchronize_full();
free_initmem();
mark_rodata_ro();
system_state = SYSTEM_RUNNING;
numa_default_policy();
current->signal->flags |= SIGNAL_UNKILLABLE;
if (ramdisk_execute_command) {
run_init_process(ramdisk_execute_command);
printk(KERN_WARNING "Failed to execute %s\n",
ramdisk_execute_command);
}
/*
* We try each of these until one succeeds.
*
* The Bourne shell can be used instead of init if we are
* trying to recover a really broken machine.
*/
if (execute_command) {
run_init_process(execute_command);
printk(KERN_WARNING "Failed to execute %s. Attempting "
"defaults...\n", execute_command);
}
/*joseph off wdg by kj*/
joseph_wdg_off();
run_init_process("/sbin/init");
run_init_process("/etc/init");
run_init_process("/bin/init");
run_init_process("/bin/sh");
panic("No init found. Try passing init= option to kernel. "
"See Linux Documentation/init.txt for guidance.");
}
二、不指定的时候才会运行init_post!
三、内核引导文件系统的时候,还有一个稍微早点的结束点,代码如下:
static inline int free_area(unsigned long pfn, unsigned long end, char *s)
{
unsigned int pages = 0, size = (end - pfn) << (PAGE_SHIFT - 10);
for (; pfn < end; pfn++) {
struct page *page = pfn_to_page(pfn);
ClearPageReserved(page);
init_page_count(page);
__free_page(page);
pages++;
}
if (size && s)
printk(KERN_INFO "Freeing %s memory: %dK\n", s, size);
/*joseph feed wdg by kj*/
joseph_wdg_off();
return pages;
}