From patchwork Sat Aug 22 20:01:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Beno=C3=AEt_Th=C3=A9baudeau?= X-Patchwork-Id: 509726 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ozlabs.org (Postfix) with ESMTP id B75B6140775 for ; Sun, 23 Aug 2015 06:01:45 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 4086695B61; Sat, 22 Aug 2015 20:01:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id N65YWd9t0Tg2; Sat, 22 Aug 2015 20:01:42 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 8202395B01; Sat, 22 Aug 2015 20:01:41 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 6685D1C1619 for ; Sat, 22 Aug 2015 20:01:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 638CA95A78 for ; Sat, 22 Aug 2015 20:01:39 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5udzcxXkk5gJ for ; Sat, 22 Aug 2015 20:01:38 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from authsmtp.register.it (authsmtp71.register.it [195.110.101.55]) by hemlock.osuosl.org (Postfix) with ESMTP id 8EC418AE36 for ; Sat, 22 Aug 2015 20:01:37 +0000 (UTC) Received: from localhost.localdomain ([88.172.188.148]) by paganini34 with id 7w1W1r00y3CYkgw01w1bW8; Sat, 22 Aug 2015 22:01:36 +0200 X-Rid: benoit@wsystem.com@88.172.188.148 From: =?UTF-8?q?Beno=C3=AEt=20Th=C3=A9baudeau?= To: buildroot@buildroot.org Date: Sat, 22 Aug 2015 22:01:26 +0200 Message-Id: <1440273688-92868-2-git-send-email-benoit@wsystem.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1440273688-92868-1-git-send-email-benoit@wsystem.com> References: <1440273688-92868-1-git-send-email-benoit@wsystem.com> In-Reply-To: <20150820143005.GA6441@ketchup.mtl.sfl> References: <20150820143005.GA6441@ketchup.mtl.sfl> MIME-Version: 1.0 Cc: =?UTF-8?q?Beno=C3=AEt=20Th=C3=A9baudeau?= Subject: [Buildroot] [PATCH 2/4] board/raspberrypi: prepare the image files for the target X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" 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 --- 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"