Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Benoît Thébaudeau" <benoit@wsystem.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 2/4] board/raspberrypi: prepare the image files for the target
Date: Sat, 22 Aug 2015 22:01:26 +0200	[thread overview]
Message-ID: <1440273688-92868-2-git-send-email-benoit@wsystem.com> (raw)
In-Reply-To: <1440273688-92868-1-git-send-email-benoit@wsystem.com>

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

diff --git a/board/raspberrypi/post-image.sh b/board/raspberrypi/post-image.sh
new file mode 100755
index 0000000..db9c53c
--- /dev/null
+++ b/board/raspberrypi/post-image.sh
@@ -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}/"
diff --git a/board/raspberrypi/readme.txt b/board/raspberrypi/readme.txt
index cf95879..168fab5 100644
--- a/board/raspberrypi/readme.txt
+++ b/board/raspberrypi/readme.txt
@@ -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.
diff --git a/configs/raspberrypi2_defconfig b/configs/raspberrypi2_defconfig
index 7e49f0c..bfbf243 100644
--- a/configs/raspberrypi2_defconfig
+++ b/configs/raspberrypi2_defconfig
@@ -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"
diff --git a/configs/raspberrypi_defconfig b/configs/raspberrypi_defconfig
index 2d47058..5ded72f 100644
--- a/configs/raspberrypi_defconfig
+++ b/configs/raspberrypi_defconfig
@@ -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"
-- 
2.1.4

  reply	other threads:[~2015-08-22 20:01 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-19 22:23 [Buildroot] rpi: image generation Benoît Thébaudeau
2015-08-20  7:59 ` Thomas Petazzoni
2015-08-20 14:30   ` Vivien Didelot
2015-08-22 20:01     ` [Buildroot] [PATCH 1/4] configs/raspberrypi: use EABIhf Benoît Thébaudeau
2015-08-22 20:01       ` Benoît Thébaudeau [this message]
2015-10-17 11:45         ` [Buildroot] [PATCH 2/4] board/raspberrypi: prepare the image files for the target Yann E. MORIN
2015-10-17 13:52           ` Benoît Thébaudeau
2015-08-22 20:01       ` [Buildroot] [PATCH 3/4] board/raspberrypi: generate a medium image Benoît Thébaudeau
2015-08-22 20:01       ` [Buildroot] [PATCH 4/4] board/raspberrypi: auto-expand rootfs on first boot Benoît Thébaudeau
2015-08-27  9:02         ` Benoît Thébaudeau
2015-08-27 21:22           ` Jérôme Pouiller
2015-08-28 10:36             ` Benoît Thébaudeau
2015-08-28 11:15               ` Benoît Thébaudeau
     [not found]         ` <4057940.fE2DsQZqLb@sagittea>
2015-08-31  9:11           ` Benoît Thébaudeau
2015-08-31 12:17         ` Floris Bos
2015-08-31 18:53           ` Benoît Thébaudeau
2015-08-31 13:25         ` Floris Bos
2015-08-31 19:05           ` Benoît Thébaudeau
2015-10-12 21:59       ` [Buildroot] [PATCH 1/4] configs/raspberrypi: use EABIhf Thomas Petazzoni
2015-10-12 23:17         ` Benoît Thébaudeau
2015-10-13  7:06           ` Arnout Vandecappelle
2015-10-15 20:11         ` Peter Korsgaard
2015-10-15 21:12           ` Peter Korsgaard
2015-10-25 15:19           ` [Buildroot] [PATCH] arch/arm: use EABIhf by default with VFP Benoît Thébaudeau
2015-10-25 18:53             ` Peter Korsgaard
2015-10-26  0:32               ` Thomas Petazzoni
2015-10-26  7:47                 ` Peter Korsgaard
2015-10-26  8:25                   ` Thomas Petazzoni
2015-10-26  8:51                     ` Peter Korsgaard
2015-10-25 18:55             ` Peter Korsgaard
2015-10-25 20:27               ` Benoît Thébaudeau
2015-10-25 20:40                 ` Peter Korsgaard
2015-10-25 20:52                   ` Benoît Thébaudeau
2015-10-25 21:30                     ` Yann E. MORIN

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1440273688-92868-2-git-send-email-benoit@wsystem.com \
    --to=benoit@wsystem.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox