Skip to content

Add ARM coprocessor emulation (make Python work!). Fix #321 - #570

Open
adriweb wants to merge 70 commits into
masterfrom
feature/python
Open

adriweb wants to merge 70 commits into
masterfrom
feature/python

Conversation

@adriweb

@adriweb adriweb commented Dec 2, 2026 •

Copy link
Copy Markdown
Member
  • The bulk of the work is from @jacobly0 in 2019-2020
  • ... then @calc84maniac took over with fixes and improvements for the ARM CPU and memory in 2024
  • ... then I made Codex finish the job in August 2026 regarding mostly the interaction between the co-proc and the ASIC + the free bootloader + debugger/GUI features, with lots of manual testing/review/feedback/iterations from calc84 and myself.

Fixes #321

jacobly0 and others added 30 commits December 2, 2026 18:24
Wake the ARM worker when USART input arrives and when the eZ80 drains an output byte. Firmware can sleep while waiting for receive data or transmit-buffer space, so either event must let SERCOM processing resume.

Co-Authored-By: Codex (gpt-5.6 Sol High) <codex@openai.com>
Co-Authored-By: Codex (gpt-5.6 Sol High) <codex@openai.com>
Co-Authored-By: Codex (gpt-5.6 Sol High) <codex@openai.com>
adriweb and others added 20 commits December 2, 2026 18:24
Do not shift a device response by 32 when a callback reports no available bits. Store an empty frame instead and let the scheduler retry without invoking undefined behavior.

Co-Authored-By: Codex (gpt-5.6 Sol High) <codex@openai.com>
Own ARM destruction through coproc_free, wake a terminating worker, and join it before releasing or replacing coprocessor state. This prevents reload and shutdown paths from racing a detached thread that still owns the old instance.

Co-Authored-By: Codex (gpt-5.6 Sol High) <codex@openai.com>
Mark arguments used only by commented-out ARM debug output so normal warning-enabled builds remain quiet.

Co-Authored-By: Codex (gpt-5.6 Sol High) <codex@openai.com>
Add a standalone SAMD21 bootloader implementation for the observed SPI mass-storage transport, UART POB identification, UF2 handoff, and double-reset ABI used by TI's Python App.

The UF2 behavior is derived from Microsoft's MIT-licensed uf2-samdx1 reference implementation. Retain the Microsoft MIT and bundled Atmel notices and document that no TI bootloader bytes are included.

Co-Authored-By: Codex (gpt-5.6 Sol High) <codex@openai.com>
Embed the generated clean-room bootloader image and copy it into otherwise empty SAMD21 flash. Track the generated-header dependency and project metadata so a proprietary ARM flash override is no longer required for initial firmware installation.

Co-Authored-By: Codex (gpt-5.6 Sol High) <codex@openai.com>
Save the SAMD21 flash, CPU, SRAM, page buffers, and modeled peripheral state under a CARM marker, and bump the CEmu image version. Continue reading legacy 0xCECE001B images by starting them from the bundled bootloader.

Co-Authored-By: Codex (gpt-5.6 Sol High) <codex@openai.com>
Default Python calculators to the bundled or state-saved coprocessor flash. Keep an explicit full-flash override for rare debugging, expose a clear action, and avoid trying to load an empty path.

Co-Authored-By: Codex (gpt-5.6 Sol High) <codex@openai.com>
List the shared threading wrapper in the CMake project and compile the TinyCThread fallback in qmake builds, matching the existing core build.

Co-Authored-By: Codex (gpt-5.6 Sol High) <codex@openai.com>
Co-Authored-By: Codex (gpt-5.6 Sol High) <codex@openai.com>
Co-Authored-By: Codex (gpt-5.6 Sol High) <codex@openai.com>
Bound the threaded SAMD21 core to the ASIC 48 MHz virtual clock while allowing it to catch up concurrently. Stop it synchronously for UI, debugger, and web pauses, and rebase its budget across resets and restores.

Co-Authored-By: Codex (gpt-5.6 Sol High) <codex@openai.com>
Account for the documented zero-wait-state Cortex-M0+ instruction costs, including runtime-dependent branches, memory interfaces, register lists, control instructions, and barriers. Advance SysTick by the complete cost and allow the virtual-time throttle to stop after an atomic instruction.

Use the SAMD21's documented fast single-cycle multiplier and its 0x60000000 IOBUS mapping.

References:
- ARM DDI 0484C, Cortex-M0+ Technical Reference Manual r0p1, section 3.3, Table 3-1
- Microchip SAM D21/DA1 Family Data Sheet DS40001882H, section 11.1.1, Table 11-1

Co-Authored-By: Codex (gpt-5.6 Sol High) <codex@openai.com>
Co-Authored-By: Codex (gpt-5.6 Sol High) <codex@openai.com>
External ARM flash images may require the Python app to be quit and relaunched after a firmware update before the REPL is ready.

Co-Authored-By: Codex (gpt-5.6 Sol High) <codex@openai.com>
Add synchronized Cortex-M0+ state and memory accessors, along with bootloader, reset, SPI, UART, and flash-loading bindings. Document the interface and ship a coprocessor inspector example with ARM regression coverage.

Co-Authored-By: Codex (gpt-5.6 Sol High) <codex@openai.com>
Expose the SAMD21E18A through a localhost-only GDB Remote Serial Protocol endpoint selected with --arm-gdb-port. Support Cortex-M registers, synchronized memory access, continue, single-step, interrupts, virtual software breakpoints, and monitor commands.

Introduce COPROC_DEBUG_SUPPORT for the core APIs and server, require the general DEBUG_SUPPORT configuration, and cover both compiled-in and compiled-out ARM builds. Keep remote debugging synchronized with the threaded ARM scheduler and coprocessor replacement, preserve peripheral access widths during memory transfers, and document symbol loading and ARM-only halt semantics.

Co-Authored-By: Codex (gpt-5.6 Sol High) <codex@openai.com>
Add a lightweight GDB RSP client and Qt debugger for ARM CPU registers, execution control, breakpoints, memory, and modeled SAMD21 peripherals. Reuse the localhost GDB server so the built-in and external clients exercise the same interface.

Expand COPROC_DEBUG_SUPPORT from the core and server to the client, debugger window, and corresponding CMake and qmake source lists.

Co-Authored-By: Codex (gpt-5.6 Sol High) <codex@openai.com>
calc84maniac and others added 6 commits December 3, 2026 03:52
Page through flash and SRAM using 32-bit addresses.
Stage SRAM edits and verify them through RSP.
Route memory replies to their originating requests and pace
peripheral refreshes so they don't block navigation / exec controls.

Co-Authored-By: Codex (gpt-6.2 Sol High) <codex@openai.com>
Reuse the disassembly text widget for ARM instruction rows and
follow the program counter on each stop.
Add address and branch navigation, memory cross-links and
virtual breakpoint actions.

Build only Capstone ARM support when coprocessor debugging is enabled.

Co-Authored-By: Codex (gpt-6.2 Sol High) <codex@openai.com>
Expose the loopback listener in the Debug menu and inside the debugger.
Persist a fixed or automatic port, display the GDB command, and preserve the current listener when a new bind fails or a client is connected.

Co-Authored-By: Codex (gpt-6.2 Sol High) <codex@openai.com>
Leave the target running while the built-in debugger negotiates its connection.
Attach on the first explicit Halt and clear old values when the dialog disconnects.
Preserve ordinary GDB attach semantics and close the built-in connection without interrupting an active continue.

Co-Authored-By: Codex (gpt-6.2 Sol High) <codex@openai.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Support for Python editions (83PCEEP and 84+CEPE)

3 participants