Run the Linux Kernel on a Raspberry Pi 3 Model B+

Updated: 3 minute read

Introduction

This is the fifth post in a series of posts (in a tutorial) about building an embedded Linux system for a Raspberry Pi 3 Model B+. A summary post for the tutorial can be found here. The summary post also talks about …

  • what is required to follow along,
  • the <project/root/dir>,
  • some terms that will be used throughout the series,
  • a link to an article that explains how to prepare the SD card,
  • some hints on how to use the UART interface of the Raspberry Pi.

After Building the Linux Kernel for a Raspberry Pi, it can be run on a Raspberry Pi. I used the same SD card that I had used to Run U-Boot on a Raspberry Pi, install the kernel on it, and than used U-Boot to boot the kernel.

It took me quite some time to make that work. Somehow most explanations about how to make that work, didn’t work for me (for some reason or another). Anyway, at the end and after some research I made it happen. The rest of the post explains how.

Install the Kernel

If you followed my description on Running U-Boot on a Raspberry Pi, you should be able to insert the SD card into your host system, run the following commands, and see four files on the card:

$> sudo mkdir -p /mnt/boot
$> sudo mount /dev/sdb1 /mnt/boot
$> ls /mnt/boot
bootcode.bin  config.txt  start.elf  u-boot.bin

Now, we will copy two more files onto the SD card. One is the kernel itself, the other one is a device tree that the kernel needs to configure the hardware of the Raspberry Pi.

$> sudo cp <project/root/dir>/linux/arch/arm64/boot/Image /mnt/boot/
$> sudo cp <project/root/dir>/linux/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b-plus.dtb /mnt/boot/

Boot the Linux Kernel

Now you can unmount the SD card from your host system:

$> sudo umount /mnt/boot

and place the card into the card holder of the Raspberry Pi. Once the SD card is in the Raspberry Pi and you have a connection to the UART interface, you can power up the board. You should see the same output as shown in the post Run U-Boot on a Raspberry Pi. Once you have the u-boot command prompt, the following commands make the kernel boot:

U-Boot> setenv bootargs 8250.nr_uarts=1 console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rw rootwait
U-Boot> load mmc 0:1 $kernel_addr_r Image
15034880 bytes read in 1186 ms (12.1 MiB/s)
U-Boot> load mmc 0:1 $fdt_addr_r bcm2837-rpi-3-b-plus.dtb
21027 bytes read in 3 ms (6.7 MiB/s)
U-Boot> booti $kernel_addr_r - $fdt_addr_r
## Flattened Device Tree blob at 02600000
   Booting using the fdt blob at 0x2600000
Working FDT set to 2600000
   Using Device Tree in place at 0000000002600000, end 0000000002608222
Working FDT set to 2600000

Starting kernel ...

After Starting kernel ... more output should appear. It looks something like this:

[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[    0.000000] Linux version 4.19.127-v8-schuam+ (andreas@penguin) (gcc version 13.2.0 (crosstool-NG 1.26.0)) #1 5
[    0.000000] Machine model: Raspberry Pi 3 Model B Plus Rev 1.3

... output shortened ...

[    0.000000] Kernel command line: 8250.nr_uarts=1 console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rw rt

... output shortened ...

[    1.376872] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    1.385220] VFS: Mounted root (ext4 filesystem) on device 179:2.
[    1.392808] devtmpfs: error mounting -2
[    1.405762] Freeing unused kernel memory: 2880K
[    1.410599] Run /sbin/init as init process
[    1.414876] Run /etc/init as init process
[    1.419093] Run /bin/init as init process
[    1.423271] Run /bin/sh as init process
[    1.427268] Kernel panic - not syncing: No working init found.  Try passing init= option to kernel. See Linux .

... output shortened ...

[    1.495295] ---[ end Kernel panic - not syncing: No working init found.  Try passing init= option to kernel. S-

The output stops with a Kernel panic message. Don’t panic yourself! This was expected, as there is not Root filesystem on the SD card yet. Let’s Build a Root Filesystem for a Raspberry Pi 3 Model B+ next.

Change Log

2025-02-01:

  • Made the post fit into the series of posts about embedded Linus on a Raspberry Pi 3 Model B+.

2025-01-20:

  • Fixed some typos.
  • Fixed a command.

2023-11-13:

  • Added part about using a “wrong” device tree binary.



Take care,
Andreas


References

    Updated:

    Leave a comment