78

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.

1

1 Answer 1

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:

9
  • 2
    Is that content of these bin files all proprietary software?
    – Petr
    Nov 2, 2013 at 17:25
  • 4
    @Petr Here is the Github for the Raspberry Pi firmware, I'll edit it into my answer.
    – syb0rg
    Nov 2, 2013 at 17:28
  • 1
    On the Raspberry Pi FAQ's, it says "You have to boot from SD but a USB HD can “take over” after the initial boot. You cannot boot without an SD card."
    – syb0rg
    Nov 2, 2013 at 17:32
  • 1
    Is that parition, which is read first, any partition with B flag or it must be first partition? What if I made it too large and I wanted to create another one on end of SD card which would be smaller
    – Petr
    Nov 3, 2013 at 12:32
  • 1
    @Petr You should ask that as another question!
    – syb0rg
    Nov 3, 2013 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.