Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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=tty0 root=PARTUUID=8d3d53e3-6d49-4c38-8349-aff6859e82fd ro rauc.slot=A numa=fake=0 numa=off amdgpu.runpm=0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Hardcoded PARTUUID will break on other installations.

The PARTUUID 8d3d53e3-6d49-4c38-8349-aff6859e82fd is hardcoded and specific to your installation. This cmdline.txt serves as a template copied during image preparation (see hassos-hook.sh line 17), so it must work generically across all installations.

Typical solutions in boot management:

  1. Use a placeholder like @@RAUC_PARTUUID@@ and have the image build or first-boot script substitute the actual partition UUID
  2. Reference by filesystem label (root=LABEL=hassos-system) if the partition labeling scheme supports it
  3. Generate cmdline.txt dynamically during image creation with the correct PARTUUID

Check how the existing rpi5-64 board handles this, or verify whether the build system is expected to template-substitute this value.


🏁 Script executed:

#!/bin/bash
# Check if other Raspberry Pi board cmdline.txt files use hardcoded PARTUUIDs or placeholders
rg -n 'PARTUUID=' buildroot-external/board/raspberrypi/*/cmdline.txt

Length of output: 475


🏁 Script executed:

#!/bin/bash
# Locate and inspect the first 200 lines of hassos-hook.sh
file=$(find buildroot-external -type f -name 'hassos-hook.sh' | head -n1)
echo "Inspecting: $file"
sed -n '1,200p' "$file"

Length of output: 975


Template PARTUUID in cmdline.txt instead of hardcoding
Both buildroot-external/board/raspberrypi/rpi5-64/cmdline.txt and …/rpi5-64-gpu/cmdline.txt hardcode root=PARTUUID=… and are copied unmodified by hassos-hook.sh, which will break on any installation whose partition UUID differs. Replace with a placeholder (e.g. @@RAUC_PARTUUID@@) or use root=LABEL=… and inject the real UUID at build/first-boot.

🤖 Prompt for AI Agents
In buildroot-external/board/raspberrypi/rpi5-64-gpu/cmdline.txt around line 1,
the cmdline hardcodes root=PARTUUID=8d3d53e3-6d49-4c38-8349-aff6859e82fd which
will break installs with different partition UUIDs; update the file to use a
template placeholder (for example @@RAUC_PARTUUID@@) or an alternative stable
identifier like root=LABEL=<label> and ensure hassos-hook.sh (or the
build/first-boot step) injects the actual PARTUUID or resolves the LABEL to the
real UUID at build or first boot time so the deployed cmdline contains the
correct root identifier for the target system.

60 changes: 60 additions & 0 deletions buildroot-external/board/raspberrypi/rpi5-64-gpu/config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 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

# use external antenna
dtparam=ant2
# use PCIe gen 3
#dtparam=pciex1_gen=3

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# 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

# Uncomment this to enable GPIO support for RPI-RF-MOD/HM-MOD-RPI-PCB
#enable_uart=1
#dtparam=i2c_arm=on
#dtoverlay=rpi-rf-mod

[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]

24 changes: 24 additions & 0 deletions buildroot-external/board/raspberrypi/rpi5-64-gpu/hassos-hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/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
# README needs to be present, otherwise os_prefix is not
# prepended implicitly to the overlays' path, see:
# https://www.raspberrypi.com/documentation/computers/config_txt.html#overlay_prefix
touch "${BOOT_DATA}/slot-A/overlays/README" 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
}

17 changes: 17 additions & 0 deletions buildroot-external/board/raspberrypi/rpi5-64-gpu/kernel-amd.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# AMDGPU support
# $ diff --unchanged-line-format= --old-line-format= --new-line-format='%L' .config_rpi .config_amd
CONFIG_ARM64_ALIGNMENT_FIXUPS=y
CONFIG_MMU_NOTIFIER=y
CONFIG_HMM_MIRROR=y
CONFIG_DRM_ARCH_CAN_WC=y
CONFIG_DRM_DISPLAY_DP_HELPER=y
CONFIG_DRM_DISPLAY_HDCP_HELPER=y
CONFIG_DRM_EXEC=m
CONFIG_DRM_BUDDY=m
CONFIG_DRM_SUBALLOC_HELPER=m
CONFIG_DRM_AMDGPU=m
CONFIG_DRM_AMDGPU_USERPTR=y
CONFIG_DRM_AMD_DC=y
CONFIG_DRM_AMD_DC_FP=y
CONFIG_HSA_AMD=y
CONFIG_INTERVAL_TREE=y
11 changes: 11 additions & 0 deletions buildroot-external/board/raspberrypi/rpi5-64-gpu/meta
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
PARTITION_TABLE_TYPE=gpt
BOOT_SIZE=64M
BOOT_SPL=false
BOOT_ENV_SIZE=0x4000
SUPERVISOR_MACHINE=raspberrypi5-64
SUPERVISOR_ARCH=aarch64
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
From c1d421d7c501c77e8c04bdfa141a55e639822c03 Mon Sep 17 00:00:00 2001
From: Yang Bo <[email protected]>
Date: Wed, 28 May 2025 11:18:19 +0800
Subject: [PATCH] Add amdgpu support for arm SoC

Change-Id: Ic95c8514271d246dd668631810e8dee210f7f1b4
Signed-off-by: Yanghaku <[email protected]>
---
drivers/gpu/drm/ttm/ttm_bo_util.c | 14 +-------------
drivers/gpu/drm/ttm/ttm_module.c | 5 +++++
2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 0b3f4267130c..e0e55cb9edd2 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -343,8 +343,6 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo,
.no_wait_gpu = false
};
struct ttm_tt *ttm = bo->ttm;
- struct ttm_resource_manager *man =
- ttm_manager_type(bo->bdev, bo->resource->mem_type);
pgprot_t prot;
int ret;

@@ -354,17 +352,7 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo,
if (ret)
return ret;

- if (num_pages == 1 && ttm->caching == ttm_cached &&
- !(man->use_tt && (ttm->page_flags & TTM_TT_FLAG_DECRYPTED))) {
- /*
- * We're mapping a single page, and the desired
- * page protection is consistent with the bo.
- */
-
- map->bo_kmap_type = ttm_bo_map_kmap;
- map->page = ttm->pages[start_page];
- map->virtual = kmap(map->page);
- } else {
+ {
/*
* We need to use vmap to get the desired page protection
* or to make the buffer object look contiguous.
diff --git a/drivers/gpu/drm/ttm/ttm_module.c b/drivers/gpu/drm/ttm/ttm_module.c
index b3fffe7b5062..9f3e425626b5 100644
--- a/drivers/gpu/drm/ttm/ttm_module.c
+++ b/drivers/gpu/drm/ttm/ttm_module.c
@@ -63,7 +63,12 @@ pgprot_t ttm_prot_from_caching(enum ttm_caching caching, pgprot_t tmp)
{
/* Cached mappings need no adjustment */
if (caching == ttm_cached)
+ {
+#ifdef CONFIG_ARM64
+ return pgprot_dmacoherent(tmp);
+#endif
return tmp;
+ }

#if defined(__i386__) || defined(__x86_64__)
if (caching == ttm_write_combined)
--
2.49.0
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
}
Comment on lines +14 to +25
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Fix regex to avoid partial matches and handle special characters.

The set_value function has two issues:

  1. Line 20: grep "$key=" matches partial keys (e.g., key="foo" matches "foobar=x")
  2. Line 21: sed "s/$key=[^ ]*/$key=$new_value/" is not anchored and doesn't escape special regex characters in key or value

Apply this diff:

 set_value() {
     key="$1"
     new_value="$2"
     cmdline_string="$3"
+
+    # Escape special characters for use in regex
+    escaped_key=$(printf '%s\n' "$key" | sed 's/[[\.*^$()+?{|]/\\&/g')
+    escaped_value=$(printf '%s\n' "$new_value" | sed 's/[&/\]/\\&/g')
 
     # 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/"
+    if echo "$cmdline_string" | grep -q "\(^\| \)$escaped_key="; then
+        echo "$cmdline_string" | sed "s/\(^\| \)$escaped_key=[^ ]*/\1$escaped_key=$escaped_value/"
     else
         echo "$cmdline_string $key=$new_value"
     fi
 }

This ensures:

  • Grep checks for word boundaries (start of line or space before key)
  • Special regex characters are escaped
  • Sed replacement is anchored to avoid partial matches
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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
}
set_value() {
key="$1"
new_value="$2"
cmdline_string="$3"
# Escape special characters for use in regex
escaped_key=$(printf '%s\n' "$key" | sed 's/[[\.*^$()+?{|]/\\&/g')
escaped_value=$(printf '%s\n' "$new_value" | sed 's/[&/\]/\\&/g')
# 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 "\(^\| \)$escaped_key="; then
echo "$cmdline_string" | sed "s/\(^\| \)$escaped_key=[^ ]*/\1$escaped_key=$escaped_value/"
else
echo "$cmdline_string $key=$new_value"
fi
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
#!/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"

get_primary() {
echo "tryboot get-primary" >&2
cmdline=$(head -n1 "${boot_dir}/cmdline.txt")
get_value rauc.slot "${cmdline}"
}

case "$1" in
get-primary)
# Actions to be performed when getting the primary bootloader
# Example: Output the path to the current primary bootloader
get_primary
;;

set-primary)
# Actions to be performed when setting the primary bootloader
# Example: Set the specified bootloader as the primary one
slot_bootname="$2"

# Do nothing if we're already booted in the requested slot
if [ "$(get_primary)" = "${slot_bootname}" ]; then
echo "tryboot set-primary $slot_bootname: already set" >&2
exit 0
fi

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
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
if [ ! -f "${boot_dir}/cmdline-tryboot.txt" ]; then
if [ -f "${boot_dir}/slot-${slot_bootname}/.good" ]; then
# Most probably already handled on this boot before, do nothing
exit 0
else
echo "cmdline-tryboot.txt not found, can't commit current state." >&2
exit 1
fi
fi
# tryboot.txt MUST exist at this point
if [ ! -f "${boot_dir}/tryboot.txt" ]; then
echo "tryboot.txt not found, can't commit current state." >&2
exit 1
fi
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
sed -e "s/^\(cmdline=\).*$/\1\/cmdline.txt/" \
"${boot_dir}/tryboot.txt" > "${boot_dir}/config.txt"
mv "${boot_dir}/cmdline-tryboot.txt" "${boot_dir}/cmdline.txt"
rm "${boot_dir}/tryboot.txt"
rm /run/systemd/reboot-param
fi

if [ "${new_state}" = "good" ]; then
touch "${boot_dir}/slot-${slot_bootname}/.good"
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
Loading