Skip to content

ci(mg24): drop dead-fork PR override, apply repo v1.27.0 patches for USER_C_MODULES - #38

Merged
cumin777 merged 1 commit into
Seeed-Studio:masterfrom
cumin777:ci/mg24-pin-v1.27.0-usermod-via-patches
Sep 29, 2026
Merged

cumin777 merged 1 commit into
Seeed-Studio:masterfrom
cumin777:ci/mg24-pin-v1.27.0-usermod-via-patches

Conversation

@cumin777

Copy link
Copy Markdown
Contributor

Problem (ref #28)

Same dead-fork failure as #37: the workflow overrode lib/micropython with git reset --hard origin/master + gh pr checkout 18030, and upstream micropython PR #18030 was closed unmerged with its source fork since deleted → upload-pack: not our ref, CI red.

But unlike nRF54L15/nRF52840 in #37, this board genuinely uses the feature: it passes -DUSER_C_MODULES=src/cmodules/modadc;src/cmodules/modrtc, so the override can't just be deleted.

Fix

Build at the repo-wide pin (v1.27.0 submodule) and run tools/apply_micropython_patches.sh. The repo's shared 0001-zephyr-xiao-nrf54lm20b-runtime.patch already carries PR #18030's entire one-file diff:

include(${MICROPY_DIR}/py/usermod.cmake)     # in ports/zephyr/CMakeLists.txt
... ${MICROPY_SOURCE_USERMOD}                # into MICROPY_SOURCE_QSTR
... ${MICROPY_INC_USERMOD}                   # into include dirs

And py/usermod.cmake at v1.27.0 appends /micropython.cmake to directory entries (IS_DIRECTORY branch), so the existing -DUSER_C_MODULES="dir;dir" keeps working unchanged — our cmodules are already in native format (add_library INTERFACE + target_link_libraries(usermod ...)).

Also drops the sed '116s/4096)/4096 * 2)/' hack: v1.27.0 moved flash storage to zephyr_storage.c, which reads erase_block_size from the devicetree (4096 is only the DT_PROP_OR fallback) — the hardcoded doubling is superseded.

Cross-impact of the shared patch set on this job (checked)

  • BT advertiser-option shim in 0001: version-guarded #ifdef (new/old Zephyr names) → fine on Zephyr v4.2.0
  • xiao_nrf54lm20b_imu_power.c added to zephyr port sources: #if defined(CONFIG_BOARD_XIAO_NRF54LM20B_...) guard → empty translation unit on xiao_mg24
  • modmachine/modtime/modzsensor/mpconfigport tweaks: port-wide, daily-verified on LM20A/B; MG24 × Zephyr v4.2.0 is the new combination CI will adjudicate

Scope

  • removed: override block + main.c sed
  • added: ./tools/apply_micropython_patches.sh
  • unchanged: Zephyr v4.2.0, xiao_mg24 board, overlays/conf, USER_C_MODULES list

🤖 Generated with Claude Code

…USER_C_MODULES

Same dead-fork failure as PR Seeed-Studio#37 (upstream PR #18030 closed unmerged,
source fork deleted -> 'upload-pack: not our ref'), but unlike
nRF54L15/nRF52840 this board genuinely uses USER_C_MODULES
(src/cmodules/modadc + modrtc), so the override cannot simply be
deleted.

The repo's shared 0001-zephyr-xiao-nrf54lm20b-runtime.patch already
carries PR #18030's entire one-file diff (include py/usermod.cmake +
MICROPY_SOURCE_USERMOD + MICROPY_INC_USERMOD in ports/zephyr), and
py/usermod.cmake at v1.27.0 appends /micropython.cmake to directory
entries, so the existing -DUSER_C_MODULES="dir;dir" keeps working
unchanged.

Also drops the 'sed 4096 -> 4096 * 2' hack on main.c: v1.27.0 moved
flash storage to zephyr_storage.c which reads erase_block_size from
the devicetree (4096 is only the fallback).

Cross-impact of running the shared patch script on this job was
checked: the BT advertiser-option shim is version-guarded (#ifdef),
and xiao_nrf54lm20b_imu_power.c is CONFIG_BOARD-guarded (compiles to
an empty translation unit on xiao_mg24).

Zephyr v4.2.0, board overlays and the USER_C_MODULES list are
unchanged.

Ref Seeed-Studio#28

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 overrode the lib/micropython submodule before compiling:

git reset --hard origin/master
gh pr checkout 18030     # upstream micropython PR, "zephyr: supports adding external user modules"
sed -i '116s/4096)/4096 * 2)/' ./main.c
  • PR #18030 was closed unmerged (author-closed 2025-11-20) and its source fork has since been deleted, so gh pr checkout fails with upload-pack: not our ref — CI red since ~2026-07.
  • Unlike nRF54L15/nRF52840 (ci(nrf54l15,nrf52840): drop dead-fork PR override, build at MicroPython v1.27.0 pin #37), this board genuinely used the PR's feature: -DUSER_C_MODULES=src/cmodules/modadc;src/cmodules/modrtc.
  • Effective old baseline: fork-base master snapshot 9939565 (2025-08-26) + the PR's 3-line usermod wiring + a line-addressed sed doubling the hardcoded flash block size (4096 → 4096*2) in main.c.

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. The shared 0001 patch already carries PR #18030's entire one-file diff, and v1.27.0's py/usermod.cmake appends /micropython.cmake to directory entries, so the existing -DUSER_C_MODULES="dir;dir" works unchanged. The sed hack is dropped: v1.27.0 moved flash storage to zephyr_storage.c, which reads erase_block_size from the devicetree (4096 is only the fallback). Zephyr v4.2.0, board and overlays unchanged.

Test status / caveat:

✅ CI compiles green (artifacts: zephyr.elf / zephyr.hex), including the usermod_adc / usermod_rtc modules being discovered and linked.

⚠️ No on-hardware validation yet. Recommend flashing and smoke-testing on a real XIAO MG24 (REPL over USB, import adc / import rtc, flash /flash filesystem with the new devicetree-derived block size) before shipping a release.

@cumin777
cumin777 merged commit dc752b6 into Seeed-Studio:master Sep 29, 2026
6 of 7 checks passed
cumin777 added a commit that referenced this pull request Sep 30, 2026
Per-board MicroPython smoke tests in example/ (matching the existing
per-board test scripts like xiao_stm32c5_full_test.py), run over the
board REPL after flashing the CI firmware artifact. Both were executed
against the v1.27.0 master builds on real hardware (2026-09-29):
xiao_nrf54l15 6/6 PASS, xiao_mg24 7/7 PASS.

Findings from the hardware run that are encoded in the tests:

- mg24: the user C modules (PR #38, USER_C_MODULES) register with
  uppercase names -- MP_REGISTER_MODULE(MP_QSTR_ADC, ...) etc, so the
  importable modules are ADC / RTC / CAN / PDM / LowPWR, and the
  callable classes live inside (ADC.ADC, RTC.RTC), consistent with
  example/boards/xiao.py and every shipped example. An early draft of
  this test did `import adc` / `import rtc` and reported ImportError;
  that was a test bug, not a firmware bug. The test now also exercises
  ADC.ADC(("adc0", ch)).read_uv() across channels and an RTC.RTC()
  datetime round-trip.

- nrf54l15: gc threshold lowered 50K -> 32K. The zephyr port default
  CONFIG_MICROPY_HEAP_SIZE is 49152, leaving 48000 usable bytes after
  GC bookkeeping (measured: free+alloc == 48000 exactly), so a >50K
  assertion can never pass on the default build.

- Script headers document how to run: both boards expose the REPL via
  the onboard debug bridge CDC port (mpremote required for raw-paste
  flow control); the MCU USB peripheral is not wired to the USB-C
  connector, so no other USB serial device is expected. The LED check
  is visual.

RA4M1 smoke test follows in a separate PR once its hardware run is done.

Co-Authored-By: Claude <noreply@anthropic.com>
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