Skip to content

Commit

Permalink
Merge pull request rauc#88 from leon-anavi/kirkstone
Browse files Browse the repository at this point in the history
meta-rauc-beaglebone: BeagleBone Black for Kirkstone
  • Loading branch information
leon-anavi authored Mar 29, 2024
2 parents 0b0d803 + feffc80 commit a24bd25
Show file tree
Hide file tree
Showing 22 changed files with 547 additions and 0 deletions.
96 changes: 96 additions & 0 deletions meta-rauc-beaglebone/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
This README file contains information on the contents of the meta-rauc-beaglebone layer.

Please see the corresponding sections below for details.

Dependencies
============

* URI: git://git.openembedded.org/openembedded-core
* URI: https://github.com/rauc/meta-rauc.git
* URI: https://git.yoctoproject.org/poky/

Patches
=======

Please submit any patches against the meta-rauc-beaglebone layer via GitHub
pull request on https://github.com/rauc/meta-rauc-community.

Maintainer: Leon Anavi <leon.anavi@konsulko.com>

Disclaimer
==========

Note that this is just an example layer that shows a few possible configuration
options how RAUC can be used.
Actual requirements may differ from project to projects and will probably need
a much different RAUC/bootloader/system configuration.

Also note that this layer is for demo purpose only and does not care about
migratability between different layer revision.

I. Adding the meta-rauc-beaglebone layer to your build
=======================================================

Run 'bitbake-layers add-layer meta-rauc-beaglebone'

II. Build The Demo System
=========================

::

$ source oe-init-build-env

Set the ``MACHINE`` to the model you intend to build for. E.g.::

MACHINE = "beaglebone-yocto"

Add configuration required for meta-rauc-beaglebone to your local.conf::

# Settings for meta-rauc-beaglebone
IMAGE_INSTALL:append = " rauc"
IMAGE_FSTYPES:append = " ext4"
IMAGE_BOOT_FILES:append = " boot.scr"
WKS_FILE = "beaglebone-yocto-dual.wks.in"

Make sure either your distro (recommended) or your local.conf have ``rauc``
``DISTRO_FEATURE`` enabled::

DISTRO_FEATURES:append = " rauc"

It is also recommended, but not strictly necessary, to enable 'systemd'::

INIT_MANAGER = "systemd"

Build the minimal system image::

$ bitbake core-image-minimal

III. Flash & Run The Demo System
================================

You can either flash using bmaptool (recommended)::

$ bmaptool copy /path/to/core-image-minimal-beaglebone-yocto.wic.xz /dev/sdX

or bzcat::

$ bzcat /path/to/core-image-minimal-beaglebone-yocto.wic.xz | dd of=/dev/sdb

Then power-on the board and log in.
To see that RAUC is configured correctly and can interact with the bootloader,
run::

# rauc status

IV. Build and Install The Demo Bundle
=====================================

To build the bundle, run::

$ bitbake update-bundle

Copy the generated bundle to the target system via nc, scp or an attached USB stick.

On the target, you can then install the bundle::

# rauc install /path/to/bundle.raucb
1 change: 1 addition & 0 deletions meta-rauc-beaglebone/classes/rauc-integration.bbclass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OVERRIDES .= "${@bb.utils.contains('DISTRO_FEATURES', 'rauc', ':rauc-integration', '', d)}"
13 changes: 13 additions & 0 deletions meta-rauc-beaglebone/conf/layer.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# We have a conf and classes directory, add to BBPATH
BBPATH .= ":${LAYERDIR}"

# We have recipes-* directories, add to BBFILES
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
${LAYERDIR}/recipes-*/*/*.bbappend"

BBFILE_COLLECTIONS += "meta-rauc-beaglebone"
BBFILE_PATTERN_meta-rauc-beaglebone = "^${LAYERDIR}/"
BBFILE_PRIORITY_meta-rauc-beaglebone = "6"

LAYERDEPENDS_meta-rauc-beaglebone = "core rauc yoctobsp"
LAYERSERIES_COMPAT_meta-rauc-beaglebone = "kirkstone nanbield"
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From f03d92ceeb8ac190a842f24c51669f46b03c1aed Mon Sep 17 00:00:00 2001
From: Leon Anavi <leon.anavi@konsulko.com>
Date: Tue, 23 Jan 2024 12:06:48 +0000
Subject: [PATCH] am335x_evm_defconfig: RAUC

Signed-off-by: Leon Anavi <leon.anavi@konsulko.com>
---
configs/am335x_evm_defconfig | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig
index 4dc5d0fe34..450933641f 100644
--- a/configs/am335x_evm_defconfig
+++ b/configs/am335x_evm_defconfig
@@ -9,7 +9,7 @@ CONFIG_DISTRO_DEFAULTS=y
CONFIG_SPL_LOAD_FIT=y
# CONFIG_USE_SPL_FIT_GENERATOR is not set
CONFIG_OF_BOARD_SETUP=y
-CONFIG_BOOTCOMMAND="run findfdt; run init_console; run finduuid; run distro_bootcmd"
+CONFIG_BOOTCOMMAND="load mmc 0:1 $loadaddr boot.scr; source $loadaddr"
CONFIG_LOGLEVEL=3
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_ARCH_MISC_INIT=y
@@ -31,7 +31,7 @@ CONFIG_CMD_SPL_NAND_OFS=0x00080000
CONFIG_SYS_I2C_EEPROM_ADDR_LEN=2
# CONFIG_CMD_FLASH is not set
CONFIG_CMD_NAND=y
-# CONFIG_CMD_SETEXPR is not set
+CMD_SETEXPR=y
CONFIG_BOOTP_DNS2=y
CONFIG_CMD_MTDPARTS=y
CONFIG_MTDIDS_DEFAULT="nand0=nand.0"
@@ -101,3 +101,8 @@ CONFIG_WDT=y
CONFIG_DYNAMIC_CRC_TABLE=y
CONFIG_RSA=y
CONFIG_LZO=y
+CONFIG_ENV_EXT4_INTERFACE="mmc"
+CONFIG_ENV_EXT4_DEVICE_AND_PART="0:1"
+CONFIG_ENV_EXT4_FILE="/boot/uboot.env"
+
+
--
2.39.2

61 changes: 61 additions & 0 deletions meta-rauc-beaglebone/recipes-bsp/u-boot/files/boot.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
run findfdt;

test -n "${BOOT_ORDER}" || env set BOOT_ORDER "A B"
test -n "${BOOT_A_LEFT}" || env set BOOT_A_LEFT 3
test -n "${BOOT_B_LEFT}" || env set BOOT_B_LEFT 3

env set bootpart
env set bootdev
env set raucslot

for BOOT_SLOT in "${BOOT_ORDER}"; do
if test "x${bootpart}" != "x"; then
# stop checking after selecting a slot

elif test "x${BOOT_SLOT}" = "xA"; then
if itest ${BOOT_A_LEFT} -gt 0; then
setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1
echo "Booting RAUC slot A"

setenv bootpart "/dev/mmcblk0p2"
setenv raucslot "A"
setenv bootdev "mmc 0:2"
fi

elif test "x${BOOT_SLOT}" = "xB"; then
if itest ${BOOT_B_LEFT} -gt 0; then
setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1
echo "Booting RAUC slot B"

setenv bootpart "/dev/mmcblk0p3"
setenv raucslot "B"
setenv bootdev "mmc 0:3"
fi
fi
done


if test -n "${bootpart}"; then
setenv bootargs "console=${console} ${optargs} root=${bootpart} rw rootfstype=ext4 rootwait fixrtc rauc.slot=${raucslot}"
saveenv
else
echo "No valid RAUC slot found. Resetting attempts to 3"
setenv BOOT_A_LEFT 3
setenv BOOT_B_LEFT 3
saveenv
reset
fi


if mmc dev 0; then

if test ! -e mmc 0:1 ${bootdir}/uboot.env; then saveenv; fi;

part uuid ${bootdev} uuid
load mmc 0:1 ${loadaddr} ${bootdir}/zImage
load mmc 0:1 ${fdtaddr} ${bootdir}/${fdtfile}
bootz ${loadaddr} - ${fdtaddr}
else
echo "Could not find mmc 0"
reset
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/boot/uboot.env 0x0000 0x20000
18 changes: 18 additions & 0 deletions meta-rauc-beaglebone/recipes-bsp/u-boot/u-boot_%.bbappend
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"

SRC_URI += " \
file://0001-am335x_evm_defconfig-rauc.patch \
file://fw_env.config \
file://boot.cmd \
"

# The UBOOT_ENV_SUFFIX and UBOOT_ENV are mandatory in order to run the
# uboot-mkimage command from poky/meta/recipes-bsp/u-boot/u-boot.inc
UBOOT_ENV_SUFFIX = "scr"
UBOOT_ENV = "boot"

do_install:append() {
install -d ${D}${sysconfdir}
install -m 0644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}/fw_env.config
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"

# Add a mount point for a shared data partition
dirs755 += "/data"
12 changes: 12 additions & 0 deletions meta-rauc-beaglebone/recipes-core/base-files/files/fstab
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# stock fstab - you probably want to override this with a machine specific one

/dev/root / auto defaults 1 1
proc /proc proc defaults 0 0
devpts /dev/pts devpts mode=0620,ptmxmode=0666,gid=5 0 0
tmpfs /run tmpfs mode=0755,nodev,nosuid,strictatime 0 0
tmpfs /var/volatile tmpfs defaults 0 0

# uncomment this if your device has a SD/MMC/Transflash slot
#/dev/mmcblk0p1 /media/card auto defaults,sync,noauto 0 0

/dev/mmcblk0p1 /boot vfat defaults 0 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 2 (0x2)
Signature Algorithm: sha256WithRSAEncryption
Issuer: O=Test Org, CN=Test Org rauc CA Development
Validity
Not Before: Jan 1 00:00:00 1970 GMT
Not After : Dec 31 23:59:59 9999 GMT
Subject: O=Test Org, CN=Test Org Development-1
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
RSA Public-Key: (2048 bit)
Modulus:
00:ac:2b:0f:05:02:d0:bb:b0:47:05:36:71:3c:20:
0e:a7:76:8d:75:c1:23:5e:6c:7a:2d:94:ff:3c:17:
d8:0b:44:48:2a:82:03:92:c5:fd:33:76:0c:42:cf:
4d:8a:c9:47:7f:af:52:7c:15:6c:3b:e7:60:d1:04:
97:24:7b:07:1f:56:7d:6c:3f:31:e8:f9:36:7b:33:
5b:cf:54:ea:37:98:a6:b1:9a:1d:da:96:a1:07:14:
9c:15:80:4d:db:0c:03:86:ce:c7:3d:72:57:a2:da:
a0:c0:8c:b2:9a:a0:6a:e5:b8:5f:52:d2:f6:27:ca:
48:f4:e3:86:eb:be:24:93:6a:af:60:68:7f:09:3b:
81:96:ce:85:0c:63:93:d8:fa:91:dc:50:2e:77:bb:
bc:38:42:e9:86:d8:ac:33:dd:e6:d4:37:69:e3:01:
8d:21:8f:a9:4a:7f:15:a5:aa:a9:be:fc:36:93:a4:
10:0c:18:33:30:06:7f:1c:13:b3:a9:c6:57:d7:6b:
96:45:15:e7:f5:8f:3d:48:e0:08:46:4f:7f:ef:14:
77:95:25:25:9b:14:21:84:25:eb:37:0b:01:48:e6:
f5:c1:8b:61:c6:cb:8c:6b:a7:d8:d2:f9:31:e3:80:
3f:78:ea:6a:41:6c:5d:4d:83:a6:54:0d:5b:c2:0e:
f6:ef
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Subject Key Identifier:
89:4C:FE:8A:60:4D:C9:6D:F7:A8:C0:04:49:7F:AA:05:92:29:17:FB
X509v3 Authority Key Identifier:
keyid:44:0C:AF:4A:74:B4:C7:65:02:B2:95:F1:91:7C:A3:CC:E6:3E:99:E8
DirName:/O=Test Org/CN=Test Org rauc CA Development
serial:01

X509v3 Basic Constraints:
CA:FALSE
Signature Algorithm: sha256WithRSAEncryption
2c:d2:30:68:f5:84:52:1e:cf:ed:0d:fc:e7:02:69:0b:3b:f6:
c3:77:00:12:1d:2d:d0:8f:49:9e:5c:f1:00:7b:1d:4f:d5:a9:
46:a5:df:54:90:50:b4:8f:8e:ba:4b:2d:82:74:eb:5b:a8:f5:
45:7b:77:73:b1:9b:32:93:15:c0:5c:02:2a:ed:b0:1e:bb:d8:
4e:41:17:20:af:04:46:21:20:7b:86:9f:32:ab:54:71:26:e8:
0b:75:12:9c:63:53:4f:54:db:a7:f9:b2:fa:e9:ee:4a:9d:80:
ba:ae:3f:eb:ef:10:11:2d:4f:5a:34:fb:8b:45:10:63:0b:f8:
af:f3:8b:24:21:2a:e0:0b:44:38:44:b5:9d:6e:8a:ff:1f:bf:
6e:44:21:22:ec:8a:8d:73:63:e5:df:1a:ec:2a:64:1f:97:f9:
5c:3a:25:7f:03:80:4c:db:99:5e:f9:7d:2b:f1:d0:97:4d:95:
6f:29:47:7b:3f:29:e3:96:25:b0:1c:f1:0b:8b:8b:ba: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3Qj0meXPEA
ex1P1alGpd9UkFC0j466Sy2CdOtbqPVFe3dzsZsykxXAXAIq7bAeu9hOQRcgrwRG
ISB7hp8yq1RxJugLdRKcY1NPVNun+bL66e5KnYC6rj/r7xARLU9aNPuLRRBjC/iv
84skISrgC0Q4RLWdbor/H79uRCEi7IqNc2Pl3xrsKmQfl/lcOiV/A4BM25le+X0r
8dCXTZVvKUd7PynjliWwHPELi4u63js/QC69MWjqqY/cyQki33ZpCF1dpAligCCD
nr3UpjXul1BmOWJmGy518m3nBq5nX0tjXFLnXd3JDIYr
-----END CERTIFICATE-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCsKw8FAtC7sEcF
NnE8IA6ndo11wSNebHotlP88F9gLREgqggOSxf0zdgxCz02KyUd/r1J8FWw752DR
BJckewcfVn1sPzHo+TZ7M1vPVOo3mKaxmh3alqEHFJwVgE3bDAOGzsc9clei2qDA
jLKaoGrluF9S0vYnykj044brviSTaq9gaH8JO4GWzoUMY5PY+pHcUC53u7w4QumG
2Kwz3ebUN2njAY0hj6lKfxWlqqm+/DaTpBAMGDMwBn8cE7OpxlfXa5ZFFef1jz1I
4AhGT3/vFHeVJSWbFCGEJes3CwFI5vXBi2HGy4xrp9jS+THjgD946mpBbF1Ng6ZU
DVvCDvbvAgMBAAECggEASphBYq9sltVyf/ytpRpSnxYLhmiPFXs0mIlE6Nl/3qnQ
BrLcL3yfDuvntg6xjx9UXistNtvlUDMYzJcLkV/InzhPEVZ0HnfTth9zeOpWrI30
M2EN7EZ1MGcqlVpI4U5cPM1cn+/proLBQYv0WnCEwFFY477JrkXDxG7MZ1mz6TaL
IGcCCIUu1BxECngQ344eaKrSR5F2MtlxAl19Pt5QSPfmuMdmElrK6RtBjnKrDu1K
fe6DCfObZ3nbG2fhFV4uTxhlTC9lUmfTQMKR79rLmHNKnbMx74kFNvy3XlT2l35I
ZVfRMLPWph7yMom9v/Im3Q70uhJ1lxyqbbl/DFZVmQKBgQDVo19SqR/QeDIxPIPn
XvVWzo5ml3KO/dVxA8sok6twr+G7yUeIUnuauYFA/tX/FS32azFRa/7GjUfoTx3q
GHK43TBCMyEt0we6WwZb+FkWa/b/RBoyD/audrpmgDDi1+fXPs8bBvoO8/oju20D
I6wOjSovcIMaeLo/+u3U6ShNQwKBgQDOTpoGMsQzXchZfDmxL61h3j4Gtjrl4BpU
WhAkJ9U2BRpL8NSZLErn5ik8MwgK2ut+YdU7aogI0D6Gc+4zZoJDEbhhmPD9cprv
LMyfAKoisR01OyU57mMSGQq0dfjmK6PfYJdX5sQJGkMFptNAJLTDoYtmXItSICoY
1j5KTvwe5QKBgGytxmErjfakHoxzh3pdERuOylwgMPPS5xCt6FyE+pLBtmisFQqh
QyXLtpgUy1IPOSmBED6mXJ4u4uSn0sTymPG3+8PBdOB12RmREqQYq2E/nQ/wWg8b
ldbcqShZkATl5pfV6M+L9gtDS/1/bA5LyExCvbISX29I+R5xDSnhTlI3AoGBAJRK
VVXtOa/+UhtYOpPMxGCbgZQLemxvWB2XmxCR/SRWKJ+7XOU4vCLSAoO93qMG1szB
/6Y0ndFP9hFo1SfnH+ybmR+18ksLDKisV+xWavSCwI7Zk5l/a4C/tT0fqyeu6JyQ
bliFjBVK5i/yyNfLSo9v16ZdENuYOQofPSjmezytAoGBALhwvtzgqvqGSXID2w5N
ullK8ny3WRa1o5DLXuMV19CvknmrN/zmmjQLblKkdp9VBb7uo8czon+qL1ZZyywC
W2BmHfGMPUyQHux4btsdJhlWcS7z7aYXM9QWiKlI+EKLHLILYk+LPIEf85sUcOZV
eCBpViT7fv2iv/0L+mzjWtLA
-----END PRIVATE KEY-----
19 changes: 19 additions & 0 deletions meta-rauc-beaglebone/recipes-core/bundles/update-bundle.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
DESCRIPTION = "RAUC bundle generator"

inherit bundle

LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"


RAUC_BUNDLE_FORMAT = "verity"

RAUC_BUNDLE_COMPATIBLE = "BeagleBoneBlack"
RAUC_BUNDLE_VERSION = "v20240123"
RAUC_BUNDLE_DESCRIPTION = "RAUC demonstration bundle"
RAUC_BUNDLE_SLOTS = "rootfs"
RAUC_SLOT_rootfs = "core-image-minimal"
RAUC_SLOT_rootfs[fstype] = "ext4"

RAUC_KEY_FILE = "${THISDIR}/files/development-1.key.pem"
RAUC_CERT_FILE = "${THISDIR}/files/development-1.cert.pem"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
IMAGE_FSTYPES += "wic wic.xz wic.bmap ext4"
WKS_FILE = "beaglebone-yocto-dual.wks.in"
IMAGE_BOOT_FILES += " boot.scr"

# Optimizations for RAUC adaptive method 'block-hash-index'
# rootfs image size must to be 4K-aligned
IMAGE_ROOTFS_ALIGNMENT = "4"
# ext4 block and inode size should be set to 4K
EXTRA_IMAGECMD:ext4 = "-i 4096 -b 4096"
Loading

0 comments on commit a24bd25

Please sign in to comment.