Skip to content

boards/rp2040: switch waveshare nsh/usbnsh configs to nxinit entrypoint - #20151

Merged
acassis merged 1 commit into
apache:masterfrom
JianyuWang0623:rp2040/nxinit-init
Sep 18, 2026
Merged

acassis merged 1 commit into
apache:masterfrom
JianyuWang0623:rp2040/nxinit-init

Conversation

@JianyuWang0623

@JianyuWang0623 JianyuWang0623 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Switch CONFIG_INIT_ENTRYPOINT from nsh_main to nxinit's init_main for
the shell-capable configs of both waveshare-rp2040-zero and
waveshare-rp2040-lcd-1.28: nsh (UART console) and usbnsh (USB CDC/ACM
console). nsh now runs as a "console sh" service started by init.rc
instead of being the top-level init task, matching the pattern already used
on rv-virt/esp32s3/qemu.

  • boards/arm/rp2040/common/src/Make.defs: add init.rc to RCSRCS,
    gated on CONFIG_ETC_ROMFS && CONFIG_SYSTEM_NXINIT, following the same
    pattern boards/risc-v/qemu-rv/rv-virt uses. Both waveshare boards share
    CONFIG_ARCH_BOARD_COMMON's common/src, so one copy of init.rc
    covers both boards.
  • boards/arm/rp2040/common/src/etc/init.d/init.rc: new. Starts an nsh
    "console" service (restart_period 1000) on the "init" event. sh
    resolves directly through the existing builtin binfmt loader
    (apps/system/nsh's PROGNAME already registers both nsh and sh),
    so no CONFIG_LIBC_ENVPATH/CONFIG_FS_BINFS changes are needed here
    (these boards don't set CONFIG_LIBC_ENVPATH).
  • boards/arm/rp2040/common/.gitignore: new, ignoring the etctmp/
    etctmp.c build byproducts that boards/Board.mk generates from
    init.rc under BOARD_COMMON_DIR, matching the existing
    boards/risc-v/qemu-rv/rv-virt/src/.gitignore precedent.
  • 4 defconfigs (waveshare-rp2040-zero and waveshare-rp2040-lcd-1.28,
    each nsh + usbnsh): CONFIG_INIT_ENTRYPOINT="init_main",
    CONFIG_SYSTEM_NXINIT=y plus its previously-unset Kconfig deps
    (CONFIG_EXPERIMENTAL, CONFIG_LIBC_EXECFUNCS, CONFIG_SCHED_HAVE_PARENT,
    CONFIG_SCHED_CHILD_STATUS), and CONFIG_ETC_ROMFS=y /
    CONFIG_FS_ROMFS=y to ship init.rc via the standard /etc ROMFS
    auto-mount (sched/init/nx_bringup.c's nx_romfsetc()). Each defconfig
    regenerated with kconfig-tweak + make savedefconfig; verified
    byte-for-byte reproducible by re-running make savedefconfig from the
    committed file.

Impact

Image size impact (waveshare-rp2040-lcd-1.28:nsh, same toolchain):
nsh_main baseline text/data/bss = 159464/900/10748 (171112 total);
nxinit build = 174740/904/8204 (183848 total). RAM_SIZE is 270336
(264 KiB SRAM), comfortably clear of both.

CMake build support for RP2040's ETC_ROMFS is a known pre-existing gap
(see boards/arm/rp23xx/*/src/CMakeLists.txt's # TODO); left untouched
here to match that established precedent.

Testing Build Host

$ ./tools/checkpatch.sh -c -u -m -g origin/master..HEAD
Used config files:
    1: .codespellrc
✔️ All checks pass.

All 4 configs built cleanly with
make PICO_SDK_PATH=<pico-sdk> (arm-none-eabi-gcc 10.3.1):

board config text/data/bss
waveshare-rp2040-lcd-1.28 nsh 174740/904/8204
waveshare-rp2040-lcd-1.28 usbnsh 180680/752/11272
waveshare-rp2040-zero nsh 174672/904/8272
waveshare-rp2040-zero usbnsh 180552/752/11400

waveshare-rp2040-zero has no physical unit available to this contributor
(build-only verification for that board).

Hardware bring-up on waveshare-rp2040-lcd-1.28 (serial console, USB
CDC/ACM console, init.rc/ROMFS boot log, interactive shell) is still
pending
— the only physical unit is currently in concurrent use by a
parallel workstream on the same fork. This PR is opened as draft and
will be updated with real UART/USB console boot logs and shell output
before being marked ready for review.

Related

Part of the RP2040 waveshare fastboot + nxinit + dual-partition bootloader
initiative (Stage 3 of 4).

@github-actions github-actions Bot added Size: S The size of the change in this PR is small Board: arm labels Sep 15, 2026
@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

acassis
acassis previously approved these changes Sep 15, 2026
@acassis

acassis commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Strange, github is failing: I will restart that job:

GET /repos/apache/nuttx/pulls/20151/files - 500 with id E019:3A5EE9:F0EA17:11516CD:6AA915E5 in 2481ms
RequestError [HttpError]
    at fetchWrapper (/home/runner/work/_actions/actions/github-script/3a2844b7e9c422d3c10d287c895573f7108da1b3/dist/index.js:61509:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
    at async Object.next (/home/runner/work/_actions/actions/github-script/3a2844b7e9c422d3c10d287c895573f7108da1b3/dist/index.js:64409:28)
    at async eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/3a2844b7e9c422d3c10d287c895573f7108da1b3/dist/index.js:64949:16), <anonymous>:13:27)
Error: Unhandled error: HttpError
    at async main (/home/runner/work/_actions/actions/github-script/3a2844b7e9c422d3c10d287c895573f7108da1b3/dist/index.js:65100:20) {
  status: 500,
  request: {
    method: 'GET',
    url: 'https://api.github.com/repos/apache/nuttx/pulls/20151/files',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'actions/github-script actions_orchestration_id/7d7d2f68-d780-400f-8579-4b7571e2c5af.labeler.__default octokit-core.js/7.0.6 Node.js/24',
      authorization: 'bearer [REDACTED]'
    },
    request: {
      agent: [Agent],
      fetch: [Function: proxyFetch],
      hook: [Function: bound bound register]
    }
  },
  response: {
    url: 'https://api.github.com/repos/apache/nuttx/pulls/20151/files',
    status: 500,
    headers: {
      'access-control-allow-origin': '*',
      'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset, Warning',
      'content-length': '0',
      'content-security-policy': "default-src 'none'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Tue, 15 Sep 2026 09:54:47 GMT',
      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
      server: 'github.com',
      'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
      vary: 'Accept-Encoding, Accept, X-Requested-With',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'deny',
      'x-github-edge-region': 'westus3',
      'x-github-media-type': 'github.v3; format=json',
      'x-github-request-id': 'E019:3A5EE9:F0EA17:11516CD:6AA915E5',
      'x-ratelimit-limit': '15000',
      'x-ratelimit-remaining': '14966',
      'x-ratelimit-reset': '1789469051',
      'x-ratelimit-resource': 'core',
      'x-ratelimit-used': '34',
      'x-xss-protection': '0'
    },
    data: ''
  },
  [cause]: undefined
}

Switch CONFIG_INIT_ENTRYPOINT from nsh_main to nxinit's init_main for
the shell-capable configs (nsh, usbnsh) of waveshare-rp2040-zero and
waveshare-rp2040-lcd-1.28.  nsh now runs as a "console sh" service
started by init.rc instead of being the top-level init task.

Add etc/init.d/init.rc to the shared common/src RCSRCS, gated on
CONFIG_ETC_ROMFS && CONFIG_SYSTEM_NXINIT, so one copy covers both
boards, plus a .gitignore for the etctmp files Board.mk generates from
it.  The four defconfigs also set CONFIG_SYSTEM_NXINIT=y with its
Kconfig deps, CONFIG_ETC_ROMFS=y and CONFIG_FS_ROMFS=y.

nsh_main connected the CDC/ACM gadget itself via
boardctl(BOARDIOC_USBDEV_CDCACM); init_main does not, so the usbnsh
configs would otherwise come up with no USB console.  Run sercon from
init.rc and enable CONFIG_SYSTEM_CDCACM in those two defconfigs to keep
that step.

Assisted-by: Claude:claude-sonnet-5
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
@acassis
acassis marked this pull request as ready for review September 18, 2026 11:47
@acassis
acassis merged commit f492f13 into apache:master Sep 18, 2026
33 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Board: arm Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants