new file mode 100755
@@ -0,0 +1,17 @@
+#!/bin/bash -e
+
+RPI_FW_BIN_DIR="${BINARIES_DIR}/rpi-firmware"
+KERNEL_IMG="${BINARIES_DIR}/zImage"
+KERNEL_RPI_FW_IMG="${RPI_FW_BIN_DIR}/zImage"
+
+# A special marker must be appended to the kernel image so that the firmware of
+# the Raspberry Pi knows that it supports Device Tree. Without this marker, the
+# firmware passes the ATAGS boot data instead of the appropriate DTB to the
+# kernel.
+# The final kernel image must be in the rpi-firmware folder.
+mkknlimg "${KERNEL_IMG}" "${KERNEL_RPI_FW_IMG}"
+
+# Move the DTBs where the firmware expects them to be, i.e. to the rpi-firmware
+# folder.
+find "${BINARIES_DIR}/" -maxdepth 1 -type f -name '*.dtb' -print0 | \
+ xargs -0r mv -ft "${RPI_FW_BIN_DIR}/"
@@ -12,7 +12,7 @@ To be able to use your Raspberry Pi board with the images generated by
Buildroot, you have to choose whether you will use:
* Volatile rootfs in RAM (the rootfs is an initramfs) or
- * Persistent rootfs on the SDCard
+ * Persistent rootfs on the SD card
Also, a good source of information is http://elinux.org/R-Pi_Hub
@@ -22,7 +22,7 @@ How to build it
Configure Buildroot
-------------------
-There are two RaspberryPi defconfig files in Buildroot, one for each
+There are two Raspberry Pi defconfig files in Buildroot, one for each
major variant, which you should base your work on:
For models A, B, A+ or B+:
@@ -61,77 +61,65 @@ Result of the build
After building, you should obtain this tree:
output/images/
- +-- rootfs.tar [0]
+ +-- rootfs.cpio [0]
+ +-- rootfs.tar [1]
+-- rpi-firmware/
+ | +-- bcm2708-rpi-b.dtb [2]
+ | +-- bcm2708-rpi-b-plus.dtb [3]
+ | +-- bcm2709-rpi-2-b.dtb [4]
| +-- bootcode.bin
+ | +-- cmdline.txt [5]
| +-- config.txt
| +-- fixup.dat
- | `-- start.elf
- +-- bcm2708-rpi-b.dtb [1]
- +-- bcm2708-rpi-b-plus.dtb [1]
- +-- bcm2709-rpi-2-b.dtb [1]
- `-- zImage
+ | +-- start.elf
+ | `-- zImage [6]
+ `-- zImage [7]
-[0] Note for Volatile: rootfs.tar will only be there if you kept
+[0] rootfs.cpio will only be there if you selected a volatile rootfs.
+[1] Note for volatile: rootfs.tar will only be there if you kept
"tar the root filesystem" option selected in "Filesystem images".
-[1] Not all of them will be present, depending on the RaspberryPi
- model you are using.
+[2] Required for models A and B, generated by raspberrypi_defconfig.
+[3] Required for models A+ and B+, generated by raspberrypi_defconfig.
+[4] Required for model 2, generated by raspberrypi2_defconfig.
-Prepare you SDCard
-==================
+[5] Generated by Buildroot, but optional for the firmware.
+
+[6] Kernel image marked for the firmware as supporting Device Tree.
+ Note: The kernel image file name is defined in config.txt like this:
+ kernel=zImage
+[7] Original kernel image.
+
+Prepare your SD card
+====================
For more information, visit
http://elinux.org/RPi_Advanced_Setup#Advanced_SD_card_setup
-In summary, your SDCard must have first partition in fat32 and marked bootable.
+In summary, your SD card must have first partition in FAT and marked bootable.
Create the required partitions:
- - for a persistent rootfs, 10MiB is enough memory for the boot fat32
- partition, and a second partition is required for the root filesystem
- - for a volatile rootfs, 50MiB is required for the boot fat32 partition
+ - for a persistent rootfs, 10MiB is enough memory for the boot FAT
+ partition, and a second partition is required for the root filesystem,
+ - for a volatile rootfs, 50MiB is required for the boot FAT partition.
-Note: You can create any number of partitions you desire, the only requirement
-is that the first partition must be using fat32 and be bootable.
+Note: You can create any number of partitions you desire; the only requirement
+is that the first partition must be using FAT and be bootable.
-Mount the partitions (adjust 'sdX' to match your SDcard device):
+Mount the partitions (adjust 'sdX' to match your SD card device):
$ sudo mount /dev/sdX1 /mnt/mountpointboot
$ sudo mount /dev/sdX2 /mnt/mountpointroot (only for persistent rootfs)
-Install the binaries to the SDCard
-----------------------------------
+Install the binaries to the SD card
+-----------------------------------
-At the root of the boot partition, the Raspberry Pi must find the following
-files:
-
- * bcm2708-rpi-b.dtb [2]
- * bcm2708-rpi-b-plus.dtb [3]
- * bcm2709-rpi-2-b.dtb [4]
- * bootcode.bin
- * config.txt
- * fixup.dat
- * start.elf
- * zImage
-
-[2] For models A and B
-[3] For models A+ and B+
-[4] For model 2
-
-For example:
+At the root of the boot partition, the Raspberry Pi must find the files from
+output/images/rpi-firmware:
$ cp output/images/rpi-firmware/* /mnt/mountpointboot
- $ cp output/images/*.dtb /mnt/mountpointboot
-The kernel image must be marked with a special header so that the
-bootloader of the RaspberryPi knows it supports Device Tree:
-
- $ ./output/host/usr/bin/mkknlimg output/images/zImage /mnt/mountpointboot/zImage
-
-Note: The kernel image file name is defined in config.txt like this:
-kernel=zImage
-
-If you use a volatile rootfs, Skip to "Finish", below. For a persistent
+If you use a volatile rootfs, skip to "Finish", below. For a persistent
rootfs, there are further steps to do.
Extract (as root!) the contents of the rootfs.tar archive into the second
@@ -147,7 +135,7 @@ Unmount all the partitions:
$ sudo umount /mnt/mountpointboot
$ sudo umount /mnt/mountpointroot (only for persistent rootfs)
-And eject your SDcard from your computer SDcard reader.
+And eject your SD card from your computer SD card reader.
-Insert the SDcard into your Raspberry Pi, and power it up. Your new system
+Insert the SD card into your Raspberry Pi, and power it up. Your new system
should come up, now.
@@ -26,3 +26,5 @@ BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2709-rpi-2-b"
BR2_PACKAGE_RPI_FIRMWARE=y
# BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS is not set
+
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi2/post-image.sh"
@@ -25,3 +25,5 @@ BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2708-rpi-b bcm2708-rpi-b-plus"
BR2_PACKAGE_RPI_FIRMWARE=y
# BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS is not set
+
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi/post-image.sh"
Automate the preparation of the generated image files for the Raspberry Pi firmware: - mark the kernel image as supporting Device Tree, - place the marked kernel image and the DTBs into the rpi-firmware folder. The instructions in readme.txt are updated accordingly. Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com> --- board/raspberrypi/post-image.sh | 17 ++++++++ board/raspberrypi/readme.txt | 90 ++++++++++++++++++----------------------- configs/raspberrypi2_defconfig | 2 + configs/raspberrypi_defconfig | 2 + 4 files changed, 60 insertions(+), 51 deletions(-) create mode 100755 board/raspberrypi/post-image.sh