-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial Raspberry Pi 5 support (#2914)
* Add initial Raspberry Pi 5 buildroot config * Add machine-id support via cmdline.txt * Add new entry if entry is missing * Don't overwrite cmdline.txt when adding machine-id Use sed to append the new cmdline parameter to the first line. * Skeleton script for RAUC custom bootloader interface * Deploy kernel/device-tree into a RAUC slot specific directory This allows us to use the os_prefix feature to switch between slot A and B. Compared to the boot_partition option, this option allows to use a shared config.txt and cmdline.txt, which makes it more like how HAOS currently works on other Raspberry Pis. * Deploy new kernel/device-tree to correct slot on installation * Increase boot size to 128MB This makes sure we can store up to three kernels (slot A, B and an temporary one while installing the OTA update). * Initial tryboot implementation using os_prefix * Make sure to delete the old slot completely * Add Busybox xargs for tryboot bootloader script * Compare tryboot bootloader file silently * Revert "Increase boot size to 128MB" This reverts commit 7f2c69b. * Use compressed kernel * Address shellcheck * Address shellcheck issue in rauc-hook * Fix shellcheck for rpi-tryboot.sh * Do not follow source - it gets checked separately * Correctly set the slot to boot * Apply suggestions from code review Co-authored-by: Jan Čermák <[email protected]> * Drop serial console from default cmdline.txt * Resync rpi5_64_defconfig with rpi4_64_defconfig * Improve machine-id match Only match actual hexadecimal characters. * Deploy firmware overlays to OS prefix directory * Add Raspberry Pi 5 to documentation * Bump buildroot * buildroot fd1dc86f40...f13ad03408 (1): > linux: add in-tree device tree overlay support * Install device tree overlays from Kernel sources * Drop RPi RF modules for now No Raspberry Pi 5 specific device tree overlays are available, drop RPi RF mod for now. * Use Raspberry 5 specific identifiers for Supervisor/OS Agent * Bump buildroot * buildroot f13ad03408...07e08e01b2 (1): > linux: fix add in-tree device tree overlay support * Revert "Drop RPi RF modules for now" This reverts commit 46fc170. --------- Co-authored-by: Jan Čermák <[email protected]>
- Loading branch information
Showing
16 changed files
with
406 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
zram.enabled=1 zram.num_devices=3 rootwait cgroup_enable=memory fsck.repair=yes console=tty1 root=PARTUUID=8d3d53e3-6d49-4c38-8349-aff6859e82fd rootfstype=squashfs ro rauc.slot=A |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# For more options and information see | ||
# http://rptl.io/configtxt | ||
# Some settings may impact device functionality. See link above for details | ||
|
||
# Uncomment some or all of these to enable the optional hardware interfaces | ||
#dtparam=i2c_arm=on | ||
#dtparam=i2s=on | ||
#dtparam=spi=on | ||
|
||
# Enable audio (loads snd_bcm2835) | ||
dtparam=audio=on | ||
|
||
# Additional overlays and parameters are documented | ||
# /boot/firmware/overlays/README | ||
|
||
# Automatically load overlays for detected cameras | ||
camera_auto_detect=1 | ||
|
||
# Automatically load overlays for detected DSI displays | ||
display_auto_detect=1 | ||
|
||
# Automatically load initramfs files, if found | ||
auto_initramfs=1 | ||
|
||
# Enable DRM VC4 V3D driver | ||
dtoverlay=vc4-kms-v3d | ||
max_framebuffers=2 | ||
|
||
# Don't have the firmware create an initial video= setting in cmdline.txt. | ||
# Use the kernel's default instead. | ||
disable_fw_kms_setup=1 | ||
|
||
# Run in 64-bit mode | ||
arm_64bit=1 | ||
|
||
# Disable compensation for displays with overscan | ||
disable_overscan=1 | ||
|
||
# Run as fast as firmware / board allows | ||
arm_boost=1 | ||
|
||
# Use OS prefix for A/B slot (RAUC) | ||
os_prefix=slot-A/ | ||
cmdline=/cmdline.txt | ||
|
||
[cm4] | ||
# Enable host mode on the 2711 built-in XHCI USB controller. | ||
# This line should be removed if the legacy DWC2 controller is required | ||
# (e.g. for USB device mode) or if USB support is not required. | ||
otg_mode=1 | ||
|
||
[all] | ||
|
20 changes: 20 additions & 0 deletions
20
buildroot-external/board/raspberrypi/rpi5-64/hassos-hook.sh
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
# shellcheck disable=SC2155 | ||
|
||
function hassos_pre_image() { | ||
local BOOT_DATA="$(path_boot_dir)" | ||
|
||
mkdir -p "${BOOT_DATA}/slot-A/" | ||
cp "${BINARIES_DIR}"/*.dtb "${BOOT_DATA}/slot-A/" | ||
gzip --stdout "${BINARIES_DIR}"/Image > "${BOOT_DATA}/slot-A/kernel_2712.img" | ||
cp -r "${BINARIES_DIR}/overlays/" "${BOOT_DATA}/slot-A/" | ||
cp "${BINARIES_DIR}"/*.dtbo "${BOOT_DATA}/slot-A/overlays/" 2>/dev/null || true | ||
cp "${BOARD_DIR}/config.txt" "${BOOT_DATA}/config.txt" | ||
cp "${BOARD_DIR}/cmdline.txt" "${BOOT_DATA}/cmdline.txt" | ||
} | ||
|
||
|
||
function hassos_post_image() { | ||
convert_disk_image_xz | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
BOARD_ID=rpi5-64 | ||
BOARD_NAME="RaspberryPi 5 64bit" | ||
CHASSIS=embedded | ||
BOOTLOADER=tryboot | ||
KERNEL_FILE=Image | ||
BOOT_SYS=gpt | ||
BOOT_SIZE=64M | ||
BOOT_SPL=false | ||
BOOT_ENV_SIZE=0x4000 | ||
SUPERVISOR_MACHINE=raspberrypi5-64 | ||
SUPERVISOR_ARCH=aarch64 |
25 changes: 25 additions & 0 deletions
25
buildroot-external/board/raspberrypi/rpi5-64/rootfs-overlay/usr/lib/rauc/cmdline.sh
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# shellcheck shell=sh | ||
# Shell script functions to manipulate kernel cmdline | ||
|
||
# Function to get the value of a key from a command line string | ||
get_value() { | ||
key="$1" | ||
cmdline_string="$2" | ||
|
||
# Split the command line string by whitespace and then by '=' using xargs | ||
echo "$cmdline_string" | xargs -n1 | grep "^$key=" | cut -d= -f2- | ||
} | ||
|
||
# Function to set or update the value of a key in a command line string | ||
set_value() { | ||
key="$1" | ||
new_value="$2" | ||
cmdline_string="$3" | ||
|
||
# Use sed to replace the value of the key if it exists, or add a new key-value pair | ||
if echo "$cmdline_string" | grep -q "$key="; then | ||
echo "$cmdline_string" | sed "s/$key=[^ ]*/$key=$new_value/" | ||
else | ||
echo "$cmdline_string $key=$new_value" | ||
fi | ||
} |
101 changes: 101 additions & 0 deletions
101
buildroot-external/board/raspberrypi/rpi5-64/rootfs-overlay/usr/lib/rauc/rpi-tryboot.sh
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#!/bin/sh | ||
|
||
# shellcheck source=/dev/null # Our GitHub Actions tests this separately | ||
. /usr/lib/rauc/cmdline.sh | ||
|
||
# RAUC hook script for Raspberry Pi firmwaree tryboot | ||
# Meant to be usesd as a RAUC bootloader-custom-backend script. | ||
|
||
boot_dir="/mnt/boot" | ||
root_slot_a="PARTUUID=8d3d53e3-6d49-4c38-8349-aff6859e82fd" | ||
root_slot_b="PARTUUID=a3ec664e-32ce-4665-95ea-7ae90ce9aa20" | ||
|
||
case "$1" in | ||
get-primary) | ||
# Actions to be performed when getting the primary bootloader | ||
# Example: Output the path to the current primary bootloader | ||
echo "tryboot get-primary" >&2 | ||
cmdline=$(head -n1 "${boot_dir}/cmdline.txt") | ||
get_value rauc.slot "${cmdline}" | ||
;; | ||
|
||
set-primary) | ||
# Actions to be performed when setting the primary bootloader | ||
# Example: Set the specified bootloader as the primary one | ||
slot_bootname="$2" | ||
echo "tryboot set-primary $slot_bootname" >&2 | ||
cmdline=$(head -n1 "${boot_dir}/cmdline.txt") | ||
if [ "${slot_bootname}" = "A" ]; then | ||
cmdline=$(set_value root "${root_slot_a}" "${cmdline}") | ||
elif [ "${slot_bootname}" = "B" ]; then | ||
cmdline=$(set_value root "${root_slot_b}" "${cmdline}") | ||
else | ||
exit 1 | ||
fi | ||
cmdline=$(set_value rauc.slot "${slot_bootname}" "${cmdline}") | ||
echo "${cmdline}" > "${boot_dir}/cmdline-tryboot.txt" | ||
sed -e "s/^\(os_prefix=\)slot-[A-Z]\/$/\1slot-${slot_bootname}\//" \ | ||
-e "s/^\(cmdline=\).*$/\1\/cmdline-tryboot.txt/" \ | ||
"${boot_dir}/config.txt" > "${boot_dir}/tryboot.txt" | ||
# Use tryboot to try booting the new primary on reboot | ||
echo "0 tryboot" > /run/systemd/reboot-param | ||
;; | ||
|
||
get-state) | ||
# Actions to be performed when getting the bootloader state | ||
# Example: Output the current state of the bootloader | ||
# You need to implement logic to determine the state (good or bad) based on the slot.bootname | ||
slot_bootname="$2" | ||
echo "tryboot get-state $slot_bootname" >&2 | ||
if [ -f "${boot_dir}/slot-${slot_bootname}/.good" ]; then | ||
echo "returning good" >&2 | ||
echo "good" | ||
else | ||
echo "returning bad" >&2 | ||
echo "bad" | ||
fi | ||
;; | ||
|
||
set-state) | ||
# Actions to be performed when setting the bootloader state | ||
# Example: Set the specified state for the bootloader | ||
slot_bootname="$2" | ||
new_state="$3" | ||
echo "tryboot set-state $slot_bootname $new_state" >&2 | ||
if [ "${new_state}" = "good" ]; then | ||
touch "${boot_dir}/slot-${slot_bootname}/.good" | ||
else | ||
rm -f "${boot_dir}/slot-${slot_bootname}/.good" | ||
exit 0 | ||
fi | ||
|
||
# It seems we call set-state in any case. Use this to "commit" tryboot | ||
# state... | ||
|
||
# Check if tryboot is active | ||
if ! cmp -s -n 4 /proc/device-tree/chosen/bootloader/tryboot /dev/zero; then | ||
cmdline_tryboot=$(head -n1 "${boot_dir}/cmdline-tryboot.txt") | ||
tryboot_slot=$(get_value rauc.slot "${cmdline_tryboot}") | ||
if [ "${tryboot_slot}" != "${slot_bootname}" ]; then | ||
echo "tryboot doesn't reflect the expected boot slot, not committing." >&2 | ||
exit 1 | ||
fi | ||
echo "Committing tryboot state to primary boot" >&2 | ||
mv "${boot_dir}/tryboot.txt" "${boot_dir}/config.txt" | ||
mv "${boot_dir}/cmdline-tryboot.txt" "${boot_dir}/cmdline.txt" | ||
fi | ||
;; | ||
|
||
get-current) | ||
# We don't have a better detection then /proc/cmdline... | ||
echo "Cannot reliably determine current slot with tryboot" >&2 | ||
exit 1 | ||
;; | ||
|
||
*) | ||
echo "Unknown operation: $1" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
exit 0 |
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
Oops, something went wrong.