树莓派没有Flash片子,直接从SD卡启动,并且SD卡被格式成了文件系统,kernel都放在了文件系统上,启动过程是如何的呢?从google上找到一篇介绍树莓派启动过程的文章,
- When the Raspberry Pi is first turned on, the ARM core is off, and the GPU core is on. At this point the SDRAM is disabled.
- The GPU starts executing the first stage bootloader, which is stored in ROM on the SoC. The first stage bootloader reads the SD card, and loads the second stage bootloader (bootcode.bin) into the L2 cache, and runs it.
- bootcode.bin enables SDRAM, and reads the third stage bootloader (loader.bin) from the SD card into RAM, and runs it.
- loader.bin reads the GPU firmware (start.elf).
- start.elf reads config.txt, cmdline.txt and kernel.img
loader.bin doesn't do much. It can handle .elf files, and so is needed to load start.elf at the top of memory (ARM uses SDRAM from address zero). There is a plan to add elf loading support to bootcode.bin, which would make loader.bin unnecessary, but it's a low priority (I guess it might save you 100ms on boot).
大致流程是
GPU启动,执行ROM --------> bootcode.bin 初始化SDRAM, 读取SD中loader.bin 到SDRAM ------->loader.bin 读取start.elf
(load bootcode.bin into L2 cache)
基本上start.elf才是最后load kernel的代码部分。
loader.bin其实做的事情不多,但是它能够解析elf文件结构,如果把这部分功能集成到bootcode.bin中,loader.bin的这个步骤就可以省略了。