Skip to content

Phase 4: first Mono boot - Hello World on CCM (JIT and interpreter) - #697

Merged
NevynUK merged 6 commits into
MergeManagedCodefrom
Phase4
Oct 14, 2026
Merged

NevynUK merged 6 commits into
MergeManagedCodefrom
Phase4

Conversation

@NevynUK

@NevynUK NevynUK commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

First part of Phase 4: Mono now starts on the board and runs a managed Hello World, and its output reaches meadow listen; GC stress passes under both the JIT and the interpreter. Blinky is still to do.

Changes

  • MonoControl options now reach Mono. meadow_mono_main used to ignore the options that hcom builds from meadow.config.yaml, and Legacy ignores them too. They now go into MONO_ENV_OPTIONS. They can't be passed as arguments, because monovm_execute_assembly puts the assembly first and mono_main() stops reading runtime options there. Tested with --interp and --debug.
  • stdout/stderr redirect: CONFIG_HCOM_MONO_STDERR_STDOUT=y, plus two fixes in hcom_stdxxx_redirect.c:
    • POLLHUP spin. The FIFOs were opened O_RDONLY, and NuttX reports POLLHUP on an empty FIFO with no writer. While Mono wasn't running, the read loop spun and starved hcom, so the CLI couldn't connect. They are now opened O_RDWR.
    • Wrong dup2 target. hcom_mono_open_mono_fifo() dup2'd both FIFOs onto fd 1, so stdout arrived labelled stderr and stderr was lost. Legacy has the same bug.
  • Runtime pin: points at runtime MergeManagedCode fafd81e8032, which contains Phase 4: NuttX 12 stack bounds and Thumb-2 JIT code alignment runtime#4 (NuttX 12 stack bounds and Thumb-2 JIT code alignment) and Merge pull request #4 from WildernessLabs/peter-rebase-point-2 #5 (Thumb-2 LDR/STR with negative offsets, which fixes --interp). Its tree is the same as the Phase4b head that was tested.

Testing (CCM, 1.99.1.7)

  • Managed set on /meadow0:
    • CoreLib built from the runtime (build.sh -subset mono.corelib -arch arm -os linux -c Release /p:FeaturePerfTracing=false)
    • 11 framework assemblies from the 3.0.0 meadow_assemblies package
    • a net11.0 console Meadow.dll
  • Results: mono_exec returned: ret=0x00000000 exit_code=42 under the JIT (about 5.8 s), the JIT with --debug, and --interp (about 3.5 s). A breakpoint confirmed that --interp really uses the interpreter.
  • meadow listen output: stdout> Hello from Meadow!, stderr> Hello from Meadow on stderr, and stdout> mono_mbedtls_init: OK.
  • CLI: connects with Mono disabled and the redirect active, and the CLI commands still work.
  • GC stress (a net11.0 app: nursery churn, a retained 65535-node tree, large objects, strings, 3 allocating threads with forced collections, finalizers, weak references), 5 passes each:
    • JIT --debug: 30/30 tests pass, 121 s.
    • --interp: 30/30 tests pass, 229 s. Before runtime#5, the board locked up with SP = 0 in the first test.

🤖 Generated with Claude Code

NevynUK and others added 3 commits October 14, 2026 20:24
meadow_mono_main ignored the options hcom builds from meadow.config.yaml
(MonoControl: Options), so --interp, --debug and the others had no effect.
monovm_execute_assembly puts the entry assembly first on the mono_main()
command line, where runtime options are no longer read, so join the options
into MONO_ENV_OPTIONS, which mono_main() reads first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Turn on CONFIG_HCOM_MONO_STDERR_STDOUT so the Mono app's stdout and stderr
reach the host (meadow listen), and fix two faults in
hcom_stdxxx_redirect.c that had not been exercised under NuttX 12:

- The readers opened the FIFOs O_RDONLY.  NuttX reports POLLHUP on every
  poll of an empty FIFO with no writer, so while Mono was not running the
  read loop spun and starved hcom (the CLI could not connect).  Open them
  O_RDWR so the reader also counts as a writer.

- hcom_mono_open_mono_fifo() ignored its fd argument and dup2'd both FIFOs
  onto STDOUT_FILENO, so stdout reached the host labelled stderr and
  stderr was lost.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WildernessLabs/runtime#4: the NuttX 12 stack bounds and the Thumb-2 code
buffer alignment.  To be moved to the MergeManagedCode merge commit once
that pull request is merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WildernessLabs/runtime#4 is merged; the tree is the same as the Phase4
commit pinned before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NevynUK and others added 2 commits October 14, 2026 21:16
WildernessLabs/runtime#5: the 32-bit Thumb-2 LDR/STR encoding for negative
offsets, which fixes the interpreter (--interp) crash.  To be moved to the
MergeManagedCode merge commit once that pull request is merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WildernessLabs/runtime#5 is merged; the tree is the same as the Phase4b
commit pinned before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NevynUK
NevynUK merged commit 5b650ff into MergeManagedCode Oct 14, 2026
2 checks passed
@NevynUK
NevynUK deleted the Phase4 branch October 14, 2026 20:24
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