72

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,108
  • 4
  • 35
  • 50
Petr
  • 881
  • 2
  • 8
  • 7
  • 1
    possible duplicate of [What happens during the boot process?](http://raspberrypi.stackexchange.com/questions/1200/what-happens-during-the-boot-process) – asalamon74 Apr 09 '15 at 09:53

1 Answers1

69

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
  • 10
syb0rg
  • 8,108
  • 4
  • 35
  • 50
  • 2
    Is that content of these bin files all proprietary software? – Petr Nov 02 '13 at 17:25
  • 3
    @Petr [Here](https://github.com/raspberrypi/firmware) is the Github for the Raspberry Pi firmware, I'll edit it into my answer. – syb0rg Nov 02 '13 at 17:28
  • also is there any way to make start.elf read an initrd instead of directly booting the kernel? That means, could I create a ram disk which the system boot from, so that I could for example contain my system on entirely different device than SD card (the OS could be living even on some RAID / LVM storage which would need to be initialised first using a script in initrd) – Petr Nov 02 '13 at 17:29
  • 1
    On the [Raspberry Pi FAQ's](http://www.raspberrypi.org/faqs), 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 02 '13 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 03 '13 at 12:32
  • 1
    @Petr You should ask that as another question! – syb0rg Nov 03 '13 at 14:57
  • @Petr proprietary I think. `LICENCE.broadcom` says "This software may only be used for the purposes of developing for, running or using a Raspberry Pi device." – Ciro Santilli OurBigBook.com Oct 07 '16 at 22:28
  • @syb0rg: Update: it is now possible to boot without an SD card on newer RPis (3+); RPi 1 not at all, only some RPi 2Bs: https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/msd.md – Piskvor left the building Feb 25 '19 at 12:48
  • This is an excellent answer. Clear and to the point. – geerlingguy Oct 09 '21 at 02:55