Skip to content

Commit 59921e0

Browse files
committed
meta-mender-raspberrypi: initial support for Raspberry Pi boards
Note that by aligning bootfiles layout to mender requirements, and that is that .dtb and Linux kernel should be in ${mender_uboot_root} we no longer support .dtb fixup by boot firmware. To further explain a bit, raspberrypis`s have a boot firmware that loads an image (Linux/u-boot) and .dtb file. DTB file is expected to be in ${mender_uboot_root} by boot firmware. Boot firmware parses a configuration (see [1]) file at start-up and applies some .dtb "patches" and DTB overlays depending on configuration. Above is acceptable since default configuration works just fine in most cases. Also see [2], regarding how "DTB patching" happens. [1]. https://github.com/Evilpaul/RPi-config/blob/master/config.txt [2]. raspberrypi/linux#1732 Signed-off-by: Mirza Krak <mirza.krak@gmail.com>
1 parent 0896339 commit 59921e0

File tree

12 files changed

+141
-0
lines changed

12 files changed

+141
-0
lines changed

meta-mender-raspberrypi/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# meta-mender-raspberrypi
2+
3+
This Yocto layers contains recipes which enables support of building Mender client for Raspberry Pi boards.
4+
5+
**NOTE!**. To be able to support update of Linux kernel and DTB these are installed to `/boot` on rootfs. This breaks support of user configurations based on `config.txt` because the Raspberry Pi boot firmware requires that the DTB file is in the same partition as the boot firmware files (mmcblk0p1). Boot firmware normally patches the DTB file based on configurations in `config.txt`.
6+
7+
Above should not pose any problems if you do not require any changes in `config.txt` and the default configuration certainly is enough to run Mender client.
8+
9+
## Dependencies
10+
11+
This layer depends on:
12+
13+
URI: git://git.yoctoproject.org/meta-raspberrypi
14+
branch: master
15+
revision: HEAD
16+
17+
in addition to `meta-mender` dependencies.
18+
19+
## Build instructions
20+
21+
- Read [the Mender documentation on Building a Mender Yocto image](https://docs.mender.io/Artifacts/Building-Mender-Yocto-image) for Mender specific configuration.
22+
- Set MACHINE to one of the following
23+
- raspberrypi
24+
- raspberrypi0
25+
- raspberrypi2
26+
- raspberrypi3
27+
- Add following to your local.conf (including configuration required by meta-mender-core)
28+
29+
KERNEL_IMAGETYPE = "uImage"
30+
31+
MENDER_PARTITION_ALIGNMENT_MB = "4"
32+
MENDER_BOOT_PART_SIZE_MB = "40"
33+
34+
IMAGE_DEPENDS_sdimg += " bcm2835-bootfiles"
35+
36+
# raspberrypi files aligned with mender layout requirements
37+
IMAGE_BOOT_FILES_append = " boot.scr u-boot.bin;${SDIMG_KERNELIMAGE}"
38+
IMAGE_INSTALL_append = " kernel-image kernel-devicetree"
39+
40+
- Run `bitbake <image name>`
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Board specific layer configuration for meta-mender
2+
# Copyright 2016 Mirza Krak
3+
4+
# We have a conf and classes directory, add to BBPATH
5+
BBPATH .= ":${LAYERDIR}"
6+
7+
# We have recipes-* directories, add to BBFILES
8+
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
9+
${LAYERDIR}/recipes-*/*/*.bbappend"
10+
11+
BBFILE_COLLECTIONS += "mender-raspberrypi"
12+
BBFILE_PATTERN_mender-raspberrypi = "^${LAYERDIR}/"
13+
BBFILE_PRIORITY_mender-raspberrypi = "6"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
do_deploy_append() {
3+
# Recently the default clock rate for uart changed to 48 MHz. This is
4+
# setup by boot firmware. This update has not been aligned in u-boot nor in
5+
# Linux yet.
6+
#
7+
# Override the default with the previous default which is 3 MHz. This
8+
# workaround can be dropped once the configuration aligns upstream.
9+
sed -i '/#init_uart_clock/ c\init_uart_clock=3000000' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
run mender_setup
2+
setenv fdtfile bcm2708-rpi-b.dtb
3+
setenv bootargs earlyprintk console=tty0 console=ttyAMA0 root=${mender_kernel_root} rootfstype=ext4 rootwait noinitrd
4+
mmc dev ${mender_uboot_dev}
5+
load ${mender_uboot_root} ${kernel_addr_r} /boot/uImage
6+
load ${mender_uboot_root} ${fdt_addr_r} /boot/${fdtfile}
7+
bootm ${kernel_addr_r} - ${fdt_addr_r}
8+
run mender_try_to_recover
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
run mender_setup
2+
setenv fdtfile bcm2708-rpi-b.dtb
3+
setenv bootargs earlyprintk console=tty0 console=ttyAMA0 root=${mender_kernel_root} rootfstype=ext4 rootwait noinitrd
4+
mmc dev ${mender_uboot_dev}
5+
load ${mender_uboot_root} ${kernel_addr_r} /boot/uImage
6+
load ${mender_uboot_root} ${fdt_addr_r} /boot/${fdtfile}
7+
bootm ${kernel_addr_r} - ${fdt_addr_r}
8+
run mender_try_to_recover
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
run mender_setup
2+
setenv fdtfile bcm2709-rpi-2-b.dtb
3+
setenv bootargs earlyprintk console=tty0 console=ttyAMA0 root=${mender_kernel_root} rootfstype=ext4 rootwait noinitrd
4+
mmc dev ${mender_uboot_dev}
5+
load ${mender_uboot_root} ${kernel_addr_r} /boot/uImage
6+
load ${mender_uboot_root} ${fdt_addr_r} /boot/${fdtfile}
7+
bootm ${kernel_addr_r} - ${fdt_addr_r}
8+
run mender_try_to_recover
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
run mender_setup
2+
setenv fdtfile bcm2710-rpi-3-b.dtb
3+
setenv bootargs earlyprintk console=tty0 console=ttyAMA0 root=${mender_kernel_root} rootfstype=ext4 rootwait noinitrd
4+
mmc dev ${mender_uboot_dev}
5+
load ${mender_uboot_root} ${kernel_addr_r} /boot/uImage
6+
load ${mender_uboot_root} ${fdt_addr_r} /boot/${fdtfile}
7+
bootm ${kernel_addr_r} - ${fdt_addr_r}
8+
run mender_try_to_recover
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FILESEXTRAPATHS_prepend_rpi := "${THISDIR}/files:"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
From 3267334937464b9c84b812f20fb12cab8b8dd0d5 Mon Sep 17 00:00:00 2001
2+
From: Mirza Krak <mirza.krak@gmail.com>
3+
Date: Sun, 30 Oct 2016 21:39:10 +0100
4+
Subject: [PATCH 1/1] CONFIGS: rpi: enable mender.io requirements
5+
6+
Which are CONFIG_BOOTCOUNT_ENV and CONFIG_BOOTCOUNT_LIMIT.
7+
8+
Mender.io also requires that FAT_ENV_INTERFACE, FAT_ENV_DEVICE_AND_PART
9+
and FAT_ENV_FILE are not present in the configuration.
10+
---
11+
include/configs/rpi-common.h | 5 ++---
12+
1 file changed, 2 insertions(+), 3 deletions(-)
13+
14+
diff --git a/include/configs/rpi-common.h b/include/configs/rpi-common.h
15+
index 2c3b026..505a2fe 100644
16+
--- a/include/configs/rpi-common.h
17+
+++ b/include/configs/rpi-common.h
18+
@@ -107,15 +107,14 @@
19+
/* Environment */
20+
#define CONFIG_ENV_SIZE SZ_16K
21+
#define CONFIG_ENV_IS_IN_FAT
22+
-#define FAT_ENV_INTERFACE "mmc"
23+
-#define FAT_ENV_DEVICE_AND_PART "0:1"
24+
-#define FAT_ENV_FILE "uboot.env"
25+
#define CONFIG_FAT_WRITE
26+
#define CONFIG_ENV_VARS_UBOOT_CONFIG
27+
#define CONFIG_SYS_LOAD_ADDR 0x1000000
28+
#define CONFIG_CONSOLE_MUX
29+
#define CONFIG_SYS_CONSOLE_IS_IN_ENV
30+
#define CONFIG_PREBOOT "usb start"
31+
+#define CONFIG_BOOTCOUNT_ENV
32+
+#define CONFIG_BOOTCOUNT_LIMIT
33+
34+
/* Shell */
35+
#define CONFIG_SYS_MAXARGS 16
36+
--
37+
2.1.4
38+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require u-boot-raspberrypi.inc

0 commit comments

Comments
 (0)