loader.bin, boot.bin, u-boot.bin 代码执行流分析.
以上三个文件时 at91rm9200 启动所需要的三个 bin, 他们的实现代码并不难.
如果是你是采用 at91rm9200 的评估版, 应该能得到其源码.
loader.bin 执行流程, 这个文件主要在片内启动从串口下载代码时会用到
- loader/entry.S init CPU
- b main ---> crt0.S
- --> copydata --> clearbss --> b boot
- main.c --> boot -->
- /*Get internel rom service address*/
- /* Init of ROM services structure */
- pAT91 = AT91C_ROM_BOOT_ADDRESS;
- /* Xmodem Initialization */
- --> pAT91->OpenSBuffer
- --> pAT91->OpenSvcXmodem
- /* System Timer initialization */
- ---> AT91F_AIC_ConfigureIt
- /* Enable ST interrupt */
- AT91F_AIC_EnableIt
- AT91F_DBGU_Printk("XMODEM: Download U-BOOT");
- Jump.S
- // Jump to Uboot BaseAddr exec
- Jump((unsigned int)AT91C_UBOOT_BASE_ADDRESS)
boot.bin 执行流程 该文件会在从片内启动时被下载到板子上, 以后还会被烧写到片外 Flash 中, 以便在片外启动时
用它来引导并解压 u-boot.bin.gz, 并跳转到 u-boot 来执行.
- boot/entry.S
- b main --> crt0.S --> copydata --> clearbss --> b boot
- AT91F_DBGU_Printk(" ");
- AT91F_DBGU_Printk("**************************************");
- AT91F_DBGU_Printk("** Welcome to at91rm9200 **");
- AT91F_DBGU_Printk("**************************************");
- boot/misc.s /* unzip uboot.bin.gz */
- ----> decompress_image(SRC,DST,LEN) --> gunzip
- //jump to ubootBaseAddr exec 这里跳转到解压 u-boot.bin.gz 的地址处直接开始执行 u-boot
- asm("mov pc,%0" : : "r" (DST));
u-boot.bin 执行流程
- u-boot/CPU/at91rm9200/start.S
- start --->reset
- ---> copyex ---> cpu_init_crit
- ---> /* set up the stack */ --> start_armboot
- u-boot/lib_arm/board.c
- init_fnc_t *init_sequence[] = {
- cpu_init, /* basic CPU dependent setup */
- board_init, /* basic board dependent setup */
- interrupt_init, /* set up exceptions */
- env_init, /* initialize environment */
- init_baudrate, /* initialze baudrate settings */
- serial_init, /* serial communications setup */
- console_init_f, /* stage 1 init of console */
- display_banner, /* say that we are here */
- dram_init, /* configure available RAM banks */
- display_dram_config,
- checkboard,
- NULL,
- };
- ---> start_armboot ---> call init_sequence
- ---> flash_init --> display_flash_config
- ---> nand_init ---> AT91F_DataflashInit
- ---> dataflash_print_info --> env_relocate
- ---> drv_vfd_init --> devices_init --> jumptable_init
- ---> console_init_r --> misc_init_r --> enable_interrupts
- ---> cs8900_get_enetaddr --> board_post_init -->
- u-boot/common/main.c
- for (;;)
- {
- /* shell parser */
- main_loop () --> u_boot_hush_start --> readline
- --> abortboot
- -->printf("Hit any key to stop autoboot: -", bootdelay);
- }
以上是 at91rm9200 启动并进入 u-boot 的执行流分析. 后面 u-boot 还会将 uImage 解压到特定的位置并开始执行内核代码.
来源: https://www.cnblogs.com/CloudWang/p/5632251.html