47

I am wondering what the boot sequence of the Raspberry Pi is in a typical setup (say NOOBS), from power application (or warm reset if that's different) up to, say, the apparition of the logo; or where that is described.

Beside a most needed general picture of that sequence, I'm most interested in the early stages:

  1. What's the reset vector for the ARM CPU, and how/where is that defined?
  2. From what memory are the first ARM CPU instructions fetched? Where is that, and what technology is used to store this code?
  3. Is that ARM32 or Thumb (or perhaps Jazelle) code? Does that depend on the low order bit of the reset vector?
  4. Is source (or disassembly, or dump) of that early boot code available? If not, is anything technical preventing the use of the JTAG port to determine that? As for legal, I'm ready to assume the risk of trusting my understanding of the law applicable where I live (France), which is that I'm fully allowed to analyze my own computer, at least in the absence of an explicit contractual requirement not to do so.
  5. In what order are peripherals initialized, and by what piece of code?
  6. Beside the ARM CPU, is there some processor/automata running in the BCM2835, and in the affirmative how does its boot sequence relate to the ARM CPU?

I'm ready to dive into the ARM CPU's Technical Reference Manual and BCM2835 ARM Peripherals, or any other doc.

Update: After posting, I found this and this, stating the BCM2835's GPU is acting as a master to the ARM, and is heavily involved in the boot sequence.

2
  • 4
    All I can say that most of that information is closed source, like the source code, the bootloaders and SoC firmware.. For now allot is unknown. You should know one thing. The BCM is a GPU... not a CPU. The bootloader starts in the GPU section, initializes RAM there and hands over to the CPU where is the first place we have access to source code... aka Raspbian. Good Luck. This question is very broad and difficult to answer.
    – Piotr Kula
    Commented Oct 31, 2013 at 9:40
  • Related: What happens during the boot process?. Duplicate? Commented Mar 3, 2015 at 21:51

2 Answers 2

57

The boot sequence of the Raspberry Pi is basically this:

  1. Stage 1 boot is in the on-chip ROM. Loads Stage 2 in the L2 cache
  2. Stage 2 is bootcode.bin. Enables SDRAM and loads Stage 3
  3. Stage 3 is loader.bin. It knows about the .elf format and loads start.elf
  4. start.elf loads kernel.img. It then also reads config.txt, cmdline.txt and bcm2835.dtb If the dtb file exists, it is loaded at 0×100 & kernel @ 0×8000 If disable_commandline_tags is set it loads kernel @ 0×0 Otherwise it loads kernel @ 0×8000 and put ATAGS at 0×100
  5. kernel.img is then run on the ARM.

Everything is run on the GPU until kernel.img is loaded on the ARM.

I found this diagram quite useful:

Boot Sequence

6
  • 2
    Useful. Could it be clarified if the 2nd stage bootloader bootcode.bin is code run by the GPU, the ARM (and then which kind of code), or a mix of these? Same for 3rd stage loader.bin (if that's not gone, as it appears to be).
    – fgrieu
    Commented Nov 8, 2013 at 9:22
  • 6
    @fgrieu I've edited the answer to include clarification. Everything is run on the GPU until kernel.img which is run on the ARM.
    – SG60
    Commented Nov 30, 2013 at 15:58
  • 5
    According to this loader.bin is no longer used. bootcode.bin directly loads start.elf according to this Git commit Commented May 27, 2014 at 16:43
  • @SG60: Can you update your answer with the information from HeatfanJohn? Commented Mar 3, 2015 at 21:46
  • Does anyone know about NOOBS boot? apparently there process is slightly different, involving recover.elf and some soft booting antics. I'm curious about getting uboot working at a slightly lower level.
    – Sam
    Commented Feb 17, 2016 at 15:05
12

For the new Pi4, the boot flow got some changes as the old bootcode.bin moved from sdcard or /boot to internal 512KB EEPROM

0

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.