In the boot partition there are two kernels, kernel.img and kernel7.img (for the pi 1 vs 2/3). How does the system know which to load?
2 Answers
All the boot magic is in /boot/config.txt
.
kernel: The alternative filename on the boot partition to use when loading the kernel; the default value is kernel.img.
Update: to clear up some confusion and to satisfy my curiosity, I tried the following small experiment.
I DO NOT RECOMMEND YOU TRY THIS!
- On my RPi3 I do not have the kernel entry in config.txt, and the system boots up fine.
- I deleted kernel.img.
- I renamed kernel7.img to foo.bar.
- After rebooting the RPi, the system failed to load. I got the multi-colour screen of death, as expected.
- I added kernel=foo.bar to my config.txt.
- Rebooted the system, and it worked.
This proves two things:
- The system can intelligently select the correct kernel per architecture, within some limits.
- The kernel entry in config.txt works if used.

- 347
- 2
- 12
See http://elinux.org/RPi_Software#Overview which describes the Pi boot process.
Basically bootcode.bin
analyses the hardware and (presumably) decides which kernel to load. (The source is not publicly available).
It is (or was) possible to specify a different kernel, but this is NOT used by normal images.
NOTE With the new USB/Network boot options for the Pi3 the process has changed but the principle remains similar.
For those interested in reading more about the new boot options Raspberry Pi boot modes

- 59,890
- 31
- 101
- 209
-
From your link, I read that completely differently. "Second stage bootloader (bootcode.bin) - This is used to retrieve the GPU firmware from the SD card, program the firmware, then start the GPU." Reading further: "User code - This can be one of any number of binaries. By default, it is the Linux kernel (usually named kernel.img), but it can also be another bootloader (e.g. U-Boot), or a bare-bones application." – SiKing Jan 24 '17 at 00:09
-
1
-
@SiKing I don't understand why you are deliberately misinterpreting my answer. I said the
kernel
option "is NOT used by normal images" NOT that it couldn't be done. This is easily verified by looking at config.txt in any standard image. – Milliways Jan 30 '17 at 06:40 -
@SiKing You are also NOT answering the actual question "How does the system know which to load" NOT what other methods can be used to load kernels. – Milliways Jan 30 '17 at 06:42
-
1I think we are both saying the same thing. I was just trying to clarify my answer. Maybe I failed. Sorry. – SiKing Jan 30 '17 at 16:54
-
these threads have been very constructive and right on point, IMO. Understanding how these devices work is difficult and general discussion on options and limitations is super helpful. – Marc Compere Feb 21 '22 at 19:52
/boot/config.txt
is passed as an argument to the closed source GPU firmwarestart.elf
which then launches the kernel specified - the confusing bit is that it seems all the boards use the pi 1 kernel image out of the box, but still contain akernel7.img
in/boot
I guess that's what's necessary for one SD card image to work across all the boards. – plastic chris Jan 24 '17 at 05:44