Skip to content

rockchip/cortexa7: add Luckfox Pico Mini A/B board support - #9

Closed
rgrizzell wants to merge 9 commits into
plan44:p44_24.10from
rgrizzell:rgrizzell_24.10
Closed

rgrizzell wants to merge 9 commits into
plan44:p44_24.10from
rgrizzell:rgrizzell_24.10

Conversation

@rgrizzell

@rgrizzell rgrizzell commented Apr 10, 2026

Copy link
Copy Markdown

Luckfox Pico Mini A/B

Adds full OpenWRT target support for the Luckfox Pico Mini A/B with SD card and SPI NAND booting, enabled by the new uboot-luckfox package.

BusyBox v1.36.1 (2025-06-23 20:40:36 UTC) built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 24.10.2, r28739-d9340319c6
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:~# uname -a
Linux OpenWrt 6.6.93+ #0 Mon Jun 23 20:40:36 2025 armv7l GNU/Linux

uboot-luckfox

This new package was derived from the uboot-rockchip package with the necessary patches applied from the Luckfox Pico SDK. For specific details on the boot-chain, see LUCKFOX_BOOT.md.

SD Card Boot -- WORKING

The Mini A/B boots successfully from SD card into OpenWRT. The full image pipeline (idblock + U-Boot + kernel FIT + rootfs) generates correctly and the system reaches a login prompt. Sysupgrade is functional.

Flashing is easy. Uncompress and write the image to the card.

zcat bin/targets/rockchip/cortexa7/openwrt-rockchip-cortexa7-luckfox_pico-mini-squashfs-sysupgrade.img.gz | sudo dd of=/dev/sdX bs=4M status=progress conv=fsync

If using the SD card on the Luckfox Pico Mini B, the NAND chip is available for extra storage.

SPI NAND Boot -- WORKING

The Mini B image pipeline is complete and generates a valid nand-flash.img (env + idblock + uboot + kernel FIT + UBI at correct offsets). The Thunderboot (TB) SPL loads the kernel FIT directly from the "boot" NAND partition; normal boot does not use the "uboot" partition. The kernel FIT includes uboot-ignore=1 in all hash nodes to bypass RSA signature verification.

Flashing is more difficult, and may require shorting pins on the NAND to recover back into download mode.

alias rkdeveloptool='./build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/rkbin-rv1106/rkbin-2025.06.13~74213af1/tools/rkdeveloptool'
sudo rkdeveloptool db bin/targets/rockchip/cortexa7/openwrt-rockchip-cortexa7-luckfox_pico-mini-nand-loader.bin
sudo rkdeveloptool wl 0 bin/targets/rockchip/cortexa7/openwrt-rockchip-cortexa7-luckfox_pico-mini-b-squashfs-nand-flash.img
sudo rkdeveloptool rd

Switching From NAND to SD Card Boot

DO NOT RUN ⚠️rkdeveloptool ef⚠️ -- See comment below. Switching back to SD card booting requires replacing the boot partitions with zeros, NOT erasing flash.

dd if=/dev/zero bs=512 count=1024 of=/tmp/nand-clear.img
sudo rkdeveloptool wl 0 /tmp/nand-clear.img
sudo rkdeveloptool rd

Why is rkdeveloptool run as root?

The rkdeveloptool communicates with the USB device via the file system. The file is question is typically owned by root, so the rkdeveloptool must also be run as root to read/write to the file.

To update the system so the USB device can be accessed without root, run these steps (Linux-only):

  1. Start by adding yourself to the plugdev group.
    sudo usermod -aG plugdev $USER
    
  2. Next, create a new udev rule file and paste the content.
    # /etc/udev/rules.d/99-rkdeveloptool.rules                                                                      
    SUBSYSTEM=="usb", ATTR{idVendor}=="2207", MODE="0666", GROUP="plugdev"
    
  3. Reboot your machine. When logging back in, verify the group and permission changes.
    id -Gn | grep plugdev
    rkdeveloptool ld
    

Adds full OpenWRT target support for the Luckfox Pico Mini A (SD card
boot) and initial support for the Luckfox Pico Mini B (SPI NAND boot).

**Luckfox Pico Mini A — SD card boot: WORKING**
The Mini A boots successfully from SD card into OpenWRT. The full image
pipeline (idblock + U-Boot + kernel FIT + rootfs) generates correctly and
the system reaches a login prompt. Sysupgrade is functional.

Boot log fixes applied and verified on hardware:
- Disabled CONFIG_USB_MASS_STORAGE (legacy gadget failed with -EINVAL at
  boot; USB gadget support retained via configfs)
- nvmem/rockchip-otp: set add_legacy_fixed_of_cells=true so OTP sub-node
  cells register correctly in Linux 6.6 (fixes rockchip-cpuinfo -ENOENT)
- sound/soc/rockchip: add rv1106-i2s-tdm to match table (fixes
  asoc-simple-card infinite -EPROBE_DEFER)
- soc/rockchip: remove duplicate pm_domains.o from Makefile (fixes
  "Driver already registered" error; upstream moved to drivers/pmdomain/)
- rv1103g-luckfox-pico-mini-a.dts: disable sc4336/sc530ai camera sensors
  (both claim i2c4 address 0x30, causing -EBUSY; Mini A has no camera)

**Luckfox Pico Mini B — SPI NAND boot: NOT YET WORKING**
The Mini B image pipeline is complete and generates a valid nand-flash.img
(env + idblock + uboot + kernel FIT + UBI at correct offsets). The
Thunderboot (TB) SPL loads the kernel FIT directly from the "boot" NAND
partition; normal boot does not use the "uboot" partition. The kernel FIT
includes uboot-ignore=1 in all hash nodes to bypass RSA signature
verification. Boot has not yet been hardware-validated.

Kernel patches (403–413):
- 403: RV1103B clock driver and bindings (from linux-stable/Lukas Zeller)
- 404: RV1103B pinctrl support (from linux-stable/Lukas Zeller)
- 405: RV1103B OTP/NVMEM support + legacy OF cell fix
- 406: GPIO v2.2 support for RV1103B
- 407: RV1103B RMII ethernet + optional stmmaceth clock
- 408: RV1103B FSPI support + unreachable code fix
- 409: RV1103B/RK3576 PWM v4 support adapted for kernel 6.6
- 410: RV1103B I2C support (autostop, reset control, GRF, suspend/resume)
- 411: ARM head UART diagnostics
- 412: Remove duplicate pm-domains driver from drivers/soc/rockchip/
- 413: Add rv1106-i2s-tdm to I2S-TDM match table

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rgrizzell

rgrizzell commented Apr 10, 2026

Copy link
Copy Markdown
Author

NAND ended up being a lot harder to build than SD Card. At some point I ran ⚠️ rkdeveloptool ef⚠️ at Claude's suggestion and it erased the Bad Block sector info programmed into the flash chip and I was unable to re-write to it.

Luckily it appears recoverable, but required a working Linux build or a SPI Flash programmer. I made Claude trudge through the former.

If I can fix up the NAND on the Mini B, I'll follow-up with another commit on this PR.

rgrizzell and others added 5 commits April 11, 2026 19:28
Suppress non-fatal U-Boot warnings and fix fw_printenv config on Mini A/B.

uboot-luckfox: bump to a65a1782 which downgrades four non-fatal printf()
calls to debug() -- DTB resource scan failures and SARADC download-key
read failure are expected at runtime and should not appear as errors.
Add PKG_SOURCE override with a commit-specific filename to prevent DL_DIR
collisions with other u-boot-2017.09 packages reusing the default name.

dts/rv1103g-luckfox-pico-mini-a: disable fiq_debugger node; the vendor
fiq-debugger driver has no upstream equivalent so the node produces
"Dropping the fwnode link to /interrupt-controller" on every boot.

cortexa7/base-files: add preinit hook 05_fw_env_config that creates
/tmp/fw_env.config from /proc/device-tree/compatible before board_detect
runs. /etc/fw_env.config is a symlink to /tmp/fw_env.config so
fw_printenv works correctly during preinit (before overlay mounts) on
both Mini A (mmcblk1) and Mini B (mtd0). Replaces the uci-defaults
approach which ran too late.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace three separate device profiles (mini-a, mini-b-sd, mini-b) with
two profiles that reflect boot media rather than PCB variant:

  luckfox_pico-mini      — SD card boot, works on both Mini A and Mini B.
  luckfox_pico-mini-nand — SPI NAND Thunderboot, Mini B only.

Mini A and Mini B are hardware-identical except for the onboard SPI NAND
chip. With SFC disabled in the SD DTS, the NAND's presence is invisible to
the kernel and a single image boots either board. SUPPORTED_DEVICES lists
both board compatibles so sysupgrade accepts the image on either variant.

DTS changes:
- rv1103g-luckfox-pico-mini.dts: combined SD DTS for both variants; SFC
  disabled, USB extcon/phy refs deleted (avoids EPROBE_DEFER), UART2
  explicitly enabled (prevents UART2 clock gate after clk_disable_unused),
  camera sensors disabled, console at 1500000n8.
- rv1103g-luckfox-pico-mini-nand.dts: renamed from mini-b.dts; primary
  compatible updated to luckfox,rv1103-luckfox-pico-mini-nand so the
  fw_env preinit hook can distinguish NAND from SD boot.
- rv1103g-luckfox-pico-mini-a.dts: deleted (superseded by mini.dts).

uboot-luckfox: bump to bc31674 which sets CONFIG_BAUDRATE=1500000 in the
SD defconfig, matching the NAND defconfig and kernel console= setting so
U-Boot, earlycon, and the kernel console all use a consistent baud rate.

fw_env preinit hook: luckfox,rv1103-luckfox-pico-mini-b and -mini-a both
route to SD env (/dev/mmcblk1); luckfox,rv1103-luckfox-pico-mini-nand
routes to NAND env (/dev/mtd0).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Enable &sfc on the SD boot DTS so Mini B's NAND is accessible for
recovery and bad-block scanning when booted from SD; Mini A probe
failure ("unknown raw ID") is harmless. Add explicit fspi_pins/fspi_cs0
pinctrl since rkbin only muxes SFC pins for NAND boot, not SD boot.

Enable &uart2 on the NAND DTS so the 8250 driver claims the UART2 clock
before clk_disable_unused() runs, keeping the debug console alive.

Add nandtest to DEFAULT_PACKAGES for both Mini A and Mini B profiles.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
End-to-end fixes to get the Mini B booting from SPI NAND without
manual intervention:

- Bump uboot-luckfox to f230b8a7: brings in the evb_rv1106.h
  CONFIG_BOOTCOMMAND "reset" -> "boot_fit" fix (the rkbin TB NAND SPL
  falls through to U-Boot proper instead of booting the kernel
  directly, so "reset" produced a boot loop), and the matching SD
  CONFIG_BOOTDELAY=3 so both defconfigs share the same interrupt
  window.

- Declare NAND partitions via fixed-partitions in the Mini B DTS.
  U-Boot hardcodes the parent SPI NAND as "spi-nand0" while Linux
  names it "spi2.0" from the SPI parent, so a single cmdline
  mtdparts=<id>:... cannot satisfy both (the mismatched side silently
  gets zero partitions). OF partitions let Linux create MTDs by
  label so ubi.mtd=ubi matches regardless of the parent name.

- Disable adc-keys on the NAND DTS. Mini B has no buttons on SARADC
  channel 0; the floating pin reads below the keyup threshold, which
  U-Boot interprets as the volume-up (download) key being pressed
  and diverts boot into rockusb download mode.

- Rework nand-combined-img layout: idblock size 256K -> 512K so the
  ~280K idblock fits without overlapping the uboot partition, uboot
  offset 512K -> 768K accordingly, drop the bad-block skip gap.

- Update env.spi-nand.txt: mtdparts prefix spi2.0 -> spi-nand0 to
  match U-Boot's internal MTD name, widen idblock to 512K to match
  the new on-flash layout, and document the bootcmd=boot_fit
  override (the compiled-in CONFIG_BOOTCOMMAND is what actually
  takes effect since ENVF does not import bootcmd).

Validated end-to-end on hardware 2026-04-19: full autoboot chain
(BROM -> DDR -> HPMCU -> NAND SPL -> U-Boot -> boot_fit -> kernel ->
UBI -> procd -> OpenWRT console) without manual interaction.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The RV1103 has an integrated 10/100 EPHY behind GMAC. The Mini carrier
exposes the PHY's MDI differential pairs on castellated pads, so a
physical link needs external magnetics + RJ45 — but the driver probes
cleanly without them and the interface reports NO-CARRIER until one is
attached. Verified on a bare Mini A: rk_gmac-dwmac binds, RK630 PHY
attaches at MDIO addr 2, eth0 enumerates with a valid MAC in
NO-CARRIER state.

Signed-off-by: Robert Grizzell <robert@grizzell.me>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@rgrizzell
rgrizzell marked this pull request as draft April 21, 2026 20:55
@rgrizzell
rgrizzell marked this pull request as ready for review April 22, 2026 16:02
@rgrizzell

Copy link
Copy Markdown
Author

@plan44 I'm content enough with the branch to hand this over to you and everyone else for further testing. I've done my best to avoid any breaking changes for other devices, but the ones using Luckfox chips will probably want to rebase atop the new uboot-luckfox build chain.

As for hardware testing, I only currently have the Mini A and Mini B. To test theses devices outside of the serial terminal, I had to create a branch that enables networking over USB. The Pico and Pico Mini A/B do not come with a physical Ethernet port, so this has allowed me to upload and test sysupgrades.

https://github.com/rgrizzell/openwrt/tree/rgrizzell_24.10-usb_gadget

It NOT included in this PR, but can be used for further validation if you need it.

@plan44

plan44 commented Apr 23, 2026

Copy link
Copy Markdown
Owner

Thanks a lot for this work @rgrizzell! This certainly goes into the right direction regarding generic rv110x based device support in OpenWrt. My current problem is that I am in midst of a criticial (paying the rent) project eating all my time, and that one is using the rv1103b which is quite different from the rv1103/06. I lack the hardware and time to confirm your rv1103/6 changes do not confict with my rv1103b stuff right now.

In particular, I noticed you took the step step from using the external patched kernel tree to kernel patches in 73ae38a. That's certainly the way to go! But in my current project, unfortunately, I'm not yet ready for that.

Another problem, where I have no idea yet how to navigate cleanly, is that target/linux/rockchip/cortexa7/config-6.6 currently is common to all cortexa7 rockchips, that is at least "our" rv110x family. However, there are options, e.g. around media and usb support, which might need to be set differently per target device.

So maybe we should create a more generic rv110x_24.10 target branch for things that are as ready as your PR (much more ready than what I have on p44_24.10 or even luz-WIP right now)? What do you think?

@rgrizzell

Copy link
Copy Markdown
Author

My current problem is that I am in midst of a criticial (paying the rent) project eating all my time, and that one is using the rv1103b which is quite different from the rv1103/06. I lack the hardware and time to confirm your rv1103/6 changes do not confict with my rv1103b stuff right now.

I appreciate you taking the time to at least review the PR. Hardware validation is not a huge concern at the moment. My primary goal with this branch was to prove that the OpenWRT build-chain could produce a valid U-Boot and Linux Kernel on these chips. I feel that much of the foundation is laid and we can hopefully focus on implementing device profiles and fixing bugs.

That said, I'll work on creating a "Support Matrix" separate from this so we can coordinate across the different SoCs. I don't yet have an rv1103b, but I'll also look into adding support for it into the uboot-luckfox package. It might just be a matter of adding the correct SPL.

Another problem, where I have no idea yet how to navigate cleanly, is that target/linux/rockchip/cortexa7/config-6.6 currently is common to all cortexa7 rockchips, that is at least "our" rv110x family. However, there are options, e.g. around media and usb support, which might need to be set differently per target device.

Thanks for calling this out, it was probably a mistake to modify this file directly. I'll check into it.

So maybe we should create a more generic rv110x_24.10 target branch for things that are as ready as your PR (much more ready than what I have on p44_24.10 or even luz-WIP right now)? What do you think?

Yes, please. If p44_24.10 is not the intended mainline branch, rv110x_24.10 will work. I initially branched off of it because it was the one with the most progress at the time. However, I do not want to conflict with your ongoing efforts.

@rgrizzell

Copy link
Copy Markdown
Author

I'll work on creating a "Support Matrix" separate from this so we can coordinate across the different SoCs.

This is probably better off in a Wiki or a separate markdown file so that others can make changes to it. For now this will suffice: #10

rgrizzell and others added 3 commits April 25, 2026 22:30
…hardcoding

Restore CONFIG_DEBUG_LL_INCLUDE="mach/debug-macro.S" (multi-platform)
and drop the hardcoded UART2 phys/virt at 0xff4c0000. The hardcoded
address is correct for RV1103/RV1106 but wrong for the RV1103B-based
Onion Omega4 EVB (UART at 0x20540000), which shares this subtarget.

DT-based earlycon=uart8250,mmio32,0xff4c0000 in the Mini's bootargs
provides the boot console independent of CONFIG_DEBUG_LL_*, so this
revert is invisible on the Luckfox Pico Mini A/B.

Incidental: kernel_oldconfig also stripped the explicit
'# CONFIG_USB_MASS_STORAGE is not set' line because it now matches
the generic baseline. Symbol stays disabled.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Two issues prevented sysupgrade from working on Mini A SD and Mini B
NAND:

1. board_name returns the DTS first compatible: SD image reports
   luckfox,rv1103-luckfox-pico-mini-b and NAND image reports
   luckfox,rv1103-luckfox-pico-mini-nand. The case statements in
   platform_do_upgrade and platform_check_image previously routed
   -mini-b to nand_do_upgrade and only -mini-a to the SD dd path. As a
   result Mini A SD (which reports -mini-b) hit the NAND handler, and
   Mini B NAND (-mini-nand) fell through to the default "not supported"
   branch. Re-route by image identity:
     -mini-nand        -> NAND case (nand_do_upgrade)
     -mini-a, -mini-b  -> SD case (dd to disk)

2. nand_do_platform_check looks up sysupgrade-PLACEHOLDER/CONTROL
   in the tar (where PLACEHOLDER is the runtime board_name with comma
   replaced by underscore), but the device profile name
   luckfox_pico-mini-nand does not match the vendor_model convention
   OpenWRT expects (would need luckfox_rv1103-luckfox-pico-mini-nand).
   Pass the tar directory name explicitly so the CONTROL file is found.

Verified end-to-end on Mini B hardware (2026-04-28): sysupgrade -T,
sysupgrade -n -v (clean), and config-preserve sysupgrade all succeed.
UBI rootfs and rootfs_data volumes attach cleanly post-reboot.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
patches 405-02, 411, 412, and 413 have been merged into
linux-stable (plan44 fork) at commit 76819cc47:
- 405-02: nvmem legacy-of-cells support for rockchip-otp
- 411: temporary UART head.S diagnostic (never intended to persist)
- 412: remove duplicate pm_domains driver from Makefile
- 413: add rv1106 support to rockchip i2s-tdm driver

The build uses CONFIG_KERNEL_GIT_CLONE_URI pointing to linux-stable,
which applies no patches — these files were dead code.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@plan44

plan44 commented Apr 30, 2026

Copy link
Copy Markdown
Owner

@rgrizzell I now created rv110x_24.10 off p44_24.10, made it the default branch of this repo and merged this PR there. Apparently github does not recognize this as merging automatically, so I'm closing the PR manually.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue while trying to build the image

2 participants