Skip to content
Open
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
50 changes: 50 additions & 0 deletions config/boards/orangepirv2.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# OrangePi RV2 - RISC-V SoC with SPI flash boot
BOARD_NAME="Orange Pi RV2"
BOARDFAMILY="ky"
BOARD_MAINTAINER="tmshlvck"
KERNEL_TARGET="current,edge"
BOOT_FDT_FILE="ky/x1_orangepi-rv2.dtb"
BOOTDELAY=1
SRC_EXTLINUX="yes"
SRC_CMDLINE="console=ttyS0,115200 earlycon=sbi clk_ignore_unused swiotlb=65536"
PACKAGE_LIST_BOARD="rfkill bluetooth bluez bluez-tools can-utils v4l-utils"
#SKIP_BOOTSPLASH="yes" # Skip boot splash patch, conflicts with CONFIG_VT=yes

function post_config_uboot_target__extra_configs_for_orangepi_rv2() {
display_alert "u-boot for ${BOARD}" "u-boot: enabling extra configs for SPI flash boot" "info"
run_host_command_logged scripts/config --enable CONFIG_SD_BOOT
run_host_command_logged scripts/config --enable CONFIG_EXT4_WRITE
run_host_command_logged scripts/config --enable CONFIG_FS_BTRFS
run_host_command_logged scripts/config --enable CONFIG_CMD_BTRFS
run_host_command_logged scripts/config --enable CONFIG_CMD_SF
run_host_command_logged scripts/config --enable CONFIG_SPI_FLASH
run_host_command_logged scripts/config --enable CONFIG_SPI_FLASH_MTD
run_host_command_logged scripts/config --enable CONFIG_CMD_MTD
}

function post_family_tweaks_bsp__orangepi_rv2_extras() {
display_alert "$BOARD" "Installing OrangePi RV2 specific configuration" "info"

if [[ -d "$SRC/packages/blobs/riscv64/ky" ]]; then
run_host_command_logged mkdir -pv "${destination}"/lib/firmware
display_alert "$BOARD" "Installing boot firmware" "info"
run_host_command_logged cp -fv $SRC/packages/blobs/riscv64/ky/esos.elf "${destination}"/lib/firmware
fi

# Force load wireless module if available
if [[ -f "${destination}"/etc/modules-load.d/${BOARD}.conf ]]; then
run_host_command_logged rm -f "${destination}"/etc/modules-load.d/${BOARD}.conf
fi
run_host_command_logged mkdir -pv "${destination}"/etc/modules-load.d

# Add wireless module for AP6256 if present
if [[ "${BOARD}x" == "orangepirv2x" ]]; then
echo "bcmdhd" > "${destination}"/etc/modules-load.d/${BOARD}.conf
Comment on lines +41 to +42
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

Use consistent logging and clarify board variant naming.

Line 42 writes directly to the file without using run_host_command_logged, inconsistent with the rest of the function. Additionally, verify that the board identifier is indeed "orangepirv2x" for the AP6256 WiFi variant (vs "orangepirv2").

Apply this diff for consistency:

 	if [[ "${BOARD}x" == "orangepirv2x" ]]; then
-		echo "bcmdhd" > "${destination}"/etc/modules-load.d/${BOARD}.conf
+		run_host_command_logged bash -c "echo 'bcmdhd' > '${destination}/etc/modules-load.d/${BOARD}.conf'"

Verify the board name with:


🏁 Script executed:

#!/bin/bash
# Check if orangepirv2x is defined as a separate board or variant
fd -t f "orangepirv2" config/boards/

Length of output: 30


🏁 Script executed:

#!/bin/bash
sed -n '1,200p' config/boards/orangepirv2.conf

Length of output: 2286


Wrap echo in logged command, drop variant check suggestion.

Replace the direct file write to use run_host_command_logged for consistency:

-    echo "bcmdhd" > "${destination}"/etc/modules-load.d/${BOARD}.conf
+    run_host_command_logged bash -c "echo 'bcmdhd' > '${destination}/etc/modules-load.d/${BOARD}.conf'"

The test [[ "${BOARD}x" == "orangepirv2x" ]] correctly checks BOARD=="orangepirv2" via the suffix-hack—no variant rename needed.

📝 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
if [[ "${BOARD}x" == "orangepirv2x" ]]; then
echo "bcmdhd" > "${destination}"/etc/modules-load.d/${BOARD}.conf
if [[ "${BOARD}x" == "orangepirv2x" ]]; then
run_host_command_logged bash -c "echo 'bcmdhd' > '${destination}/etc/modules-load.d/${BOARD}.conf'"
🤖 Prompt for AI Agents
In config/boards/orangepirv2.conf around lines 41-42, replace the direct echo
redirection that writes "bcmdhd" into
"${destination}/etc/modules-load.d/${BOARD}.conf" with a call to
run_host_command_logged to keep logging/consistency; keep the existing BOARD
check ([[ "${BOARD}x" == "orangepirv2x" ]]) unchanged, and have
run_host_command_logged execute a safe single-write operation (for example using
printf/tee in a single command invocation) to create/overwrite the target file
and surface any errors via the logger.


# Copy WiFi firmware if available
if [[ -f "${SRC}/packages/blobs/ky/nvram_ap6256.txt" ]]; then
run_host_command_logged mkdir -pv "${destination}"/lib/firmware
run_host_command_logged cp -v "${SRC}/packages/blobs/ky/nvram_ap6256.txt" "${destination}"/lib/firmware/
fi
fi
}
2 changes: 2 additions & 0 deletions config/bootenv/ky.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
verbosity=1
bootlogo=false
57 changes: 57 additions & 0 deletions config/bootscripts/boot-ky.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# DO NOT EDIT THIS FILE
#
# Please edit /boot/orangepiEnv.txt to set supported parameters
#

setenv load_addr "0x9000000"
setenv overlay_error "false"
# default values
setenv verbosity "1"
setenv console "both"
setenv bootlogo "false"
setenv rootfstype "ext4"
setenv docker_optimizations "on"
setenv earlycon "on"

echo "Boot script loaded from ${devtype} ${devnum}"

#if test -e ${devtype} ${devnum} ${prefix}orangepiEnv.txt; then
load ${devtype} ${devnum} ${load_addr} ${prefix}orangepiEnv.txt
env import -t ${load_addr} ${filesize}
#fi

if test "${logo}" = "disabled"; then setenv logo "logo.nologo"; fi

if test "${console}" = "display" || test "${console}" = "both"; then setenv consoleargs "console=tty1"; fi
if test "${console}" = "serial" || test "${console}" = "both"; then setenv consoleargs "console=ttyS0,115200 ${consoleargs}"; fi
if test "${earlycon}" = "on"; then setenv consoleargs "earlycon=sbi ${consoleargs}"; fi
if test "${bootlogo}" = "true"; then setenv consoleargs "bootsplash.bootfile=bootsplash.orangepi ${consoleargs}"; fi

setenv bootargs "mtdparts=${mtdparts} root=${rootdev} rootwait rootfstype=${rootfstype} ${consoleargs} consoleblank=0 loglevel=${verbosity} ubootpart=${partuuid} clk_ignore_unused swiotlb=65536 workqueue.default_affinity_scope=system usb-storage.quirks=${usbstoragequirks} ${extraargs} ${extraboardargs}"

if test "${docker_optimizations}" = "on"; then setenv bootargs "${bootargs} cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1"; fi

load ${devtype} ${devnum} ${ramdisk_addr_r} ${prefix}uInitrd
load ${devtype} ${devnum} ${kernel_addr_r} ${prefix}Image

load ${devtype} ${devnum} ${fdt_addr_r} ${prefix}dtb/${fdtfile}
fdt addr ${fdt_addr_r}
fdt rm /soc/lcd_backlight phandle
fdt resize 65536
for overlay_file in ${overlays}; do
if load ${devtype} ${devnum} ${load_addr} ${prefix}dtb/ky/overlay/${overlay_prefix}-${overlay_file}.dtbo; then
echo "Applying kernel provided DT overlay ${overlay_prefix}-${overlay_file}.dtbo"
fdt apply ${load_addr} || setenv overlay_error "true"
fi
done
for overlay_file in ${user_overlays}; do
if load ${devtype} ${devnum} ${load_addr} ${prefix}overlay-user/${overlay_file}.dtbo; then
echo "Applying user provided DT overlay ${overlay_file}.dtbo"
fdt apply ${load_addr} || setenv overlay_error "true"
fi
done

booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}

# Recompile with:
# mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr
Loading