Skip to contentSkip to conversation

Preliminary support for Raspberry Pi 3.

PATCH New Ubaldo Porcheddu 4 participants 8 messages Apr 20, 2016 – Apr 22, 2016 Broadcom BCM2711/BCM2835 Arm architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Preliminary support for Raspberry Pi 3.

---
 board/raspberrypi3/genimage-raspberrypi3.cfg | 30 +++++++++++++
 board/raspberrypi3/post-build.sh             |  9 ++++
 board/raspberrypi3/post-image.sh             | 22 ++++++++++
 board/raspberrypi3/readme.txt                | 64 ++++++++++++++++++++++++++++
 configs/raspberrypi3_defconfig               | 36 ++++++++++++++++
 5 files changed, 161 insertions(+)
 create mode 100644 board/raspberrypi3/genimage-raspberrypi3.cfg
 create mode 100755 board/raspberrypi3/post-build.sh
 create mode 100755 board/raspberrypi3/post-image.sh
 create mode 100644 board/raspberrypi3/readme.txt
 create mode 100644 configs/raspberrypi3_defconfig
board/raspberrypi3/genimage-raspberrypi3.cfg new file +30 -0
new file mode 100644
index 0000000..7ba89c5
@@ -0,0 +1,30 @@
+image boot.vfat {
+  vfat {
+    files = {
+      "bcm2710-rpi-3-b.dtb",
+      "rpi-firmware/bootcode.bin",
+      "rpi-firmware/cmdline.txt",
+      "rpi-firmware/config.txt",
+      "rpi-firmware/fixup.dat",
+      "rpi-firmware/start.elf",
+      "kernel-marked/zImage"
+    }
+  }
+  size = 32M
+}
+
+image sdcard.img {
+  hdimage {
+  }
+
+  partition boot {
+    partition-type = 0xC
+    bootable = "true"
+    image = "boot.vfat"
+  }
+
+  partition rootfs {
+    partition-type = 0x83
+    image = "rootfs.ext4"
+  }
+}
board/raspberrypi3/post-build.sh new file +9 -0
new file mode 100755
index 0000000..7eae14a
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+set -u
+set -e
+
+# Add a console on tty1
+grep -qE '^tty1::' ${TARGET_DIR}/etc/inittab || \
+sed -i '/GENERIC_SERIAL/a\
+tty1::respawn:/sbin/getty -L  tty1 0 vt100 # HDMI console' ${TARGET_DIR}/etc/inittab
board/raspberrypi3/post-image.sh new file +22 -0
new file mode 100755
index 0000000..73ffd65
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+BOARD_DIR="$(dirname $0)"
+BOARD_NAME="$(basename ${BOARD_DIR})"
+GENIMAGE_CFG="${BOARD_DIR}/genimage-${BOARD_NAME}.cfg"
+GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
+
+# Mark the kernel as DT-enabled
+mkdir -p "${BINARIES_DIR}/kernel-marked"
+${HOST_DIR}/usr/bin/mkknlimg "${BINARIES_DIR}/zImage" \
+	"${BINARIES_DIR}/kernel-marked/zImage"
+
+rm -rf "${GENIMAGE_TMP}"
+
+genimage                           \
+	--rootpath "${TARGET_DIR}"     \
+	--tmppath "${GENIMAGE_TMP}"    \
+	--inputpath "${BINARIES_DIR}"  \
+	--outputpath "${BINARIES_DIR}" \
+	--config "${GENIMAGE_CFG}"
+
+exit $?
board/raspberrypi3/readme.txt new file +64 -0

64 lines not on this page · raw message

configs/raspberrypi3_defconfig new file +36 -0
new file mode 100644
index 0000000..80ce908
@@ -0,0 +1,36 @@
+BR2_arm=y
+BR2_cortex_a7=y
+BR2_ARM_EABIHF=y
+BR2_ARM_FPU_NEON_VFPV4=y
+
+BR2_TOOLCHAIN_BUILDROOT_CXX=y
+
+BR2_SYSTEM_DHCP="eth0"
+
+# Linux headers same as kernel, a 4.1 series
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_1=y
+
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_GIT=y
+BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/raspberrypi/linux.git"
+BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="20fe468af4bb40fec0f81753da4b20a8bfc259c9"
+BR2_LINUX_KERNEL_DEFCONFIG="bcm2709"
+
+# Build the DTB from the kernel sources
+BR2_LINUX_KERNEL_DTS_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2710-rpi-3-b"
+
+BR2_PACKAGE_RPI_FIRMWARE=y
+# BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS is not set
+
+# Required tools to create the SD image
+BR2_PACKAGE_HOST_DOSFSTOOLS=y
+BR2_PACKAGE_HOST_GENIMAGE=y
+BR2_PACKAGE_HOST_MTOOLS=y
+
+# Filesystem / image
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_4=y
+# BR2_TARGET_ROOTFS_TAR is not set
+BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi3/post-build.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi3/post-image.sh"
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 Preliminary support for Raspberry Pi 3.

Hi Ubaldo,

I updated a bit your defconfig (see below), and I was able to boot the generated image. Weirdly I get no getty on the HDMI, just the kernel boot log. Have I done something wrong ?

Regards,
Ben.

Quoted 170 lines · On Wed, 20 Apr 2016 11:04:00 +0000 Ubaldo Porcheddu <[email protected]> wrote:
---
 board/raspberrypi3/genimage-raspberrypi3.cfg | 30 +++++++++++++
 board/raspberrypi3/post-build.sh             |  9 ++++
 board/raspberrypi3/post-image.sh             | 22 ++++++++++
 board/raspberrypi3/readme.txt                | 64

++++++++++++++++++++++++++++
configs/raspberrypi3_defconfig | 36 ++++++++++++++++ 5
files changed, 161 insertions(+) create mode 100644 board/raspberrypi3/genimage-raspberrypi3.cfg create mode 100755 board/raspberrypi3/post-build.sh create mode 100755 board/raspberrypi3/post-image.sh create mode 100644 board/raspberrypi3/readme.txt create mode 100644 configs/raspberrypi3_defconfig

(quoted diff) +0 -0

b/board/raspberrypi3/genimage-raspberrypi3.cfg new file mode 100644 index 0000000..7ba89c5

board/raspberrypi3/genimage-raspberrypi3.cfg new file +30 -0
@@ -0,0 +1,30 @@
+image boot.vfat {
+  vfat {
+    files = {
+      "bcm2710-rpi-3-b.dtb",
+      "rpi-firmware/bootcode.bin",
+      "rpi-firmware/cmdline.txt",
+      "rpi-firmware/config.txt",
+      "rpi-firmware/fixup.dat",
+      "rpi-firmware/start.elf",
+      "kernel-marked/zImage"
+    }
+  }
+  size = 32M
+}
+
+image sdcard.img {
+  hdimage {
+  }
+
+  partition boot {
+    partition-type = 0xC
+    bootable = "true"
+    image = "boot.vfat"
+  }
+
+  partition rootfs {
+    partition-type = 0x83
+    image = "rootfs.ext4"
+  }
+}
(quoted diff) +0 -0

b/board/raspberrypi3/post-build.sh new file mode 100755 index 0000000..7eae14a

board/raspberrypi3/post-build.sh new file +9 -0
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+set -u
+set -e
+
+# Add a console on tty1
+grep -qE '^tty1::' ${TARGET_DIR}/etc/inittab || \
+sed -i '/GENERIC_SERIAL/a\
+tty1::respawn:/sbin/getty -L  tty1 0 vt100 # HDMI console'

${TARGET_DIR}/etc/inittab diff --git a/board/raspberrypi3/post-image.sh b/board/raspberrypi3/post-image.sh new file mode 100755 index 0000000..73ffd65

board/raspberrypi3/post-image.sh new file +22 -0
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+BOARD_DIR="$(dirname $0)"
+BOARD_NAME="$(basename ${BOARD_DIR})"
+GENIMAGE_CFG="${BOARD_DIR}/genimage-${BOARD_NAME}.cfg"
+GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
+
+# Mark the kernel as DT-enabled
+mkdir -p "${BINARIES_DIR}/kernel-marked"
+${HOST_DIR}/usr/bin/mkknlimg "${BINARIES_DIR}/zImage" \
+	"${BINARIES_DIR}/kernel-marked/zImage"
+
+rm -rf "${GENIMAGE_TMP}"
+
+genimage                           \
+	--rootpath "${TARGET_DIR}"     \
+	--tmppath "${GENIMAGE_TMP}"    \
+	--inputpath "${BINARIES_DIR}"  \
+	--outputpath "${BINARIES_DIR}" \
+	--config "${GENIMAGE_CFG}"
+
+exit $?
(quoted diff) +0 -0

b/board/raspberrypi3/readme.txt new file mode 100644 index 0000000..dcbcffd

board/raspberrypi3/readme.txt new file +21 -0
@@ -0,0 +1,64 @@
+Raspberry Pi
+
+Intro
+=====
+
+These instructions apply to Raspberry Pi 3 version B.
+
+How to build it
+===============
+
+Configure Buildroot
+-------------------
+
+
+  $ make raspberrypi3_defconfig
+
+
+Build the rootfs
+----------------
+
+Note: you will need to have access to the network, since Buildroot

will +download the packages' sources.

board/raspberrypi3/readme.txt new file +32 -0
+
+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/
+    +-- bcm2710-rpi-3-b.dtb
+    +-- boot.vfat
+    +-- kernel-marked/zImage        [1]
+    +-- rootfs.ext4
+    +-- rpi-firmware/
+    |   +-- bootcode.bin
+    |   +-- cmdline.txt
+    |   +-- config.txt
+    |   +-- fixup.dat
+    |   `-- start.elf
+    +-- sdcard.img
+    `-- zImage
+
+[1] This is the mkknlimg DT-marked kernel.
+
+How to write the SD card
+========================
+
+Once the build process is finished you will have an image called

"sdcard.img" +in the output/images/ directory.

board/raspberrypi3/readme.txt new file +6 -0
+
+Copy the bootable "sdcard.img" onto an SD card with "dd":
+
+  $ sudo dd if=output/images/sdcard.img of=/dev/sdX
+
+Insert the SDcard into your Raspberry Pi, and power it up. Your new

system +should come up now and start two consoles: one on the serial port on +the P1 header, one on the HDMI output where you can login using a USB +keyboard.

(quoted diff) +0 -0

b/configs/raspberrypi3_defconfig new file mode 100644 index 0000000..80ce908

configs/raspberrypi3_defconfig line 2

Quoted 2 lines
configs/raspberrypi3_defconfig new file +2 -0
@@ -0,0 +1,36 @@
+BR2_arm=y
+BR2_cortex_a7=y

Raspberry3 are using A8 processors.

Quoted 4 lines
configs/raspberrypi3_defconfig new file +4 -0
+BR2_ARM_EABIHF=y
+BR2_ARM_FPU_NEON_VFPV4=y
+
+BR2_TOOLCHAIN_BUILDROOT_CXX=y

configs/raspberrypi3_defconfig line 16

Quoted 10 lines
configs/raspberrypi3_defconfig new file +10 -0
+
+BR2_SYSTEM_DHCP="eth0"
+
+# Linux headers same as kernel, a 4.1 series
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_1=y
+
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_GIT=y
+BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/raspberrypi/linux.git"
+BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="20fe468af4bb40fec0f81753da4b20a8bfc259c9"

Better use the branch name to allow shallow clones. in this case:
"rpi-4.1.y"

Why don't you use a more recent branch ?

configs/raspberrypi3_defconfig line 17

Quoted 1 line
configs/raspberrypi3_defconfig new file +1 -0
+BR2_LINUX_KERNEL_DEFCONFIG="bcm2709"

If using the 4.4 branch, there is a defconfig for bcm2710.

Quoted 9 lines
configs/raspberrypi3_defconfig new file +9 -0
+
+# Build the DTB from the kernel sources
+BR2_LINUX_KERNEL_DTS_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2710-rpi-3-b"
+
+BR2_PACKAGE_RPI_FIRMWARE=y
+# BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS is not set
+
+# Required tools to create the SD image

configs/raspberrypi3_defconfig line 36

Quoted 10 lines
configs/raspberrypi3_defconfig new file +10 -0
+BR2_PACKAGE_HOST_DOSFSTOOLS=y
+BR2_PACKAGE_HOST_GENIMAGE=y
+BR2_PACKAGE_HOST_MTOOLS=y
+
+# Filesystem / image
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_4=y
+# BR2_TARGET_ROOTFS_TAR is not set
+BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi3/post-build.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi3/post-image.sh"

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20160422/dc37e902/attachment.asc>

#2 lore raw

PATCH 1/1 Preliminary support for Raspberry Pi 3.

Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Beno?t" == Beno?t Allard <[email protected]> writes:

Hi Ubaldo,
I updated a bit your defconfig (see below), and I was able to boot the generated image. Weirdly I get no getty on the HDMI, just the kernel boot log. Have I done something wrong ?

Quoted 6 lines

configs/raspberrypi3_defconfig line 2

Quoted 4 lines

+++ b/configs/raspberrypi3_defconfig

configs/raspberrypi3_defconfig new file +2 -0
@@ -0,0 +1,36 @@
+BR2_arm=y
+BR2_cortex_a7=y

Raspberry3 are using A8 processors.

Not it uses A53, which is only selectable when building in 64bit mode. The A7 is afaik the closest 32bit equivalent, so that's ok.

Quoted 9 lines
Quoted 9 lines
configs/raspberrypi3_defconfig new file +9 -0
+BR2_ARM_EABIHF=y
+BR2_ARM_FPU_NEON_VFPV4=y
+
+BR2_TOOLCHAIN_BUILDROOT_CXX=y
+
+BR2_SYSTEM_DHCP="eth0"
+
+# Linux headers same as kernel, a 4.1 series
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_1=y
Quoted 8 lines

configs/raspberrypi3_defconfig line 16

Quoted 5 lines
configs/raspberrypi3_defconfig new file +5 -0
+
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_GIT=y
+BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/raspberrypi/linux.git"
+BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="20fe468af4bb40fec0f81753da4b20a8bfc259c9"

Better use the branch name to allow shallow clones. in this case:
"rpi-4.1.y"

No, please only use tags or git hashes, not branches. We want builds to be reproducable, and new commits may get pushed to the branch in the future, breaking that.

Quoted 1 line

Why don't you use a more recent branch ?

Yes, that sounds odd.

Signature · 1 line
Bye, Peter Korsgaard
#3 lore raw

PATCH 1/1 Preliminary support for Raspberry Pi 3.

In reply to Ubaldo Porcheddu
Quoted 15 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Ubaldo" == Ubaldo Porcheddu <[email protected]> writes:

---
 board/raspberrypi3/genimage-raspberrypi3.cfg | 30 +++++++++++++
 board/raspberrypi3/post-build.sh             |  9 ++++
 board/raspberrypi3/post-image.sh             | 22 ++++++++++
 board/raspberrypi3/readme.txt                | 64 ++++++++++++++++++++++++++++
 configs/raspberrypi3_defconfig               | 36 ++++++++++++++++
 5 files changed, 161 insertions(+)
 create mode 100644 board/raspberrypi3/genimage-raspberrypi3.cfg
 create mode 100755 board/raspberrypi3/post-build.sh
 create mode 100755 board/raspberrypi3/post-image.sh
 create mode 100644 board/raspberrypi3/readme.txt
 create mode 100644 configs/raspberrypi3_defconfig

Thanks. Aren't these basically identical to the rpi1/rpi2 variants (except for the genimage script)? Please rework it to simply add a raspberrypi3 symlink like we do for raspberrypi2.

Signature · 1 line
Bye, Peter Korsgaard
#4 lore raw

PATCH 1/1 Preliminary support for Raspberry Pi 3.

Hello,

Quoted 3 lines · Peter Korsgaard

Thanks. Aren't these basically identical to the rpi1/rpi2 variants (except for the genimage script)? Please rework it to simply add a raspberrypi3 symlink like we do for raspberrypi2.

Why do we even have a symlink? If all files are the same, why aren't we referencing board/raspberrypi/ files from the raspberrypi2_defconfig?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#5 lore raw

PATCH 1/1 Preliminary support for Raspberry Pi 3.

Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Hello,

Quoted 3 lines · Peter Korsgaard

Thanks. Aren't these basically identical to the rpi1/rpi2 variants (except for the genimage script)? Please rework it to simply add a raspberrypi3 symlink like we do for raspberrypi2.

Why do we even have a symlink? If all files are the same, why aren't we referencing board/raspberrypi/ files from the raspberrypi2_defconfig?

Because of some magic in post-image.sh that looks at the dirname to figure out what genimage configuration to use:

BOARD_DIR="$(dirname $0)" BOARD_NAME="$(basename ${BOARD_DIR})" GENIMAGE_CFG="${BOARD_DIR}/genimage-${BOARD_NAME}.cfg"

According to git blame this comes from 8dd797a0549869 that you applied ;)

We could also solve it by passing an argument to the script using BR2_ROOTFS_POST_SCRIPT_ARGS (or the generic genimage support stuff).

Signature · 2 lines
Venlig hilsen,
Peter Korsgaard 
#6 lore raw

PATCH 1/1 Preliminary support for Raspberry Pi 3.

Hello,

Quoted 9 lines · Peter Korsgaard

Because of some magic in post-image.sh that looks at the dirname to figure out what genimage configuration to use:

BOARD_DIR="$(dirname $0)" BOARD_NAME="$(basename ${BOARD_DIR})" GENIMAGE_CFG="${BOARD_DIR}/genimage-${BOARD_NAME}.cfg"

According to git blame this comes from 8dd797a0549869 that you applied ;)

Hum, since like my memory starts failing :-/

Thanks for reminding me. Seems a bit tricky, but OK, that's probably the easiest solution.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#7 lore raw

PATCH 1/1 Preliminary support for Raspberry Pi 3.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

According to git blame this comes from 8dd797a0549869 that you applied ;)

Hum, since like my memory starts failing :-/

It's called having kids :P

Quoted 2 lines

Thanks for reminding me. Seems a bit tricky, but OK, that's probably the easiest solution.

Yeah, I don't think it's too bad.

Signature · 2 lines
Venlig hilsen,
Peter Korsgaard