03U-Boot概要.ppt

03U-Boot概要

三 U-BOOT移植 三 U-BOOT移植 U-Boot启动流程之stage2 start_armboot函数是c语言的入口函数,定义在lib_arm/board.c中。 首先,初始化全局变量global_data: gd_base = CFG_UBOOT_BASE + CFG_UBOOT_SIZE - CFG_MALLOC_LEN - CFG_STACK_SIZE - sizeof(gd_t); gd = (gd_t*)gd_base; memset ((void*)gd, 0, sizeof (gd_t)); gd-bd = (bd_t*)((char*)gd - sizeof(bd_t)); memset (gd-bd, 0, sizeof (bd_t)); gd是全局变量的一个指针,始终保存在r8中。 global_data的成员大多是开发板的基本设置,如串口波特率、设备序列号、mac地址、启动参数存储地址等。 调用初始化序列: init_fnc_t *init_sequence[] = { board_init, // board/samsung/smdkc110/smdkc110.c中实现,主要BANK1 初始化、内核启动参数存放地址设置、ARCH_NUMBER设置 interrupt_init, //在cpu/s5pc11x/interrupts.c实现,初始化时钟中断 env_init, //在common/env_flash.c中实现,设置缺省环境变量 init_baudrate, //在lib_arm/board.c中实现,设置环境变量中的串口波特率 serial_init, //在common/serial.c中实现,初始化串口(硬件层面) display_banner, //在lib_arm/board.c中实现,打印U-Boot的banner dram_init, //在board/samsung/smdkc110/smdkc110.c中实现,初始化SDRAM NULL, }; U-Boot启动流程之stage2 start_armboot函数,定义在lib_arm/board.c中。 size = flash_init (); display_flash_config (size); puts (SD/MMC: ); mmc_exist = mmc_initialize(gd-bd); puts(NAND: ); nand_init(); puts(Net: ); eth_initialize(gd-bd); for (;;) { main_loop(); } /* 进入无限循环 */ U-Boot启动流程之stage2 main_loop函数是c语言的入口函数,定义在common/main.c中。 void main_loop (void) { s = getenv (bootdelay); bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY; s = getenv (bootcmd); if (bootdelay = 0 s !abortboot (bootdelay)) { run_command (s, 0); } } U-Boot启动流程之stage2 U-Boot启动Linux内核(1/3) ARM Linux Kernel Boot Requirements : 设置machine type number 定义 在include/configs/smdkv210single.h中 #define MACH_TYPE 2456 赋值(board_init函数中) gd-bd-bi_arch_number = MACH_TYPE; 把该值设置到环境变量中。 得到该值(do_bootm_linux函数中) bd_t *bd = gd-bd; int machid = bd-bi_arch_number; U-Boot启动Linux内核(2/3) do_boot_linux函数,在lib_arm/bootm.c中实现。 设置内核启动参数: setup_start_tag (bd); setup_serial_t

文档评论(0)

1亿VIP精品文档

相关文档