77

I have a raspberry mini computer and I am wondering how that thing does whole the boot process. I can compile my own kernel and init ramdisk with my own scripts and build my own minimal linux system on PC, but for that I need to use some bootloader. Raspberry doesn't seem to support bootloaders at all.

It seems to somehow boot up using its GPU which reads some partition on SD card (probably that one with bootable flag) that needs to be formatted in FAT32, then it reads some files from there, which are provided, for example by raspbian.

But how would I boot up my own kernel, with my own customizations that I compiled myself? Where should I copy the kernel image / initrd (ram disk) so that raspberry find it and boot from it? I am basically looking for some very detailed technical documentation that describes the boot process on raspberry or just some explanation of this.

syb0rg
  • 8,178
  • 4
  • 38
  • 51
Petr
  • 951
  • 2
  • 8
  • 7

1 Answers1

73

From this Raspberry Pi forum post [Edited to reflect loader.bin as an anachronism]:

  1. 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.
  2. 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.
  3. bootcode.bin enables SDRAM, and reads the third stage bootloader (loader.bin) from the SD card into RAM, and runs it. [ More recent versions do not use a third stage bootloader. ]
  4. [ If applicable ]loader.bin reads the GPU firmware (start.elf).
  5. 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). [ This change has since taken place. ]

Here are some resources that could be helpful:

0xC0000022L
  • 192
  • 1
  • 11
syb0rg
  • 8,178
  • 4
  • 38
  • 51