-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
rpi5 board with GPU support #4335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| 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] | ||
|
|
| 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 | ||
| } | ||
|
|
| 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 |
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix regex to avoid partial matches and handle special characters. The set_value function has two issues:
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:
📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Hardcoded PARTUUID will break on other installations.
The PARTUUID
8d3d53e3-6d49-4c38-8349-aff6859e82fdis 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:
@@RAUC_PARTUUID@@and have the image build or first-boot script substitute the actual partition UUIDroot=LABEL=hassos-system) if the partition labeling scheme supports itCheck how the existing rpi5-64 board handles this, or verify whether the build system is expected to template-substitute this value.
🏁 Script executed:
Length of output: 475
🏁 Script executed:
Length of output: 975
Template PARTUUID in cmdline.txt instead of hardcoding
Both
buildroot-external/board/raspberrypi/rpi5-64/cmdline.txtand…/rpi5-64-gpu/cmdline.txthardcoderoot=PARTUUID=…and are copied unmodified byhassos-hook.sh, which will break on any installation whose partition UUID differs. Replace with a placeholder (e.g.@@RAUC_PARTUUID@@) or useroot=LABEL=…and inject the real UUID at build/first-boot.🤖 Prompt for AI Agents