一、uboot引导内核
1、flash分区
1、flash分区(include/configs/mini2440.h)
#define MTDIDS_DEFAULT "nand0=nandflash0"
#define MTDPARTS_DEFAULT "mtdparts=nandflash0:256@0(bootloader)"\
"128k(params)," \
"2m(kernel)," \
"8m(jffs2)," \
"-(yaffs)"
2、uboot引导内核依赖两个变量
bootcmd= nand read 31000000 400000 500000 \; bootm 31000000
1、bootcmd(common/main.c : main_loop())
s = getenv ("bootcmd");
2、执行bootm引导内核
3、读取头部
typedef struct image_header {
uint32_t ih_magic; /* Image Header Magic Number */
uint32_t ih_hcrc; /* Image Header CRC Checksum */
uint32_t ih_time; /* Image Creation Timestamp */
uint32_t ih_size; /* Image Data Size */
uint32_t ih_load; /* Data Load Address */
uint32_t ih_ep; /* Entry Point Address */
uint32_t ih_dcrc; /* Image Data CRC Checksum */
uint8_t ih_os; /* Operating System */
uint8_t ih_arch; /* CPU architecture */
uint8_t ih_type; /* Image Type */
uint8_t ih_comp; /* Compression Type */
uint8_t ih_name[IH_NMLEN]; /* Image Name */
} image_header_t;
4、启动内核
do_bootm_linux (cmdtp, flag, argc, argv, addr, len_ptr, verify);
5、跳转至内核
<lib_arm/armlinuc.c>
void (*theKernel)(int zero, int arch, uint params);
theKernel = (void (*)(int, int, uint))ntohl(hdr->ih_ep);
theKernel (0, bd->bi_arch_number, bd->bi_boot_params);
6、内核参数
setup_start_tag (bd);
setup_memory_tags (bd);
setup_commandline_tag (bd, commandline); //commandline来源于bootargs
setup_end_tag (bd)