Last active
May 1, 2019 20:25
-
-
Save vivien/752f85b563b02afd772c to your computer and use it in GitHub Desktop.
[PATCH 0/2] board/raspberrypi: add a genimage config (based on 8d00fe4)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 9c91753518e813ad96c3ec4d225f4545cff826e3 Mon Sep 17 00:00:00 2001 | |
From: Vivien Didelot <[email protected]> | |
Date: Mon, 16 Mar 2015 00:21:31 -0400 | |
Subject: [PATCH 1/2] board/raspberrypi: install Device Tree | |
Add a post-image script to Raspberry Pi configs with a Device Tree | |
(raspberrypi_dt and raspberrypi2), which calls the mkknlimg tool on the | |
resulting zImage kernel, in order to install the Device Tree as | |
described in the board readme file. | |
Signed-off-by: Vivien Didelot <[email protected]> | |
--- | |
board/raspberrypi/mark-dt.sh | 9 +++++++++ | |
configs/raspberrypi2_defconfig | 1 + | |
configs/raspberrypi_dt_defconfig | 1 + | |
3 files changed, 11 insertions(+) | |
create mode 100755 board/raspberrypi/mark-dt.sh | |
diff --git a/board/raspberrypi/mark-dt.sh b/board/raspberrypi/mark-dt.sh | |
new file mode 100755 | |
index 0000000..4852565 | |
--- /dev/null | |
+++ b/board/raspberrypi/mark-dt.sh | |
@@ -0,0 +1,9 @@ | |
+#!/bin/bash | |
+ | |
+# Merely appends a marker at the end of the kernel image, which instructs the | |
+# RPi bootloader that the kernel is Device Tree aware, and thus the bootloader | |
+# will load the device tree blobs; if the marker is missing, the bootloader | |
+# will not load a device tree blob, and will pass ATAGS. | |
+ | |
+mkknlimg "${BINARIES_DIR}/zImage" "${BINARIES_DIR}/zImage-dt" | |
+mv "${BINARIES_DIR}/zImage-dt" "${BINARIES_DIR}/zImage" | |
diff --git a/configs/raspberrypi2_defconfig b/configs/raspberrypi2_defconfig | |
index b523a4a..306ebef 100644 | |
--- a/configs/raspberrypi2_defconfig | |
+++ b/configs/raspberrypi2_defconfig | |
@@ -23,3 +23,4 @@ BR2_LINUX_KERNEL_ZIMAGE=y | |
# Install the DTB files, as the RPi2 uses the Device Tree | |
BR2_PACKAGE_RPI_FIRMWARE=y | |
BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTBS=y | |
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi2/mark-dt.sh" | |
diff --git a/configs/raspberrypi_dt_defconfig b/configs/raspberrypi_dt_defconfig | |
index ca62084..bcf5598 100644 | |
--- a/configs/raspberrypi_dt_defconfig | |
+++ b/configs/raspberrypi_dt_defconfig | |
@@ -20,3 +20,4 @@ BR2_LINUX_KERNEL_ZIMAGE=y | |
# Install the DTB files | |
BR2_PACKAGE_RPI_FIRMWARE=y | |
BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTBS=y | |
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi/mark-dt.sh" | |
-- | |
2.5.0 | |
From 79b3f9be9229d843e2e2e957982529a7c3b93635 Mon Sep 17 00:00:00 2001 | |
From: Vivien Didelot <[email protected]> | |
Date: Thu, 16 Apr 2015 18:36:33 -0400 | |
Subject: [PATCH 2/2] board/raspberrypi: add a genimage config | |
This patch adds a genimage config file and a post-image script for the | |
Raspberry Pi models, to generate a medium image "sdcard.img", ready to | |
be booted. | |
The image contains the persistent layout explained in the board | |
readme.txt file: a vfat partition for the kernel, DT and firmware files, | |
and a Ext4 rootfs partition. | |
The defconfigs have been slightly changed to enable this feature. Also | |
lighten the readme file since the config file is documented and simpler. | |
Signed-off-by: Vivien Didelot <[email protected]> | |
--- | |
board/raspberrypi/genimage.cfg | 56 ++++++++++++++ | |
board/raspberrypi/genimage.sh | 13 ++++ | |
board/raspberrypi/readme.txt | 154 ++++----------------------------------- | |
configs/raspberrypi2_defconfig | 3 +- | |
configs/raspberrypi_defconfig | 2 + | |
configs/raspberrypi_dt_defconfig | 3 +- | |
6 files changed, 88 insertions(+), 143 deletions(-) | |
create mode 100644 board/raspberrypi/genimage.cfg | |
create mode 100755 board/raspberrypi/genimage.sh | |
diff --git a/board/raspberrypi/genimage.cfg b/board/raspberrypi/genimage.cfg | |
new file mode 100644 | |
index 0000000..4757f62 | |
--- /dev/null | |
+++ b/board/raspberrypi/genimage.cfg | |
@@ -0,0 +1,56 @@ | |
+# Minimal SD card image for the Raspberry Pi | |
+# | |
+# The SD card must have at least a bootable VFAT partition containing the | |
+# firmware files, the kernel, and optionally the device tree blob. | |
+# | |
+# This image defines a persistent rootfs partition. If you prefer a | |
+# volatile rootfs, you have to slightly adjust the configuration: | |
+# | |
+# $ make menuconfig | |
+# * Select "Filesystem images" | |
+# * Select "initial RAM filesystem linked into linux kernel" | |
+# | |
+# You may also deselect "tar the root filesystem". Then adjust the | |
+# boot.vfat image size to at least 50M and remove the rootfs partition | |
+# definition below. | |
+# | |
+# For more information, visit | |
+# http://elinux.org/RPi_Advanced_Setup#Advanced_SD_card_setup | |
+ | |
+image boot.vfat { | |
+ vfat { | |
+ files = { | |
+ # Mandatory RPi firmware files | |
+ "rpi-firmware/bootcode.bin", | |
+ "rpi-firmware/config.txt", | |
+ "rpi-firmware/fixup.dat", | |
+ "rpi-firmware/start.elf", | |
+ | |
+ # Device Tree Blobs, for dt-marked kernels | |
+ "rpi-firmware/bcm2708-rpi-b.dtb", | |
+ "rpi-firmware/bcm2708-rpi-b-plus.dtb", | |
+ "rpi-firmware/bcm2709-rpi-2-b.dtb", | |
+ | |
+ # Kernel, optionally marked for DT-enabled configs (see mkknlimg) | |
+ "zImage" | |
+ } | |
+ } | |
+ size = 10M | |
+} | |
+ | |
+image sdcard.img { | |
+ hdimage { | |
+ } | |
+ | |
+ partition boot { | |
+ partition-type = 0xC | |
+ bootable = "true" | |
+ image = "boot.vfat" | |
+ } | |
+ | |
+ partition rootfs { | |
+ partition-type = 0x83 | |
+ image = "rootfs.ext4" | |
+ size = 512M | |
+ } | |
+} | |
diff --git a/board/raspberrypi/genimage.sh b/board/raspberrypi/genimage.sh | |
new file mode 100755 | |
index 0000000..77f99e9 | |
--- /dev/null | |
+++ b/board/raspberrypi/genimage.sh | |
@@ -0,0 +1,13 @@ | |
+#!/bin/bash | |
+ | |
+GENIMAGE_CFG="board/raspberrypi/genimage.cfg" | |
+GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp" | |
+ | |
+rm -rf "${GENIMAGE_TMP}" | |
+ | |
+genimage \ | |
+ --rootpath "${TARGET_DIR}" \ | |
+ --tmppath "${GENIMAGE_TMP}" \ | |
+ --inputpath "${BINARIES_DIR}" \ | |
+ --outputpath "${BINARIES_DIR}" \ | |
+ --config "${GENIMAGE_CFG}" | |
diff --git a/board/raspberrypi/readme.txt b/board/raspberrypi/readme.txt | |
index b513ca3..d2f5d1f 100644 | |
--- a/board/raspberrypi/readme.txt | |
+++ b/board/raspberrypi/readme.txt | |
@@ -1,153 +1,25 @@ | |
Raspberry Pi | |
-Intro | |
-===== | |
+https://www.raspberrypi.org/ | |
-These instructions apply to all models of the Raspberry Pi: | |
+Buildroot supports all Raspberry Pi models: | |
- the original models A and B, | |
- the "enhanced" models A+ and B+, | |
- the model B2 (aka Raspberry Pi 2). | |
-To be able to use your Raspberry Pi board with the images generated by | |
-Buildroot, you have to choose whether you will use: | |
+To build a minimal support for one of these boards, run: | |
- * Volatile rootfs in RAM (the rootfs is an initramfs) or | |
- * Persistent rootfs on the SDCard | |
+ $ make <model>_defconfig | |
+ $ make | |
-Also, a good source of information is http://elinux.org/R-Pi_Hub | |
+Where <model> is one of: | |
-How to build it | |
-=============== | |
+ - "raspberrypi" for A, B, A+ and B+ models, | |
+ - "raspberrypi_dt" for previous models with device tree support, | |
+ - "raspberrypi2" for the B2 model (implies device tree support). | |
-Configure Buildroot | |
-------------------- | |
+Buildroot prepares a bootable "sdcard.img" image in the output/images/ | |
+directory, ready to be dumped on an SD card. | |
-The raspberrypi_defconfig configuration is a minimal configuration with | |
-all that is required to bring the Raspberry Pi. You should base your | |
-work on this defconfig: | |
- | |
- $ make raspberrypi_defconfig | |
- | |
-Alternatively, if you want to test support for the Device Tree: | |
- | |
- $ make raspberrypi_dt_defconfig | |
- | |
-If you want to use a persistent rootfs, skip to "Build the rootfs", below. | |
- | |
-For a volatile rootfs, you have to slightly adjust the configuration: | |
- | |
- $ make menuconfig | |
- * Select "Filesystem images" | |
- * Select "initial RAM filesystem linked into linux kernel" | |
- | |
-You may also deselect "tar the root filesystem". | |
- | |
-Build the rootfs | |
----------------- | |
- | |
-Note: you will need to have access to the network, since Buildroot will | |
-download the packages' sources. | |
- | |
-You may now build your rootfs with: | |
- | |
- $ make | |
- | |
-(This may take a while; consider getting yourself a coffee ;-) ) | |
- | |
-Result of the build | |
-------------------- | |
- | |
-After building, you should obtain this tree: | |
- | |
- output/images/ | |
- +-- rootfs.tar [0] | |
- +-- rpi-firmware/ | |
- | +-- bcm2708-rpi-b.dtb | |
- | +-- bcm2708-rpi-b-plus.dtb | |
- | +-- bcm2709-rpi-2-b.dtb | |
- | +-- bootcode.bin | |
- | +-- config.txt | |
- | +-- fixup.dat | |
- | `-- start.elf | |
- `-- zImage | |
- | |
-[0] Note for Volatile: rootfs.tar will only be there if you kept | |
- "tar the root filesystem" option selected in "Filesystem images". | |
- | |
-Prepare you SDCard | |
-================== | |
- | |
-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. | |
- | |
-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 | |
- | |
-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. | |
- | |
-Mount the partitions (adjust 'sdX' to match your SDcard device): | |
- | |
- $ sudo mount /dev/sdX1 /mnt/mountpointboot | |
- $ sudo mount /dev/sdX2 /mnt/mountpointroot (only for persistent rootfs) | |
- | |
-Install the binaries to the SDCard | |
----------------------------------- | |
- | |
-At the root of the boot partition, the Raspberry Pi must find the following | |
-files: | |
- | |
- * bcm2708-rpi-b.dtb [1] | |
- * bcm2708-rpi-b-plus.dtb [2] | |
- * bcm2709-rpi-2-b.dtb [3] | |
- * bootcode.bin | |
- * config.txt | |
- * fixup.dat | |
- * start.elf | |
- * zImage | |
- | |
-[1] For models A and B | |
-[2] For models A+ and B+ | |
-[3] For model 2 | |
- | |
-For example: | |
- | |
- $ cp output/images/rpi-firmware/* /mnt/mountpointboot | |
- | |
-If your kernel does *not* have support for the Device Tree, then install | |
-it with: | |
- | |
- $ cp output/images/zImage /mnt/mountpointboot | |
- | |
-If your kernel *does* have support for the Device Tree, then install it | |
-with: | |
- | |
- $ ./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 | |
-rootfs, there are further steps to do. | |
- | |
-Extract (as root!) the contents of the rootfs.tar archive into the second | |
-partition you created above: | |
- | |
- $ sudo tar xf ./output/images/rootfs.tar -C /mnt/mountpointroot | |
- | |
-Finish | |
-====== | |
- | |
-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. | |
- | |
-Insert the SDcard into your Raspberry Pi, and power it up. Your new system | |
-should come up, now. | |
+For details about the medium image layout, see the definition in | |
+board/raspberrypi/genimage.cfg. | |
diff --git a/configs/raspberrypi2_defconfig b/configs/raspberrypi2_defconfig | |
index 306ebef..bdfed13 100644 | |
--- a/configs/raspberrypi2_defconfig | |
+++ b/configs/raspberrypi2_defconfig | |
@@ -23,4 +23,5 @@ BR2_LINUX_KERNEL_ZIMAGE=y | |
# Install the DTB files, as the RPi2 uses the Device Tree | |
BR2_PACKAGE_RPI_FIRMWARE=y | |
BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTBS=y | |
-BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi2/mark-dt.sh" | |
+BR2_PACKAGE_HOST_GENIMAGE=y | |
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi2/mark-dt.sh board/raspberrypi2/genimage.sh" | |
diff --git a/configs/raspberrypi_defconfig b/configs/raspberrypi_defconfig | |
index 835657c..5029b53 100644 | |
--- a/configs/raspberrypi_defconfig | |
+++ b/configs/raspberrypi_defconfig | |
@@ -7,6 +7,8 @@ BR2_TOOLCHAIN_BUILDROOT_CXX=y | |
BR2_TARGET_GENERIC_GETTY_PORT="tty1" | |
BR2_PACKAGE_RPI_FIRMWARE=y | |
+BR2_PACKAGE_HOST_GENIMAGE=y | |
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi/genimage.sh" | |
# Lock to 3.12 headers as the RPi kernel is based off the 3.12 branch | |
BR2_KERNEL_HEADERS_VERSION=y | |
diff --git a/configs/raspberrypi_dt_defconfig b/configs/raspberrypi_dt_defconfig | |
index bcf5598..93d7620 100644 | |
--- a/configs/raspberrypi_dt_defconfig | |
+++ b/configs/raspberrypi_dt_defconfig | |
@@ -20,4 +20,5 @@ BR2_LINUX_KERNEL_ZIMAGE=y | |
# Install the DTB files | |
BR2_PACKAGE_RPI_FIRMWARE=y | |
BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTBS=y | |
-BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi/mark-dt.sh" | |
+BR2_PACKAGE_HOST_GENIMAGE=y | |
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi/mark-dt.sh board/raspberrypi/genimage.sh" | |
-- | |
2.5.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment