Profiling hooks, PIO conformance fixes, and native-memory RAM#43
Merged
Conversation
Add an opt-in, profiling-only execution path that never touches the hot Run(int) loop, mirroring AVR8Sharp's Execute()/ExecuteProfiling() split: - IProfilingObserver: per-instruction observation callback (pc, opcode, cycles) - RunProfiled(int, IProfilingObserver): byte-for-byte sibling of Run(int) that fires the observer before each dispatch. Run(int) is left unchanged, so the fast path pays nothing for profiling. - OnExceptionEntry / OnExceptionReturn: nullable Action hooks (same pattern as OnBreakpoint/OnLockup), fired once per exception event — not per instruction — so a profiler can track the thread/handler boundary and RTOS task switches. All 456 unit tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Three RP2040 PIO conformance bugs surfaced by exhaustive testing: - CheckSmWait advanced the PC past an OUT that had stalled on autopull when data arrived late, skipping the OUT entirely. It now distinguishes the FIFO event (TX vs RX) and only re-arms the stall so the instruction re-executes. - FDEBUG TXOVER was written to bits [11:8] (RXUNDER) instead of [19:16], and RXUNDER on empty-RX reads was not reported at all (TRM 3.7). - Autopush with a full RX FIFO silently discarded the captured word instead of stalling (datasheet 3.5.4.2). It now stalls via an AutopushPending flag that retains the data and completes the deferred push once the RX FIFO drains. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- PioExhaustiveTests: full coverage of the PIO instruction set (all JMP conditions, IN/OUT sources/dests and shift directions, MOV ops, PUSH/PULL variants, IRQ/WAIT, SET, side-set, autopull/autopush, FIFO join, clock divider, wrap, multi-SM, NVIC routing) plus regressions for the three fixes. - MicroPython integration scripts (real firmware): late-producer autopull path and MOV invert/reverse operators. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
RandomAccessMemory pinned a managed byte[] via GCHandle and had no finalizer, so every RP2040Machine that was discarded without an explicit Dispose() leaked its ~2.5 MB of SRAM/Flash/BootROM as non-collectable pinned heap. Switch the backing store to NativeMemory.AllocZeroed with a finalizer and an idempotent Dispose (same pattern as InstructionDecoder). This keeps the multi-MB blocks out of the GC heap entirely and guarantees release via Dispose, with the finalizer as a safety net. The migration is transparent: all access goes through BasePtr / Bus.Ptr*, never the managed array. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ne runs Bundle the MicroPython (v1.19.1/v1.20.0/v1.21.0) and CircuitPython (9.2.1) UF2 images under Firmware/python and have FirmwareCache prefer the embedded copy before falling back to a network download. This removes the download-induced flakiness seen when the whole integration suite runs in parallel. EmbeddedFirmwareTests guards that the images stay embedded so the suite cannot silently regress back to downloading. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on the
1.0.1line with a profiling entry point, three PIO conformancefixes, a fix for a pinned-heap memory leak, and exhaustive test coverage.
✨ Added
feat(profiling)— a separateRunProfiledexecution path plus exceptionhooks, so callers can observe execution without paying the cost on the hot path.
🐛 Fixed
fix(pio)— three RP2040 PIO conformance bugs:OUTwhen data arrived late (CheckSmWaitnowre-arms the stall per FIFO event instead of advancing the PC);
TXOVER/RXUNDERwere on the wrong bits (now[19:16]/[11:8], TRM 3.7);push once space frees up, datasheet 3.5.4.2).
fix(memory)—RandomAccessMemorybacked a pinned managedbyte[]with nofinalizer, leaking ~2.5 MB of non-collectable pinned heap per discarded machine.
Now backed by
NativeMemorywith a finalizer + idempotentDispose.🧪 Tests
RandomAccessMemorycorrectness + no-leak stress.test(integration)— MicroPython/CircuitPython UF2s embedded so the suiteruns fully offline (no download flakiness).
✅ Verification
🤖 Generated with Claude Code