Skip to content

ci(ra4m1): drop upstream PR #16409 checkout, carry USB LDO VDCEN as patch 0002 - #39

Merged
cumin777 merged 2 commits into
Seeed-Studio:masterfrom
cumin777:ci/ra4m1-pin-v1.27.0-carry-vdcen-patch
Sep 29, 2026
Merged

cumin777 merged 2 commits into
Seeed-Studio:masterfrom
cumin777:ci/ra4m1-pin-v1.27.0-carry-vdcen-patch

Conversation

@cumin777

Copy link
Copy Markdown
Contributor

Problem (ref #28)

The workflow deleted the lib/micropython submodule, cloned micropython fresh, checked out upstream PR #16409 (WEACT_RA4M1_CORE board profile — open, unmerged since 2024-12-13), and patched main.c/mpconfigport.h with two line-addressed seds. Depending on a 2-year-old open PR is the fragile pattern #28 set out to remove.

What the board actually needs from #16409 — only 2 hunks

PR #16409 = 23 WEACT board-profile files + a USB LDO VDCEN enable:

  • Board profile: not needed. This repo already supplies the XIAO board via boards/seeed/xiao_ra4m1 (full FSP set: ra_cfg/, ra_gen/, linker, pins), and the renesas-ra Makefile natively supports BOARD_DIR.
  • USB LDO VDCEN: needed. boards/seeed/xiao_ra4m1/ra_gen/bsp_clock_cfg.h sets USB_CFG_LDO_REGULATOR (USB_CFG_ENABLE) — USB is powered from the internal LDO, so USBMC.VDCEN must be set for enumeration. Carried as micropython/patches/v1.27.0/0002-renesas-ra-usb-ldo-vdcen.patch, verified with git apply --check on the v1.27.0 tree after 0001 (anchors identical to the PR's: main.c:366, mphalport.h:64).

Everything else is upstream at v1.27.0: RA4M1 family (EK_RA4M1, RA4M1_CLICKER, ra4m1_af.csv), BOARD_DIR support. Both old seds are obsolete: main.c now ships mp_cstack_init_with_top() as-is; MICROPY_FATFS_ENABLE_LFN is (2) (enabled, dynamic buffer — better than the forced (1)).

Cross-impact of growing the shared patch dir

0002 touches only ports/renesas-ra/* (disjoint from 0001's ports/zephyr/*), is guarded by #if USB_CFG_LDO_REGULATOR == USB_CFG_ENABLE, and the README now documents the disjoint-file-set contract. Jobs that don't compile renesas-ra apply it inertly (and vice versa for 0001 on this job).

Scope

  • removed: fresh clone + gh pr checkout 16409 + both seds
  • added: ./tools/apply_micropython_patches.sh, patch 0002, README section
  • unchanged: make BOARD_DIR=../../../../boards/seeed/xiao_ra4m1, toolchain, board files

⚠️ Same caveat as #37: compiled, not yet hardware-tested — the VDCEN behavior (USB enumeration) specifically deserves a smoke test on a real XIAO RA4M1.

🤖 Generated with Claude Code

cumin777 and others added 2 commits September 28, 2026 19:04
…atch 0002

The old flow deleted the lib/micropython submodule, cloned micropython
fresh, checked out upstream PR #16409 (WEACT_RA4M1_CORE board profile,
open and unmerged since 2024-12) and patched main.c/mpconfigport.h with
two line-addressed seds.

What the XIAO RA4M1 actually needs from #16409 is only the USB LDO
VDCEN enable (the board powers USB from the internal LDO:
USB_CFG_LDO_REGULATOR = ENABLE in its FSP config, so USBMC.VDCEN must
be set for enumeration).  That 2-hunk change is now carried as
micropython/patches/v1.27.0/0002-renesas-ra-usb-ldo-vdcen.patch --
verified to apply cleanly (git apply --check) on the v1.27.0 tree,
after 0001, with identical anchor context (main.c:366, mphalport.h:64).
The WEACT board profile half of the PR is not needed: this repo already
supplies the board via boards/seeed/xiao_ra4m1, and the port natively
supports BOARD_DIR.

Everything else is upstream at v1.27.0: the RA4M1 family (EK_RA4M1,
RA4M1_CLICKER, ra4m1_af.csv) and Makefile BOARD_DIR support.  Both old
seds are obsolete: main.c now ships mp_cstack_init_with_top() as-is,
and MICROPY_FATFS_ENABLE_LFN is (2) (enabled, dynamic buffer).

Cross-impact: 0002 only touches ports/renesas-ra files (disjoint from
0001's ports/zephyr set), is guarded by
#if USB_CFG_LDO_REGULATOR == USB_CFG_ENABLE, and applies harmlessly on
zephyr-port jobs that run the shared patch script.

Ref Seeed-Studio#28

Co-Authored-By: Claude <noreply@anthropic.com>
The XIAO RA4M1 board dir was copied from PR #16409's WEACT_RA4M1_CORE
and still referenced the WEACT board's in-tree paths:
  LD_FILES = boards/WEACT_RA4M1_CORE/ra4m1_ek.ld
  FROZEN_MANIFEST ?= boards/WEACT_RA4M1_CORE/manifest.py
These only resolved because the old CI flow checked out PR #16409 (the
WEACT board then existed under ports/renesas-ra/boards/).  Without it
the build fails at freeze time ('No such file or directory .../boards/
WEACT_RA4M1_CORE/manifest.py').  Point both at the board directory's
own copies via $(BOARD_DIR), which the port Makefile defines before
including mpconfigboard.mk.

Co-Authored-By: Claude <noreply@anthropic.com>
@cumin777

Copy link
Copy Markdown
Contributor Author

Environment change notes (pre-merge summary)

What this board was building on before (the "old environment"):

The workflow deleted the lib/micropython submodule and rebuilt the source from scratch every run:

cd lib && rm -r micropython || true
git clone https://github.com/micropython/micropython.git
cd micropython && git submodule update --init --recursive && gh pr checkout 16409
sed -i '301,302c\    mp_cstack_init_with_top(...)' main.c
sed -i '170s/#define MICROPY_FATFS_ENABLE_LFN.*/...(1)/' mpconfigport.h
make BOARD_DIR=../../../../boards/seeed/xiao_ra4m1
  • PR #16409 (WEACT_RA4M1_CORE board profile) has been open and unmerged since 2024-12-13 — a two-year dependency on someone else's pending PR, the exact fragile pattern issue Unify the MicroPython build environment; drop personal-fork / open-PR dependencies (CI red for 4 boards) #28 set out to remove.
  • Only 2 hunks of that PR are actually load-bearing for us: the USB LDO VDCEN enable (the XIAO RA4M1 powers USB from the internal LDO — USB_CFG_LDO_REGULATOR = ENABLE in its FSP config — so USBMC.VDCEN must be set for enumeration). The 23-file WEACT board profile was only used as a path crutch.
  • Hidden landmine: the XIAO board dir was copied from that PR and still referenced boards/WEACT_RA4M1_CORE/... paths (LD_FILES, FROZEN_MANIFEST) that resolved only because the PR checkout put the WEACT board in-tree. Removing the checkout exposed it (first CI run failed at freeze time) — fixed in the second commit by pointing at the board's own files via $(BOARD_DIR).
  • The two line-addressed seds patched a then-current micropython master; both changes are upstream at v1.27.0 (mp_cstack_init_with_top() as-is; MICROPY_FATFS_ENABLE_LFN (2)).

What it builds on now:

The repo-wide pin — lib/micropython at v1.27.0 (78ff170) — plus tools/apply_micropython_patches.sh, same model as the green nRF54LM20A/B jobs. New patch 0002-renesas-ra-usb-ldo-vdcen.patch carries the PR's 2 genuinely-needed hunks (verified with git apply --check on the v1.27.0 tree, after 0001). The RA4M1 chip itself is fully upstream at v1.27.0 (EK_RA4M1, RA4M1_CLICKER, ra4m1_af.csv, native BOARD_DIR support). make BOARD_DIR=... and the board files are unchanged (except the $(BOARD_DIR) path fix).

Test status / caveat:

✅ CI compiles green (artifact: firmware.hex), and the shared patch set (0001+0002) was confirmed side-effect-free on the nRF54LM20A/B jobs in this run.

⚠️ No on-hardware validation yet. The VDCEN change specifically affects USB enumeration — flash a real XIAO RA4M1 and confirm the USB CDC REPL comes up before shipping a release.

@cumin777
cumin777 merged commit 3fb7e71 into Seeed-Studio:master Sep 29, 2026
6 of 7 checks passed
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.

1 participant