Skip to content

Conversation

@sven-ola
Copy link

@sven-ola sven-ola commented Jan 26, 2026

Description

This PR supports a new board: Xunlong Orange Pi RV2. I already applied for maintainership for this board, but currently the board configs are *.wip. Note, that the smaller sibling, the Orange Pi R2V is also supported, but I do not own the HW, thus it's unsupported probably.

Documentation summary for feature / change

You can read about this PR in the Armbian forum, see the respective thread under https://forum.armbian.com/topic/56846-orange-pi-rv2/ I also generated and uploaded testing images built with this on my private project website (see https://privat-in.de/ goto downloads): current-trixie-minimal, edge-trixie-minimal, and edge-trixie-desktop-mate.

Here is a list of features (valid both for 6.6/current and for 6.18/edge if not noted otherwise)

  • Boots from SD, eMMC, and indirect via MTD from upper M2 (2230) and lower M2 (2280). Note, that the original Xunlong SW does not boot from upper 2230.
  • Boot files can be installed via armbian-install (write to MTD / write to eMMC).
  • Most hardware runs. That includes UARTs, both Eth, HDMI, HDMI-audio, internal audio, internal Wifi / BT, USB2, USB3, both M.2 slots.
  • There are a number of device tree overlays for the pin socket. Can be activated via extlinux.conf (fdtoverlays option).
  • There are changes for other Spacemit board (namely BPI F3, MusePiPro), those are marked in the commit comment with "Spacemit:" or "General". No critical changes AFAICT.

How Has This Been Tested?

This was tested with the images one can download. I have a number of people that tried my images and provided feedback (see Forum thread linked above).

Notes

  • There was a discussion with the upsteam kernel maintainer on a removed kernel thread for the rCPU in the context of a non-working HDMI audio. See jmontleon/linux-spacemit@d6a6ebe
  • From this discussion: we can strip debug info the esos.elf FW file that is in the Armbian tree. With this, the kernel module tranferring the FW can save 400k of memory. This is not include in the PR
  • From my wishlist: Mediatek Wifi drivers and Device-Mapper drivers are a thing. Should be activated all as module for this and other boards.
  • Internal Wifi/BT driver (Spacemit adapted bcmdhd) was included in the 6.6/current kernel tree. This driver is not included with the 6.18/edge kernel tree, therefore I added this as an DKMS/external driver. I tried to activate EXTRAWIFI=yes, but this conflicts with patches for the other Spacemit boards.
  • Also, the OPI R2S (smaller sister board) is supported. For this I added the r8125 driver via ./patch/kernel/archive/spacemit-* in two steps: 1 patch with the driver subdir (should apply to future kernel trees as well) and 1 patch for Makefile/Kconfig. Hope it's OK this way.
  • There are a number for HW features not supported. The GPU is unsupported (and likely with stay so). See PowerVR on Mesa, the https://docs.mesa3d.org/drivers/powervr.html lists Imagination BXE-2-32 on the table-of-unsupported. Also no HW video decoding, probably Mipi/DSI and Mipi/CSI will not work. This extra Realtime-CPU needs investigation, there's an unsupported extra rUART maybe for a prompt or so...

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for Orange Pi R2S and Orange Pi RV2 boards with complete hardware initialization
    • Added Realtek 8125 2.5GbE Ethernet driver support
    • Added CAN bus support with FlexCAN
    • Added remote control and IR support
    • Added ES8323 audio codec support
    • Added Bluetooth and WiFi configuration for Orange Pi RV2
  • Improvements

    • Enhanced RISC-V architecture support for MATE desktop environment
    • Improved kernel crypto engine efficiency and buffer handling
    • Added SPI NOR flash support for new boards
  • Bug Fixes

    • Fixed HDMI audio dependency configuration
    • Fixed headphone GPIO initialization on Orange Pi RV2

✏️ Tip: You can customize this high-level summary in your review settings.

Required to compile BCM bluetooth firmware hacking tool.

Signed-off-by: Sven-Ola Tuecke <[email protected]>
Note: HW AES is really slow with LUKS2 when using default 512 byte block
size, regardless what cryptsetup benchmark prints out (this uses 65536
bytes). Performance is much better with luksFormat --sector-size 4096.

Signed-off-by: Sven-Ola Tuecke <[email protected]>
Added with new extension named bcmdhd-spacemit (hosted on Codeberg.org)

Signed-off-by: Sven-Ola Tuecke <[email protected]>
This is for use with fdtoverlays directive in extlinux.conf
to enabled different configs for the Opi rv2 pin headers

Signed-off-by: Sven-Ola Tuecke <[email protected]>
…ver.

Disable U-Boot CONFIG_MMC_UHS_SUPPORT otherwise a fast SD card does not
report "1.8 Volt mode switch possible" on kernel init which in turn does
not enable SDR104 for my SDXC card.

Fast mode ok is visible in the kernel log after booting from SD card:

root@orangepirv2:~# dmesg |grep mmc
[    2.198816] mmc0: SDHCI controller on d4280000.sdh [d4280000.sdh] using ADMA
[    2.224576] mmc1: SDHCI controller on d4280800.sdh [d4280800.sdh] using ADMA
[    2.272657] mmc0: set tx_delaycode: 159
[    2.273950] mmc0: pass window [6 68)
[    2.276301] mmc0: pass window [72 198)
[    2.277591] mmc0: pass window [219 255)
[    2.277599] mmc0: tuning done, use the firstly delay_code:134
[    2.277611] mmc0: new ultra high speed SDR104 SDXC card at address b36b

With UHS already enabled in u-boot, no tuning and no SDR104 mode is switched on
in the Linux kernel. Seems to be a side effect of an un-complete mmc_deinit() in
u-boot/driver/mmc/mmc.c. With MMC_UHS_SUPPORT disabled, the SD card does report
SD_ROCR_S18A with then leads to enter spacemit_sdhci_execute_sw_tuning() and the
subsequent switch to SDK104 or probably other 1.8 Volt modes is fine. This is at
least true for my OrangePi RV2 board.

Signed-off-by: Sven-Ola Tuecke <[email protected]>
Driver for Ethernet/PCI as found with Xunlong/Ky on the
OrangePi RV2/R2S source tree. Added as kernel patch since
the current spacemit family has conflicting changes with
rtl8852bs when enabling EXTRAWIFI=yes

Note: on the Xunlong/Ky tree, there is also a realtek_pgtool/
subdir that compiles a pgdrv.ko. B/c this does not have a
license indication, is only needed e.g. for MAC address
programming of efuse / eeprom, and generally does not look
required this is ommited here. For details, you may refer
to https://github.com/redchenjs/rtnicpg

Signed-off-by: Sven-Ola Tuecke <[email protected]>
Note: have a 128Gb 2030 NVME that returns read errors with Active State PM

Signed-off-by: Sven-Ola Tuecke <[email protected]>
Signed-off-by: Sven-Ola Tuecke <[email protected]>
@sven-ola sven-ola requested a review from pyavitz as a code owner January 26, 2026 21:00
@sven-ola sven-ola requested review from a team and igorpecovnik as code owners January 26, 2026 21:00
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 26, 2026

📝 Walkthrough

Walkthrough

This PR introduces comprehensive support for two Orange Pi boards (R2S and RV2) based on the Spacemit K1-X architecture. It includes board configuration scripts, complete device tree definitions, kernel configuration updates, multiple kernel patches for drivers and subsystems, Bluetooth and WiFi support components, and U-Boot integration. The changes span board metadata, hardware initialization, firmware flashing procedures, and peripheral enablement.

Changes

Cohort / File(s) Summary
Board Configuration
config/boards/orangepir2s.wip, config/boards/orangepirv2.wip
New board configuration scripts defining board metadata (name, vendor, family, maintainer, kernel target, boot configuration) and board-specific functions: post_config_uboot_target__extra_configs_for_orangepi (MMC UHS disable), write_uboot_platform_mtd (MTD partition flashing), plus RV2-specific WiFi/Bluetooth/service enablement hooks.
Environment Architecture Support
config/desktop/trixie/environments/mate/architectures
Adds riscv64 architecture support to MATE desktop environment configuration.
Host Dependencies
lib/functions/host/prepare-host.sh
Adds libc6-dev-riscv64-cross package to riscv64 architecture-specific host dependencies alongside existing gcc-riscv64-linux-gnu.
Kernel Configuration (Spacemit Current)
config/kernel/linux-spacemit-current.config
Enables new kernel features: CAN bus support (CONFIG_CAN, CONFIG_CAN_FLEXCAN), Realtek R8125 2.5GbE NIC (CONFIG_R8125), remote control/IR (CONFIG_RC_CORE, CONFIG_RC_DEVICES, CONFIG_IR_SPACEMIT), and ES8323 audio codec (CONFIG_SND_SOC_ES8323).
Kernel Configuration (Spacemit Edge)
config/kernel/linux-spacemit-edge.config
Extends spacemit-current config with additional USB CEC support (CONFIG_USB_RAINSHADOW_CEC) for edge kernel variant.
Kernel Device Tree (Spacemit 6.18)
patch/kernel/archive/spacemit-6.18/dt/Makefile
Registers two new DTB targets: x1_orangepi-r2s.dtb and x1_orangepi-rv2.dtb.
Device Tree Sources (Spacemit 6.18)
patch/kernel/archive/spacemit-6.18/dt/x1_orangepi-r2s.dts, patch/kernel/archive/spacemit-6.18/dt/x1_orangepi-rv2.dts
Complete device tree definitions for Orange Pi R2S and RV2 boards including CPU topology, memory layout, regulators, peripherals (UART, I2C, SPI, USB, PCIe, Ethernet), PMIC configuration, and pinctrl mappings. RV2 includes additional WiFi/Bluetooth power sequencing and camera/display support.
Device Tree Overlays (Spacemit 6.18)
patch/kernel/archive/spacemit-6.18/overlay/Makefile, patch/kernel/archive/spacemit-6.18/overlay/k1-{can0,i2c3,i2c4,lcd,pwm7,pwm9,spi3-cs0-spidev,uart5,uart8,uart9}.dts
Adds ten device tree overlay files for optional peripheral enablement (CAN, I2C, LCD/DSI, PWM, SPI, UART variants) with corresponding Makefile entries.
Kernel Patches (Spacemit 6.18)
patch/kernel/archive/spacemit-6.18/008-010-*.patch, 012-014-*.patch, 016-017-*.patch
Various driver and subsystem patches: SPI-NOR flash size expansion (12→16MB), crypto config adjustments, HW crypto fallback optimization, Realtek R8125 2.5GbE support, Samsung NVMe ASPM quirk, HDMI audio dummy codec dependency, k1x remoteproc thread handling and scheduling optimization.
Kernel Device Tree (Spacemit 6.6)
patch/kernel/archive/spacemit-6.6/dt/Makefile, patch/kernel/archive/spacemit-6.6/dt/x1_orangepi-r2s.dts, patch/kernel/archive/spacemit-6.6/dt/x1_orangepi-rv2.dts
Parallel device tree infrastructure for 6.6 kernel variant with same board definitions and overlay structure as 6.18.
Device Tree Overlays (Spacemit 6.6)
patch/kernel/archive/spacemit-6.6/overlay/*
Duplicate overlay set for 6.6 kernel variant (CAN, I2C, LCD, PWM, SPI, UART).
Kernel Patches (Spacemit 6.6)
patch/kernel/archive/spacemit-6.6/007-014-*.patch
Corresponding patches for 6.6 kernel: BCMDHD power control enablement, SPI-NOR expansion, crypto config, HDMI audio, k1x remoteproc thread handling.
U-Boot Support (Legacy)
patch/u-boot/legacy/u-boot-spacemit-k1/006-007-*.patch
Adds SPI NOR flash device (XM25QH128A) support and FIT image entries for both Orange Pi boards with corresponding device tree sources in U-Boot.
WiFi Driver Extension
extensions/bcmdhd-spacemit.sh
New extension functions: extension_finish_config__install_kernel_headers_for_bcmdhd_spacemit_dkms (conditional header installation) and post_install_kernel_debs__install_bcmdhd_spacemit_dkms_package (downloads and installs WiFi driver package variants via chroot).
Bluetooth Support
packages/bsp/orangepirv2/brcm_patchram_plus.c
Comprehensive C utility (~890 lines) for Broadcom Bluetooth HCD patchram flashing with command-line parsing, UART initialization, baud rate handling, BD_ADDR configuration, and Android-specific hooks.
Bluetooth Service
packages/bsp/orangepirv2/orangepirv2-bluetooth.service
Systemd service unit for Bluetooth initialization invoking brcm_patchram_plus with HCI enablement and rfkill unblocking.
Firmware Documentation
packages/blobs/riscv64/spacemit/LICENSE.spacemit_esos, packages/blobs/riscv64/spacemit/README.txt
License and documentation files for Spacemit ESOS firmware blob with use restrictions and RTOS references.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • armbian/build#8823 — Similar board configuration pattern with U-Boot post-config helpers and MTD flashing functions for other boards.
  • armbian/build#9261 — Introduces write_uboot_platform_mtd and board U-Boot configuration flows for different Orange Pi variant.
  • armbian/build#9058 — Adds Spacemit board configurations with similar post_config_uboot_target hooks and kernel DTB overlay structure.

Suggested labels

Hardware, Board-Support, Kernel, Device-Tree

Suggested reviewers

  • igorpecovnik
  • pyavitz

🐰 Orange Pi dreams take shape at last,
R2S and RV2 casting off the past,
Device trees bloom, like carrots in the sun,
Spacemit boards together, now they're one! 🌱

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.06% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main addition: support for Orange Pi RV2 with Spacemit processor on both current (6.6) and edge (6.18) kernel versions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • BXE-2: Request failed with status code 404

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the 02 Milestone: First quarter release label Jan 26, 2026
@github-actions
Copy link
Contributor

Hey @sven-ola! 👋

Thanks for submitting your first pull request to the Armbian project — we're excited to have you contributing! 🧡
Your effort doesn’t just improve Armbian — it benefits the entire community of users and developers.

If you'd like to stay informed about project updates or collaborate more closely with the team,
you can optionally share some personal contact preferences at armbian.com/update-data.
This helps us keep in touch without relying solely on GitHub notifications.

Also, don’t forget to ⭐ star the repo if you haven’t already — and welcome aboard! 🚀

@github-actions
Copy link
Contributor

🚫 Missing required board assets

This PR adds new board configuration(s). Required assets must already exist in github/armbian/armbian.github.io.
They are required by Armbian Imager to ensure all boards are displayed with proper images.

  • Board images: board-images/<board>.png (1920x1080 px transparent)
  • Vendor logos: board-vendor-logos/<vendor>-logo.png (512x512 px transparent)

Missing items

  • Board image missing for orangepir2s

    • Expected: board-images/orangepir2s.png
    • Fix: add the file to armbian/armbian.github.io (folder board-images/)
  • Board image missing for orangepirv2

    • Expected: board-images/orangepirv2.png
    • Fix: add the file to armbian/armbian.github.io (folder board-images/)

Once the missing files are added (or a PR is opened in armbian/armbian.github.io), re-run this check.

@github-actions github-actions bot added size/large PR with 250 lines or more Desktop Graphical user interface Needs review Seeking for review Framework Framework components Patches Patches related to kernel, U-Boot, ... BSP Board Support Packages labels Jan 26, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 17

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
patch/kernel/archive/spacemit-6.6/dt/Makefile (1)

9-17: Remove the orphaned k1-x_orangepi-rv2.dtb entry from the Makefile.

The reference to k1-x_orangepi-rv2.dtb on line 9 has no corresponding source file. Only x1_orangepi-rv2.dts exists, which generates x1_orangepi-rv2.dtb (added on line 17). The k1-x_orangepi-rv2.dtb entry will fail during kernel compilation. Remove this orphaned entry—it should not coexist with the new x1_orangepi-rv2.dtb.

🤖 Fix all issues with AI agents
In `@extensions/bcmdhd-spacemit.sh`:
- Around line 15-45: The script downloads external .deb files
(pcie_url/sdio_url/usb_url) via chroot_sdcard "wget ..." and then installs via
chroot_sdcard_apt_get_install /tmp/"${file_name}" without integrity checks; add
a verification step after each download and before calling
chroot_sdcard_apt_get_install: fetch the upstream checksum/signature (e.g., a
.sha256 or .asc file provided by the bcmdhd-spacemit-dkms release), verify the
.deb against that checksum (sha256sum) and/or verify a signature with gpg, and
abort (return non‑zero) on mismatch or missing verification; integrate this into
the case branch flow using the same variables (pcie_url/sdio_url/usb_url and
file_name) so the check runs after chroot_sdcard "wget ..." and before
use_clean_environment="yes" chroot_sdcard_apt_get_install /tmp/"${file_name}".

In `@packages/bsp/orangepirv2/brcm_patchram_plus.c`:
- Around line 107-123: This source uses POSIX I/O functions (read, write, close)
and timing functions (usleep, alarm) without including the POSIX header; add
`#include` <unistd.h> near the other system headers so functions like read(),
write(), close(), usleep(), and alarm() have correct prototypes and avoid
implicit-declaration warnings/errors in brcm_patchram_plus.c.
- Around line 617-635: Create and use a robust read helper (e.g., safe_read or
read_all) that wraps read(2) in a loop handling EINTR, returns -1 on error, 0 on
EOF, or the total bytes read on success; replace the ad-hoc read loops in
read_event and the lone read in proc_patchram to call this helper, check its
return value and abort/propagate errors instead of looping forever. In
read_event (function read_event) use the helper to read the 3-byte header,
validate the header result (handle EOF/err), extract len = buffer[2] and
validate that len does not exceed the remaining buffer capacity before reading
the payload with the helper; in proc_patchram use the same helper to read both
header and payload, check the returned byte counts, and reject or handle
short/EOF/error results properly. Ensure all error paths return/cleanup
consistently and do not assume read() will always fulfill the requested length.
- Around line 331-344: In parse_bdaddr, check the return value of sscanf and
ensure it parsed all 6 bytes before writing into hci_write_bd_addr; if sscanf
does not return 6, do not touch hci_write_bd_addr or set bdaddr_flag and instead
return an error (non-zero) so parse_cmd_line can surface usage; only copy
bd_addr into hci_write_bd_addr[4 + i] and set bdaddr_flag = 1 when sscanf
succeeded.

In
`@patch/kernel/archive/spacemit-6.18/015-OrangePi-RV2-fix-internal-audio-activate-headphone-g.patch`:
- Around line 30-41: The new CONFIG_SOC_SPACEMIT block must check and handle
errors from of_get_named_gpio and devm_gpio_request_one and fix the kernel style
for the else placement: after calling of_get_named_gpio for "earphone-sw-gpio"
on i2c_client->dev.of_node, only call devm_gpio_request_one if gpio >= 0,
capture its return value, and on failure call dev_err(&i2c_client->dev, "...:
%d\n", ret) (or dev_warn if you prefer optional) instead of ignoring it; also
change the closing brace/else to follow kernel style (`} else {`) when falling
back to dev_info for "No earphone-sw-gpio".

In
`@patch/kernel/archive/spacemit-6.18/016-Revert-k1x_rproc-avoid-creating-busy-looping-mailbox.patch`:
- Around line 37-57: Rename the misspelled function __process_theread to
__process_thread and update any references/callers accordingly; also fix the
invalid realtime priority by setting param.sched_priority to a valid 1–99 value
(e.g., use sched_get_priority_max(SCHED_FIFO) or at least 1) before calling
sched_setscheduler(current, SCHED_FIFO, &param) so the call does not fail with
-EINVAL.
- Around line 121-125: The loop unconditionally calls
kthread_stop(priv->mb[i].mb_thread) which can crash if the thread was never
created (mb_thread is NULL); modify the loop to mirror spacemit_rproc_remove()
by checking the thread state before stopping—e.g., only call kthread_stop when
kthread_running(priv->mb[i].mb_thread) (or priv->mb[i].mb_thread != NULL) is
true—and ensure any associated cleanup such as
mbox_free_channel(priv->mb[i].chan) is performed consistently as in
spacemit_rproc_remove().

In
`@patch/kernel/archive/spacemit-6.18/017-Spacemit-lower-kthread-loop-speed-to-1-sec.patch`:
- Around line 19-23: The SCHED_FIFO call is using an invalid priority
(DEFAULT_PRIO / 0) causing sched_setscheduler to fail; update the sched_param
used in the sched_setscheduler call in this block (struct sched_param param,
reference to DEFAULT_PRIO and sched_setscheduler/current/SCHED_FIFO) to supply a
valid real-time priority (e.g., set sched_priority to 1 for the lowest RT
priority) or alternatively change the scheduling policy from SCHED_FIFO to
SCHED_NORMAL if real-time behavior is not required; ensure the chosen fix
results in a valid range for sched_setscheduler and adjust the param
initialization accordingly.

In `@patch/kernel/archive/spacemit-6.18/dt/x1_orangepi-rv2.dts`:
- Around line 828-836: The node name rgmii0: phy@0 under mdio-bus has a reg =
<0x1> but the unit address (phy@0) does not match the reg; rename the node to
phy@1 to match the reg value and satisfy device tree rules—update the node label
from "phy@0" to "phy@1" (keeping the same properties: compatible, device_type,
reg, phy-mode) so the unit address and reg are consistent.
- Around line 273-289: The eeprom@50 node is marked status = "disabled" but
defines mac_address0 and mac_address1 nvmem cells which eth0 and eth1 reference
via their nvmem-cells; either enable the EEPROM provider by setting eeprom@50 to
status = "okay" (so mac_address0 and mac_address1 become available) or
remove/replace the nvmem-cells references from the ethernet nodes (eth0/eth1) to
point to a valid NVMEM provider/constant instead; locate the eeprom@50 node and
mac_address0/mac_address1 cell labels and update status, or edit the eth0 and
eth1 nodes to remove or retarget their nvmem-cells accordingly.

In
`@patch/kernel/archive/spacemit-6.6/013-Spacemit-copy-kernel-thread-handling-from-Xunlong-Ky.patch`:
- Around line 40-62: Rename the misspelled thread entry function
__process_theread to __process_thread and update any references; also fix the
invalid realtime priority by changing struct sched_param param =
{.sched_priority = 0 } to a valid value (e.g. 1) before calling
sched_setscheduler(current, SCHED_FIFO, &param); keep mb->kthread_running,
set_freezable()/try_to_freeze(), wait_for_completion_timeout(&mb->mb_comp, 10)
and the rproc_vq_interrupt(rproc, mb->vq_id) handling as-is, and ensure
sched_setscheduler return is assigned to ret as already done (optionally log on
failure).

In `@patch/kernel/archive/spacemit-6.6/dt/x1_orangepi-r2s.dts`:
- Around line 653-661: The PHY node name and MDIO addresses are inconsistent:
the node rgmii0 is declared as phy@0 but has reg = <0x1>, and both rgmii0 and
rgmii1 share MDIO address 0x1. Fix by renaming the node phy@0 to phy@1 (so the
unit-address matches reg = <0x1>) inside the mdio-bus, and ensure rgmii1 uses a
different reg value (unique MDIO address) than rgmii0 so no two PHYs share the
same MDIO address.

In `@patch/kernel/archive/spacemit-6.6/dt/x1_orangepi-rv2.dts`:
- Around line 271-287: The EEPROM node eeprom@50 is marked status = "disabled"
while eth0/eth1 reference its nvmem-cells mac_address0 and mac_address1, so
enable the provider or relocate the cells: either remove or change status =
"disabled" to status = "okay" on the eeprom@50 node so the NVMEM provider
registers, or move the mac_address0 and mac_address1 child nodes into an enabled
nvmem provider node that eth0/eth1 can reference; ensure the referenced symbols
(eeprom@50, mac_address0, mac_address1, and the eth0/eth1 nvmem-cells usage)
match after the change.
- Around line 826-834: The node name phy@0 under mdio-bus has reg = <0x1>,
causing unit_address_vs_reg warnings; rename the node to phy@1 (matching the reg
value) so the unit address matches reg, i.e., update the node label from "phy@0"
to "phy@1" (retain properties like compatible, device_type, reg, phy-mode and
the rgmii0 label as-is) to eliminate the dtbs_check warning.
- Around line 142-149: The rf-pwrseq node declares a bare pwr-gpios property
which is invalid; either restore the intended GPIO phandle specifier (use
pwr-gpios = <&gpio 67 0>; inside the rf_pwrseq: rf-pwrseq node so the driver can
parse the power-enable line) or remove the pwr-gpios property entirely if that
GPIO is not used; update the rf_pwrseq node accordingly (refer to the rf_pwrseq:
rf-pwrseq node and the commented '<&gpio 67 0>' specifier).

In `@patch/u-boot/legacy/u-boot-spacemit-k1/006-orangepi-rv2-spi-flash.patch`:
- Around line 15-21: The XM25QH128A entry for the spi_nor_ids array is placed
outside the CONFIG_SPI_FLASH_XMC guard so it won't be compiled when only
CONFIG_SPI_FLASH_XMC is set; move the { INFO("XM25QH128A", 0x204118, 0, 64 *
1024, 256, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) } line into the
`#ifdef` CONFIG_SPI_FLASH_XMC block (or wrap that single entry with `#ifdef`
CONFIG_SPI_FLASH_XMC / `#endif`) so the device ID is included whenever the XMC
driver is enabled and remains excluded otherwise.

In `@patch/u-boot/legacy/u-boot-spacemit-k1/007-orangepi-rv2-r2s-fit.patch`:
- Around line 44-46: The model string in the device tree node for
x1_orangepi-r2s is incorrect—update the model property that currently reads "ky
x1 orangepi-rv2 board" to the correct board name "ky x1 orangepi-r2s board" so
the node for x1_orangepi-r2s reflects the R2S hardware (locate the node with the
model property in x1_orangepi-r2s.dts and replace the string).
🧹 Nitpick comments (5)
patch/kernel/archive/spacemit-6.18/015-OrangePi-RV2-fix-internal-audio-activate-headphone-g.patch (1)

19-22: Consider using the gpiod descriptor-based API.

The legacy GPIO API (of_get_named_gpio, gpio.h, of_gpio.h) is deprecated in the kernel. For 6.18, the preferred approach is to use the gpiod_* descriptor-based API with <linux/gpio/consumer.h>.

♻️ Suggested refactor using gpiod API
 `#ifdef` CONFIG_SOC_SPACEMIT
-#include <linux/gpio.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/consumer.h>
 `#endif`

Then in probe:

`#ifdef` CONFIG_SOC_SPACEMIT
	struct gpio_desc *earphone_gpio;
	earphone_gpio = devm_gpiod_get_optional(&i2c_client->dev, "earphone-sw", GPIOD_OUT_HIGH);
	if (IS_ERR(earphone_gpio))
		return PTR_ERR(earphone_gpio);
`#endif`

Note: The DT property would need to change from earphone-sw-gpio to earphone-sw-gpios for gpiod binding conventions.

patch/kernel/archive/spacemit-6.6/013-Spacemit-copy-kernel-thread-handling-from-Xunlong-Ky.patch (1)

54-54: Consider increasing the timeout to reduce polling overhead.

A 10-tick timeout results in frequent wakeups (10–100ms depending on HZ). The corresponding 6.18 patch (017) increases this to 1 second via msecs_to_jiffies(1000). Consider aligning the 6.6 version for consistency.

Suggested alignment with 6.18
-		wait_for_completion_timeout(&mb->mb_comp, 10);
+		wait_for_completion_timeout(&mb->mb_comp, msecs_to_jiffies(1000));
patch/kernel/archive/spacemit-6.6/overlay/k1-pwm9.dts (1)

10-11: Rename to k1-rpwm9.dts for consistency with target node name.

The overlay correctly targets &rpwm9 (confirmed in base DT at x1_orangepi-rv2.dts:1219), but the filename k1-pwm9.dts is misleading. Rename to k1-rpwm9.dts to match the target node name, consistent with how other overlays are named (e.g., k1-pwm7.dts targets &pwm7).

packages/bsp/orangepirv2/orangepirv2-bluetooth.service (1)

5-10: Consider using Type=oneshot for initialization services.

brcm_patchram_plus performs a one-time initialization (patchram upload and HCI attachment) then typically exits or continues running to maintain the HCI. The combination of Type=simple with RemainAfterExit=yes works but Type=oneshot is the more conventional pattern for services that run once to initialize hardware.

If brcm_patchram_plus continues running (daemonizes) to keep the UART attached, then Type=simple without RemainAfterExit would be appropriate. If it exits after initialization, Type=oneshot with RemainAfterExit=yes is cleaner.

patch/u-boot/legacy/u-boot-spacemit-k1/007-orangepi-rv2-r2s-fit.patch (1)

260-262: Minor: Inconsistent indentation.

Line 261 (cd-inverted;) uses spaces instead of tabs, inconsistent with surrounding lines. Same issue at line 602 in the rv2 DTS.

Comment on lines +15 to +45
[[ "${INSTALL_HEADERS}" != "yes" ]] || [[ "${KERNEL_HAS_WORKING_HEADERS}" != "yes" ]] && return 0
[[ -z ${BCMDHD_SPACEMIT_TAG} ]] && return 0
[[ -z ${BCMDHD_SPACEMIT_TYPE} ]] && return 0

local file_name=
local pcie_url="https://codeberg.org/sven-ola/bcmdhd-spacemit-dkms/releases/download/${BCMDHD_SPACEMIT_TAG}/bcmdhd-spacemit-pcie-dkms_${BCMDHD_SPACEMIT_TAG#v}_all.deb"
local sdio_url="https://codeberg.org/sven-ola/bcmdhd-spacemit-dkms/releases/download/${BCMDHD_SPACEMIT_TAG}/bcmdhd-spacemit-sdio-dkms_${BCMDHD_SPACEMIT_TAG#v}_all.deb"
local usb_url="https://codeberg.org/sven-ola/bcmdhd-spacemit-dkms/releases/download/${BCMDHD_SPACEMIT_TAG}/bcmdhd-spacemit-usb-dkms_${BCMDHD_SPACEMIT_TAG#v}_all.deb"

case "${BCMDHD_SPACEMIT_TYPE}" in
"pcie")
file_name=bcmdhd-spacemit-pcie-dkms_${BCMDHD_SPACEMIT_TAG#v}_all.deb
use_clean_environment="yes" chroot_sdcard "wget ${pcie_url} -P /tmp"
;;
"sdio")
file_name=bcmdhd-spacemit-sdio-dkms_${BCMDHD_SPACEMIT_TAG#v}_all.deb
use_clean_environment="yes" chroot_sdcard "wget ${sdio_url} -P /tmp"
;;
"usb")
file_name=bcmdhd-spacemit-usb-dkms_${BCMDHD_SPACEMIT_TAG#v}_all.deb
use_clean_environment="yes" chroot_sdcard "wget ${usb_url} -P /tmp"
;;
*)
return 0
;;
esac
display_alert "Install bcmdhd-spacemit packages, will build kernel module in chroot" "${EXTENSION}" "info"
# shellcheck disable=SC2034
declare -ag if_error_find_files_sdcard=("/var/lib/dkms/bcmdhd*/*/build/*.log")
use_clean_environment="yes" chroot_sdcard_apt_get_install /tmp/"${file_name}"
use_clean_environment="yes" chroot_sdcard "rm -f /tmp/bcmdhd*.deb"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

bcmdhd-spacemit-dkms Codeberg releases checksums signatures

💡 Result:

Codeberg (Forgejo) doesn’t automatically publish checksums or cryptographic signatures for “Releases” assets—a release is essentially a Git tag plus arbitrary attached files (binaries, tarballs, .sha256, .asc, etc.) and release notes. (docs.codeberg.org)

So for bcmdhd-spacemit-dkms on Codeberg, if you want checksums/signatures, you typically need to look for (or the maintainer needs to upload):

  • a checksum file alongside the asset (e.g., SHA256SUMS, *.sha256)
  • a detached OpenPGP signature (e.g., *.asc) for the asset and/or for the checksum file

Separately, Codeberg supports GPG/SSH verification for Git objects (commits/tags) once the maintainer uploads a key—so a signed tag can provide authenticity for the source at that tag, but it’s distinct from signing the uploaded release binaries themselves. (docs.codeberg.org)

Citations:


🏁 Script executed:

# Let's examine the full file to understand the context better
cat -n extensions/bcmdhd-spacemit.sh

Repository: armbian/build

Length of output: 2538


Add integrity verification before installing external .deb packages

Lines 27, 31, and 35 download and install .deb files from Codeberg releases without checksum or signature verification. This creates a supply-chain risk. Before installation, either:

  • Verify the downloaded package against checksums provided by the upstream project (if available), or
  • Request that the bcmdhd-spacemit-dkms maintainer publish checksums/signatures alongside releases.

Note that apt-get install on a local .deb file (line 44) does not perform package signature verification—this verification must happen before or during the download.

🤖 Prompt for AI Agents
In `@extensions/bcmdhd-spacemit.sh` around lines 15 - 45, The script downloads
external .deb files (pcie_url/sdio_url/usb_url) via chroot_sdcard "wget ..." and
then installs via chroot_sdcard_apt_get_install /tmp/"${file_name}" without
integrity checks; add a verification step after each download and before calling
chroot_sdcard_apt_get_install: fetch the upstream checksum/signature (e.g., a
.sha256 or .asc file provided by the bcmdhd-spacemit-dkms release), verify the
.deb against that checksum (sha256sum) and/or verify a signature with gpg, and
abort (return non‑zero) on mismatch or missing verification; integrate this into
the case branch flow using the same variables (pcie_url/sdio_url/usb_url and
file_name) so the check runs after chroot_sdcard "wget ..." and before
use_clean_environment="yes" chroot_sdcard_apt_get_install /tmp/"${file_name}".

Comment on lines +107 to +123
#include <stdio.h>
#include <getopt.h>
#include <errno.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include <stdlib.h>

#ifdef ANDROID
#include <termios.h>
#else
#include <sys/termios.h>
#include <sys/ioctl.h>
#include <limits.h>
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

find . -name "brcm_patchram_plus.c" -type f

Repository: armbian/build

Length of output: 104


🏁 Script executed:

sed -n '107,130p' ./packages/bsp/orangepirv2/brcm_patchram_plus.c

Repository: armbian/build

Length of output: 443


🏁 Script executed:

grep -n "unistd.h" ./packages/bsp/orangepirv2/brcm_patchram_plus.c

Repository: armbian/build

Length of output: 39


🏁 Script executed:

grep -nE "(read|write|close|usleep|sleep|alarm)\s*\(" ./packages/bsp/orangepirv2/brcm_patchram_plus.c | head -20

Repository: armbian/build

Length of output: 740


🏁 Script executed:

# Check what headers might be including unistd.h indirectly
# Also check the C standard to see if unistd.h is required

# First, let's see how this file is compiled (look for build files)
find . -name "*.mk" -o -name "Makefile" -o -name "*.cmake" | grep -i orange

Repository: armbian/build

Length of output: 39


🏁 Script executed:

# Verify the context around the proposed fix location
sed -n '110,115p' ./packages/bsp/orangepirv2/brcm_patchram_plus.c

Repository: armbian/build

Length of output: 142


Add <unistd.h> for POSIX I/O prototypes

This file uses read(), write(), close(), usleep(), and alarm() without including <unistd.h>, which will cause implicit function declaration warnings or build failures with strict C flags.

🛠️ Proposed fix
 `#include` <stdlib.h>
+#include <unistd.h>
 
 `#ifdef` ANDROID
 `#include` <termios.h>
📝 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
#include <stdio.h>
#include <getopt.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#ifdef ANDROID
#include <termios.h>
#else
#include <sys/termios.h>
#include <sys/ioctl.h>
#include <limits.h>
#endif
`#include` <stdio.h>
`#include` <getopt.h>
`#include` <errno.h>
`#include` <sys/types.h>
`#include` <sys/stat.h>
`#include` <fcntl.h>
`#include` <stdlib.h>
`#include` <unistd.h>
`#ifdef` ANDROID
`#include` <termios.h>
`#else`
`#include` <sys/termios.h>
`#include` <sys/ioctl.h>
`#include` <limits.h>
`#endif`
🧰 Tools
🪛 Clang (14.0.6)

[error] 107-107: 'stdio.h' file not found

(clang-diagnostic-error)

🤖 Prompt for AI Agents
In `@packages/bsp/orangepirv2/brcm_patchram_plus.c` around lines 107 - 123, This
source uses POSIX I/O functions (read, write, close) and timing functions
(usleep, alarm) without including the POSIX header; add `#include` <unistd.h> near
the other system headers so functions like read(), write(), close(), usleep(),
and alarm() have correct prototypes and avoid implicit-declaration
warnings/errors in brcm_patchram_plus.c.

Comment on lines +331 to +344
parse_bdaddr(char *optarg)
{
int bd_addr[6];
int i;

sscanf(optarg, "%02X:%02X:%02X:%02X:%02X:%02X",
&bd_addr[5], &bd_addr[4], &bd_addr[3],
&bd_addr[2], &bd_addr[1], &bd_addr[0]);

for (i = 0; i < 6; i++) {
hci_write_bd_addr[4 + i] = bd_addr[i];
}

bdaddr_flag = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

find . -name "brcm_patchram_plus.c" -type f

Repository: armbian/build

Length of output: 104


🏁 Script executed:

wc -l ./packages/bsp/orangepirv2/brcm_patchram_plus.c

Repository: armbian/build

Length of output: 108


🏁 Script executed:

sed -n '325,355p' ./packages/bsp/orangepirv2/brcm_patchram_plus.c

Repository: armbian/build

Length of output: 442


🏁 Script executed:

rg "parse_cmd_line|parse_bdaddr" ./packages/bsp/orangepirv2/brcm_patchram_plus.c -A 2 -B 2

Repository: armbian/build

Length of output: 461


🏁 Script executed:

sed -n '660,750p' ./packages/bsp/orangepirv2/brcm_patchram_plus.c

Repository: armbian/build

Length of output: 1445


🏁 Script executed:

rg "hci_write_bd_addr" ./packages/bsp/orangepirv2/brcm_patchram_plus.c -B 3 -A 3

Repository: armbian/build

Length of output: 558


🏁 Script executed:

sed -n '400,500p' ./packages/bsp/orangepirv2/brcm_patchram_plus.c

Repository: armbian/build

Length of output: 3001


🏁 Script executed:

sed -n '500,600p' ./packages/bsp/orangepirv2/brcm_patchram_plus.c

Repository: armbian/build

Length of output: 1969


🏁 Script executed:

sed -n '330,350p' ./packages/bsp/orangepirv2/brcm_patchram_plus.c

Repository: armbian/build

Length of output: 389


🏁 Script executed:

sed -n '360,430p' ./packages/bsp/orangepirv2/brcm_patchram_plus.c

Repository: armbian/build

Length of output: 992


Validate BD_ADDR parsing result

If sscanf doesn't parse all 6 bytes, the code writes uninitialized values into the HCI command buffer. Return an error to allow parse_cmd_line to surface usage.

Proposed fix
-	sscanf(optarg, "%02X:%02X:%02X:%02X:%02X:%02X",
-		&bd_addr[5], &bd_addr[4], &bd_addr[3],
-		&bd_addr[2], &bd_addr[1], &bd_addr[0]);
+	if (sscanf(optarg, "%02X:%02X:%02X:%02X:%02X:%02X",
+		&bd_addr[5], &bd_addr[4], &bd_addr[3],
+		&bd_addr[2], &bd_addr[1], &bd_addr[0]) != 6) {
+		fprintf(stderr, "invalid bd_addr: %s\n", optarg);
+		return 1;
+	}
🤖 Prompt for AI Agents
In `@packages/bsp/orangepirv2/brcm_patchram_plus.c` around lines 331 - 344, In
parse_bdaddr, check the return value of sscanf and ensure it parsed all 6 bytes
before writing into hci_write_bd_addr; if sscanf does not return 6, do not touch
hci_write_bd_addr or set bdaddr_flag and instead return an error (non-zero) so
parse_cmd_line can surface usage; only copy bd_addr into hci_write_bd_addr[4 +
i] and set bdaddr_flag = 1 when sscanf succeeded.

Comment on lines +617 to +635
read_event(int fd, uchar *buffer)
{
int i = 0;
int len = 3;
int count;

while ((count = read(fd, &buffer[i], len)) < len) {
i += count;
len -= count;
}

i += count;
len = buffer[2];

while ((count = read(fd, &buffer[i], len)) < len) {
i += count;
len -= count;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

find . -name "brcm_patchram_plus.c" -type f

Repository: armbian/build

Length of output: 104


🏁 Script executed:

wc -l ./packages/bsp/orangepirv2/brcm_patchram_plus.c

Repository: armbian/build

Length of output: 108


🏁 Script executed:

sed -n '617,635p' ./packages/bsp/orangepirv2/brcm_patchram_plus.c

Repository: armbian/build

Length of output: 337


🏁 Script executed:

sed -n '694,705p' ./packages/bsp/orangepirv2/brcm_patchram_plus.c

Repository: armbian/build

Length of output: 247


🏁 Script executed:

rg -n "read_fully|ssize_t.*read" ./packages/bsp/orangepirv2/brcm_patchram_plus.c

Repository: armbian/build

Length of output: 39


🏁 Script executed:

sed -n '680,710p' ./packages/bsp/orangepirv2/brcm_patchram_plus.c

Repository: armbian/build

Length of output: 602


🏁 Script executed:

sed -n '650,695p' ./packages/bsp/orangepirv2/brcm_patchram_plus.c

Repository: armbian/build

Length of output: 620


🏁 Script executed:

rg -n "errno|perror|EINTR" ./packages/bsp/orangepirv2/brcm_patchram_plus.c

Repository: armbian/build

Length of output: 375


🏁 Script executed:

sed -n '806,820p' ./packages/bsp/orangepirv2/brcm_patchram_plus.c

Repository: armbian/build

Length of output: 407


Handle short reads and errors in read_event and proc_patchram

Both read_event (lines 617-635) and proc_patchram (lines 694-705) have dangerous error-handling gaps:

  • read_event assumes read() always returns the requested length; if it returns 0 (EOF) or -1 (EINTR/error), the condition count < len never becomes false, causing an infinite loop.
  • proc_patchram ignores the return value of read() at line 699 entirely, and lacks buffer size validation for the len variable read from the file.

The codebase already demonstrates proper error handling elsewhere (e.g., lines 813–820), but this pattern is missing here. Implement a robust read helper that handles EOF, EINTR, and other errors, and apply it to both functions.

🤖 Prompt for AI Agents
In `@packages/bsp/orangepirv2/brcm_patchram_plus.c` around lines 617 - 635, Create
and use a robust read helper (e.g., safe_read or read_all) that wraps read(2) in
a loop handling EINTR, returns -1 on error, 0 on EOF, or the total bytes read on
success; replace the ad-hoc read loops in read_event and the lone read in
proc_patchram to call this helper, check its return value and abort/propagate
errors instead of looping forever. In read_event (function read_event) use the
helper to read the 3-byte header, validate the header result (handle EOF/err),
extract len = buffer[2] and validate that len does not exceed the remaining
buffer capacity before reading the payload with the helper; in proc_patchram use
the same helper to read both header and payload, check the returned byte counts,
and reject or handle short/EOF/error results properly. Ensure all error paths
return/cleanup consistently and do not assume read() will always fulfill the
requested length.

Comment on lines +30 to +41
+#ifdef CONFIG_SOC_SPACEMIT
+ {
+ int gpio = of_get_named_gpio(i2c_client->dev.of_node, "earphone-sw-gpio", 0);
+ if (0 <= gpio) {
+ devm_gpio_request_one(&i2c_client->dev, gpio,
+ GPIOF_OUT_INIT_HIGH, NULL);
+ }
+ else {
+ dev_info(&i2c_client->dev, "No earphone-sw-gpio\n");
+ }
+ }
+#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Missing error handling and kernel coding style violation.

  1. The return value of devm_gpio_request_one() is not checked. While this GPIO appears optional, silently ignoring failures may mask configuration issues.

  2. The else placement on line 37 violates kernel coding style (should be } else { on same line).

🔧 Proposed fix
 `#ifdef` CONFIG_SOC_SPACEMIT
-	{
-		int gpio = of_get_named_gpio(i2c_client->dev.of_node, "earphone-sw-gpio", 0);
-		if (0 <= gpio) {
-			devm_gpio_request_one(&i2c_client->dev, gpio,
-				GPIOF_OUT_INIT_HIGH, NULL);
-		}
-		else {
-			dev_info(&i2c_client->dev, "No earphone-sw-gpio\n");
-		}
+	{
+		int gpio = of_get_named_gpio(i2c_client->dev.of_node, "earphone-sw-gpio", 0);
+		if (gpio >= 0) {
+			int ret = devm_gpio_request_one(&i2c_client->dev, gpio,
+				GPIOF_OUT_INIT_HIGH, "earphone-sw");
+			if (ret)
+				dev_warn(&i2c_client->dev, "Failed to request earphone-sw-gpio: %d\n", ret);
+		} else {
+			dev_info(&i2c_client->dev, "No earphone-sw-gpio\n");
+		}
 	}
 `#endif`
📝 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
+#ifdef CONFIG_SOC_SPACEMIT
+ {
+ int gpio = of_get_named_gpio(i2c_client->dev.of_node, "earphone-sw-gpio", 0);
+ if (0 <= gpio) {
+ devm_gpio_request_one(&i2c_client->dev, gpio,
+ GPIOF_OUT_INIT_HIGH, NULL);
+ }
+ else {
+ dev_info(&i2c_client->dev, "No earphone-sw-gpio\n");
+ }
+ }
+#endif
`#ifdef` CONFIG_SOC_SPACEMIT
{
int gpio = of_get_named_gpio(i2c_client->dev.of_node, "earphone-sw-gpio", 0);
if (gpio >= 0) {
int ret = devm_gpio_request_one(&i2c_client->dev, gpio,
GPIOF_OUT_INIT_HIGH, "earphone-sw");
if (ret)
dev_warn(&i2c_client->dev, "Failed to request earphone-sw-gpio: %d\n", ret);
} else {
dev_info(&i2c_client->dev, "No earphone-sw-gpio\n");
}
}
`#endif`
🤖 Prompt for AI Agents
In
`@patch/kernel/archive/spacemit-6.18/015-OrangePi-RV2-fix-internal-audio-activate-headphone-g.patch`
around lines 30 - 41, The new CONFIG_SOC_SPACEMIT block must check and handle
errors from of_get_named_gpio and devm_gpio_request_one and fix the kernel style
for the else placement: after calling of_get_named_gpio for "earphone-sw-gpio"
on i2c_client->dev.of_node, only call devm_gpio_request_one if gpio >= 0,
capture its return value, and on failure call dev_err(&i2c_client->dev, "...:
%d\n", ret) (or dev_warn if you prefer optional) instead of ignoring it; also
change the closing brace/else to follow kernel style (`} else {`) when falling
back to dev_info for "No earphone-sw-gpio".

Comment on lines +142 to +149
rf_pwrseq: rf-pwrseq {
compatible = "spacemit,rf-pwrseq";
//vdd-supply = <&ldo_7>;
//vdd_voltage = <3300000>;
io-supply = <&dcdc_3>;
io_voltage = <1800000>;
pwr-gpios;// = <&gpio 67 0>;
status = "okay";
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's read the target file to see the current state of the rf_pwrseq node
cat -n patch/kernel/archive/spacemit-6.6/dt/x1_orangepi-rv2.dts | sed -n '140,160p'

Repository: armbian/build

Length of output: 701


🏁 Script executed:

# Also check the other issues mentioned in the scratchpad at lines 271-287 and 826-834
cat -n patch/kernel/archive/spacemit-6.6/dt/x1_orangepi-rv2.dts | sed -n '269,290p'

Repository: armbian/build

Length of output: 568


🏁 Script executed:

cat -n patch/kernel/archive/spacemit-6.6/dt/x1_orangepi-rv2.dts | sed -n '824,840p'

Repository: armbian/build

Length of output: 471


🏁 Script executed:

# Let's look for any device tree binding docs or comments about rf-pwrseq in the codebase
find . -type f \( -name "*.txt" -o -name "*.yaml" -o -name "*.md" \) | xargs grep -l "rf-pwrseq" 2>/dev/null | head -5

Repository: armbian/build

Length of output: 39


🏁 Script executed:

# Search for how *-gpios properties are typically used in this device tree file
rg "gpios\s*=" patch/kernel/archive/spacemit-6.6/dt/x1_orangepi-rv2.dts | head -10

Repository: armbian/build

Length of output: 465


🏁 Script executed:

# Search for spacemit,rf-pwrseq binding documentation
find . -type f \( -name "*.txt" -o -name "*.yaml" -o -name "*.md" \) -path "*/bindings/*" | xargs grep -l "rf-pwrseq\|spacemit" 2>/dev/null | head -10

Repository: armbian/build

Length of output: 39


🏁 Script executed:

# Search for any kernel driver code that handles rf-pwrseq
find . -type f \( -name "*.c" -o -name "*.h" \) | xargs grep -l "rf.pwrseq\|rf_pwrseq" 2>/dev/null | head -5

Repository: armbian/build

Length of output: 39


🏁 Script executed:

# Look for device tree validation or binding examples in the codebase
rg "pwr-gpios" --type yaml --type txt 2>/dev/null | head -20

Repository: armbian/build

Length of output: 39


🏁 Script executed:

# Check if there are other similar pwrseq implementations in the tree for reference
rg "pwrseq.*compatible" patch/kernel/archive/spacemit-6.6/dt/ --type dts 2>/dev/null

Repository: armbian/build

Length of output: 39


🌐 Web query:

device tree gpio properties specification format requirements

💡 Result:

GPIO properties in Device Tree: format & requirements

1) Consumer-side GPIO properties (*-gpios)

  • GPIOs are described in consumer nodes using one or more properties named [<function>-]gpios (preferred). Older [<function>-]gpio is deprecated for new bindings. [1]
  • The property value is a phandle-array made of one or more entries of the form:
    <&gpio_controller ...gpio-specifier-cells...>, where the number of specifier cells is defined by the controller’s #gpio-cells. [1]
  • Multiple GPIOs in one property are discouraged unless they serve the same function (e.g., a parallel bus). Otherwise use separate, clearly named properties (e.g., reset-gpios, enable-gpios). [1]

Canonical example

reset-gpios = <&gpio1 12 GPIO_ACTIVE_LOW>;

Here &gpio1 is the GPIO controller phandle; 12 and GPIO_ACTIVE_LOW are the controller-defined specifier cells (common convention: line offset + flags). [1]

2) GPIO controller node requirements
A node that provides GPIOs (a GPIO controller) must contain: [1]

  • gpio-controller; (empty boolean property)
  • #gpio-cells = <N>; (how many cells follow the phandle in each GPIO specifier)

Common optional controller properties include ngpios (how many lines are actually usable) and mapping-related properties like gpio-ranges. [1]

3) Specifier cell conventions / flags

  • The meaning of the GPIO specifier cells is controller-specific, but Linux strongly recommends a 2-cell form:
    1. local GPIO line offset/number
    2. consumer flags bitfield (polarity, open-drain, etc.) [1]
  • When the last cell is a generic flags bitfield, use the standard macros from include/dt-bindings/gpio/gpio.h (e.g., GPIO_ACTIVE_LOW, GPIO_ACTIVE_HIGH). [1][2]

4) What a “phandle” is (background)

  • A phandle is a unique numeric identifier for a node, used by other nodes to reference it (DTS source typically uses &label which compiles to a phandle). [3]

Sources: Linux GPIO devicetree binding (Documentation/devicetree/bindings/gpio/gpio.txt) for naming/format/controller requirements and recommended practices [1], Linux kernel GPIO DT mapping overview [2], Devicetree Specification basics for phandle semantics [3].

References
[1] (git.ti.com)
[2] (kernel.org)
[3] (devicetree-specification.readthedocs.io)

Citations:


🌐 Web query:

Linux device tree *-gpios property bare empty value invalid

💡 Result:

In Linux devicetree, a *-gpios property is (by convention and in most bindings) a GPIO specifier list, i.e. a phandle-array like:

reset-gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;

A bare/empty property:

reset-gpios;

is therefore invalid for *-gpios, because an empty value is only meaningful for boolean “flag” properties (presence/absence conveys true/false). (devicetree-specification.readthedocs.io) The Linux DT binding schema examples likewise treat foo-gpios as a property that carries items (not a boolean). (docs.kernel.org)

What to do instead:

  • If the GPIO is optional: omit the *-gpios property entirely (and ensure the driver/binding defines it as optional).
  • If you need to express “no GPIO connected” while keeping the property: that generally requires a binding-defined convention (driver-specific). The generic DT rules don’t define an “empty gpios means none” encoding—so check the specific binding/driver and follow what it documents.

If you share the exact property name (e.g., reset-gpios, enable-gpios) and the device/binding, I can tell you the correct representation for that specific case.

Citations:


pwr-gpios property is missing required GPIO specifier

The bare pwr-gpios; declaration violates the device tree specification: *-gpios properties must contain phandle-array GPIO specifiers (<&gpio line flags>), not empty values. This will prevent proper GPIO parsing and cause the rf-pwrseq driver to fail probing. The commented value suggests the intended spec was <&gpio 67 0>, so either restore it or remove the property if unused.

🛠️ Proposed fix (if GPIO67 is the intended power-enable line)
-		pwr-gpios;//  = <&gpio 67 0>;
+		pwr-gpios = <&gpio 67 GPIO_ACTIVE_HIGH>;
📝 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
rf_pwrseq: rf-pwrseq {
compatible = "spacemit,rf-pwrseq";
//vdd-supply = <&ldo_7>;
//vdd_voltage = <3300000>;
io-supply = <&dcdc_3>;
io_voltage = <1800000>;
pwr-gpios;// = <&gpio 67 0>;
status = "okay";
rf_pwrseq: rf-pwrseq {
compatible = "spacemit,rf-pwrseq";
//vdd-supply = <&ldo_7>;
//vdd_voltage = <3300000>;
io-supply = <&dcdc_3>;
io_voltage = <1800000>;
pwr-gpios = <&gpio 67 GPIO_ACTIVE_HIGH>;
status = "okay";
🤖 Prompt for AI Agents
In `@patch/kernel/archive/spacemit-6.6/dt/x1_orangepi-rv2.dts` around lines 142 -
149, The rf-pwrseq node declares a bare pwr-gpios property which is invalid;
either restore the intended GPIO phandle specifier (use pwr-gpios = <&gpio 67
0>; inside the rf_pwrseq: rf-pwrseq node so the driver can parse the
power-enable line) or remove the pwr-gpios property entirely if that GPIO is not
used; update the rf_pwrseq node accordingly (refer to the rf_pwrseq: rf-pwrseq
node and the commented '<&gpio 67 0>' specifier).

Comment on lines +271 to +287
eeprom@50{
compatible = "atmel,24c02";
reg = <0x50>;
#address-cells = <1>;
#size-cells = <1>;

power-domains = <&power K1X_PMU_DUMMY_PWR_DOMAIN>;
status = "disabled";

mac_address0: mac_address0@0 {
reg = <0x0 6>;
};

mac_address1: mac_address1@6 {
reg = <0x6 6>;
};
};
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cat patch/kernel/archive/spacemit-6.6/dt/x1_orangepi-rv2.dts | head -400 | tail -250

Repository: armbian/build

Length of output: 4958


🏁 Script executed:

# Search for eth0 and eth1 definitions in the file
rg "eth0|eth1" patch/kernel/archive/spacemit-6.6/dt/x1_orangepi-rv2.dts -A 5 -B 2

Repository: armbian/build

Length of output: 319


🏁 Script executed:

# Search for references to mac_address0 or mac_address1
rg "mac_address" patch/kernel/archive/spacemit-6.6/dt/x1_orangepi-rv2.dts -B 2 -A 2

Repository: armbian/build

Length of output: 390


🏁 Script executed:

# Get the full context around the eeprom section (lines 271-287)
sed -n '260,310p' patch/kernel/archive/spacemit-6.6/dt/x1_orangepi-rv2.dts

Repository: armbian/build

Length of output: 1167


EEPROM disabled while eth0/eth1 reference its MAC address cells

Both eth0 and eth1 use nvmem-cells to reference mac_address0 and mac_address1 from the EEPROM, but the EEPROM node has status = "disabled". This prevents NVMEM provider registration, causing MAC address resolution to fail and the NICs to fall back to random MACs. Either enable the EEPROM or move the MAC cell definitions to an enabled provider.

🤖 Prompt for AI Agents
In `@patch/kernel/archive/spacemit-6.6/dt/x1_orangepi-rv2.dts` around lines 271 -
287, The EEPROM node eeprom@50 is marked status = "disabled" while eth0/eth1
reference its nvmem-cells mac_address0 and mac_address1, so enable the provider
or relocate the cells: either remove or change status = "disabled" to status =
"okay" on the eeprom@50 node so the NVMEM provider registers, or move the
mac_address0 and mac_address1 child nodes into an enabled nvmem provider node
that eth0/eth1 can reference; ensure the referenced symbols (eeprom@50,
mac_address0, mac_address1, and the eth0/eth1 nvmem-cells usage) match after the
change.

Comment on lines +826 to +834
mdio-bus {
#address-cells = <0x1>;
#size-cells = <0x0>;
rgmii0: phy@0 {
compatible = "ethernet-phy-ieee802.3-c22";
device_type = "ethernet-phy";
reg = <0x1>;
phy-mode = "rgmii";
};
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Check if the file exists and read the relevant section
fd -t f "x1_orangepi-rv2.dts" --exec wc -l {} \;

Repository: armbian/build

Length of output: 185


🏁 Script executed:

# Find and read the specific file
find . -name "x1_orangepi-rv2.dts" -type f

Repository: armbian/build

Length of output: 175


🏁 Script executed:

# Read the specific section mentioned in the review
sed -n '820,840p' ./patch/kernel/archive/spacemit-6.6/dt/x1_orangepi-rv2.dts | cat -n

Repository: armbian/build

Length of output: 561


🏁 Script executed:

# Search for any references to phy@0 or rgmii0 in the spacemit-6.6 device tree file
rg "phy@0|rgmii0" ./patch/kernel/archive/spacemit-6.6/dt/x1_orangepi-rv2.dts

Repository: armbian/build

Length of output: 99


🏁 Script executed:

# Also check if there are similar issues in the spacemit-6.18 version
sed -n '820,840p' ./patch/kernel/archive/spacemit-6.18/dt/x1_orangepi-rv2.dts | cat -n

Repository: armbian/build

Length of output: 535


PHY unit-address should match reg

phy@0 uses reg = <0x1>, which triggers unit_address_vs_reg warnings in dtbs_check. Rename the node to match the address.

🛠️ Proposed fix
-		rgmii0: phy@0 {
+		rgmii0: phy@1 {
 			compatible = "ethernet-phy-ieee802.3-c22";
 			device_type = "ethernet-phy";
 			reg = <0x1>;
 			phy-mode = "rgmii";
 		};
📝 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
mdio-bus {
#address-cells = <0x1>;
#size-cells = <0x0>;
rgmii0: phy@0 {
compatible = "ethernet-phy-ieee802.3-c22";
device_type = "ethernet-phy";
reg = <0x1>;
phy-mode = "rgmii";
};
mdio-bus {
`#address-cells` = <0x1>;
`#size-cells` = <0x0>;
rgmii0: phy@1 {
compatible = "ethernet-phy-ieee802.3-c22";
device_type = "ethernet-phy";
reg = <0x1>;
phy-mode = "rgmii";
};
🤖 Prompt for AI Agents
In `@patch/kernel/archive/spacemit-6.6/dt/x1_orangepi-rv2.dts` around lines 826 -
834, The node name phy@0 under mdio-bus has reg = <0x1>, causing
unit_address_vs_reg warnings; rename the node to phy@1 (matching the reg value)
so the unit address matches reg, i.e., update the node label from "phy@0" to
"phy@1" (retain properties like compatible, device_type, reg, phy-mode and the
rgmii0 label as-is) to eliminate the dtbs_check warning.

Comment on lines +15 to +21
@@ -444,6 +444,7 @@ const struct flash_info spi_nor_ids[] = {
{ INFO("w25m512jw", 0xef6119, 0, 64 * 1024, 1024, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
{ INFO("w25m512jv", 0xef7119, 0, 64 * 1024, 1024, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
{ INFO("w25h02jv", 0xef9022, 0, 64 * 1024, 4096, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
+ { INFO("XM25QH128A", 0x204118, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
#endif
#ifdef CONFIG_SPI_FLASH_XMC
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

XM25QH128A is under the wrong config guard.
It’s inserted before the #ifdef CONFIG_SPI_FLASH_XMC block, so it will be compiled only if the preceding vendor option is enabled. If the intent is XMC, the ID can be missing when only CONFIG_SPI_FLASH_XMC is set.

🐛 Proposed fix
-	{ INFO("XM25QH128A", 0x204118, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
-#endif
-#ifdef CONFIG_SPI_FLASH_XMC
+#endif
+#ifdef CONFIG_SPI_FLASH_XMC
+	{ INFO("XM25QH128A", 0x204118, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
🤖 Prompt for AI Agents
In `@patch/u-boot/legacy/u-boot-spacemit-k1/006-orangepi-rv2-spi-flash.patch`
around lines 15 - 21, The XM25QH128A entry for the spi_nor_ids array is placed
outside the CONFIG_SPI_FLASH_XMC guard so it won't be compiled when only
CONFIG_SPI_FLASH_XMC is set; move the { INFO("XM25QH128A", 0x204118, 0, 64 *
1024, 256, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) } line into the
`#ifdef` CONFIG_SPI_FLASH_XMC block (or wrap that single entry with `#ifdef`
CONFIG_SPI_FLASH_XMC / `#endif`) so the device ID is included whenever the XMC
driver is enabled and remains excluded otherwise.

Comment on lines +44 to +46
+/ {
+ model = "ky x1 orangepi-rv2 board";
+
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Model string appears to be a copy-paste error.

The x1_orangepi-r2s.dts file has model = "ky x1 orangepi-rv2 board" but this is the R2S board, not RV2. The model string should likely be "ky x1 orangepi-r2s board" to distinguish the two boards.

🐛 Proposed fix
 / {
-	model = "ky x1 orangepi-rv2 board";
+	model = "ky x1 orangepi-r2s board";
🤖 Prompt for AI Agents
In `@patch/u-boot/legacy/u-boot-spacemit-k1/007-orangepi-rv2-r2s-fit.patch` around
lines 44 - 46, The model string in the device tree node for x1_orangepi-r2s is
incorrect—update the model property that currently reads "ky x1 orangepi-rv2
board" to the correct board name "ky x1 orangepi-r2s board" so the node for
x1_orangepi-r2s reflects the R2S hardware (locate the node with the model
property in x1_orangepi-r2s.dts and replace the string).

@peterwillcn
Copy link

R2S board photo
5d133a7c0ae69b122f48ed3c96dcf3bf
d3e01a1e1defe9b6d123f5f00af16a06
317d71cf8808d52696fa639847d9ec8c

@sven-ola sven-ola changed the title Orangepi rv2 Orangepi RV2 Board with Spacemit-Famliy both Current and Edge Jan 28, 2026
sven-ola added a commit to sven-ola/armbian.github.io that referenced this pull request Jan 28, 2026
The orangepirv2.png image was taken from my board. I use it
with an UART (wires cut in photo) and a Samsung NVME 128 Gb
SSD.

The orangepir2s.png is for reference only. I do not own this
board, but I asked at the OpenWrt forum for a photo. Github
member https://github.com/peterwillcn was so kind and add
this photo of his R2S board to the merge RQ, see
armbian/build#9299 (comment)

Signed-off-by: Sven-Ola Tuecke <[email protected]>
@sven-ola
Copy link
Author

Thanks to @peterwillcn for making this photo of his OrangePi R2S available for this PR. I use it together with photo from my board to create the necessary pull RQ, see armbian/armbian.github.io#201

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

02 Milestone: First quarter release BSP Board Support Packages Desktop Graphical user interface Framework Framework components Needs review Seeking for review Patches Patches related to kernel, U-Boot, ... size/large PR with 250 lines or more

Development

Successfully merging this pull request may close these issues.

2 participants