WrapperSubboardBlock-based microcontroller dev board, with RP2040 as example#497
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR prototypes a new WrapperSubboardBlock-based approach for microcontroller dev boards (using RP2040/XIAO RP2040 as the concrete example), replacing the older “magical” export mechanism with more explicit inner export/wrap APIs and updating SWD handling + generated example artifacts accordingly.
Changes:
- Refactors
Rp2040and introduces a wrapper-styleXiao_Rp2040implementation that wraps an internal model subcircuit and taps/export-remaps IOs to a footprint-only device. - Adds explicit IO wrapping/export utilities (
_export_ios_inner,_wrap_inner,_export_tap_ios_inner) and introducesIoControllerWrappedhelpers for remapping model pin-assigns to wrapper footprints. - Updates SWD connector configuration to use
swd_connect_swo/tdiboolean parameters plus standardpin_assigns, and refreshes example netlists / tests to match.
Reviewed changes
Copilot reviewed 54 out of 54 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/UsbKey/UsbKey.svgpcb.js | Regenerated component ordering / netlist ordering; SWD + NRST net naming update. |
| examples/UsbKey/UsbKey.net.ref | Regenerated netlist reference reflecting updated net ordering. |
| examples/TofArray/TofArray.svgpcb.js | Regenerated SWD connector placement ordering and SWD net ordering. |
| examples/TofArray/TofArray.net.ref | Regenerated netlist reference reflecting updated SWD nets ordering. |
| examples/TestBlinkyImplicit/TestBlinkyImplicit.svgpcb.js | Regenerated SWD connector placement ordering and SWD-related net ordering. |
| examples/TestBlinkyImplicit/TestBlinkyImplicit.net.ref | Regenerated netlist reference reflecting updated ordering. |
| examples/TestBlinkyExpanded/TestBlinkyExpanded.svgpcb.js | Regenerated SWD connector placement ordering and SWD net ordering. |
| examples/TestBlinkyExpanded/TestBlinkyExpanded.net.ref | Regenerated netlist reference reflecting updated ordering. |
| examples/TestBlinkyComplete/TestBlinkyComplete.svgpcb.js | Regenerated SWD connector placement ordering and SWD net ordering. |
| examples/TestBlinkyComplete/TestBlinkyComplete.net.ref | Regenerated netlist reference reflecting updated ordering. |
| examples/TestBlinkyChain/TestBlinkyChain.svgpcb.js | Regenerated SWD connector placement ordering and SWD net ordering. |
| examples/TestBlinkyChain/TestBlinkyChain.net.ref | Regenerated netlist reference reflecting updated ordering. |
| examples/TestBlinkyBasicBattery/TestBlinkyBasicBattery.svgpcb.js | Updates XIAO RP2040 net naming (eg, mcu.device.*) and power wiring netlist regeneration. |
| examples/TestBlinkyBasicBattery/TestBlinkyBasicBattery.net.ref | Regenerated netlist reference reflecting XIAO wrapper path naming and power net changes. |
| examples/TestBlinkyBasic/TestBlinkyBasic.svgpcb.js | Switches example board footprint to XIAO RP2040 and updates power/IO nets accordingly. |
| examples/TestBlinkyBasic/TestBlinkyBasic.net.ref | Regenerated netlist reference reflecting XIAO RP2040 footprint and net renames. |
| examples/test_tofarray.py | Updates SWD refinements to new swd_connect_swo + pin_assigns style. |
| examples/test_swd_debugger.py | Updates SWD refinements to new swd_connect_swo + pin_assigns style (incl RP2040 case). |
| examples/test_robotcrawler.py | Updates SWD refinements to new swd_connect_swo + pin_assigns style for multiple MCUs. |
| examples/test_multimeter.py | Updates SWD refinements to new swd_connect_swo + pin_assigns style. |
| examples/test_high_switch.py | Updates SWD refinements to new swd_connect_swo + pin_assigns style. |
| examples/test_fcml.py | Updates SWD refinements to new swd_connect_swo/tdi + pin_assigns style. |
| examples/test_datalogger.py | Updates SWD refinements to new swd_connect_swo + pin_assigns style. |
| examples/test_blinky.py | Updates blinky basic example to use Xiao_Rp2040 wrapper block. |
| examples/SwdDebugger/SwdDebugger.svgpcb.js | Regenerated SWD connector placement ordering and SWD net ordering. |
| examples/SwdDebugger/SwdDebugger.net.ref | Regenerated netlist reference reflecting updated ordering. |
| examples/RobotCrawler/RobotCrawler.svgpcb.js | Regenerated SWD connector placement ordering and SWD net ordering for multiple MCUs. |
| examples/RobotCrawler/RobotCrawler.net.ref | Regenerated netlist reference reflecting updated ordering. |
| examples/PicoProbe/PicoProbe.svgpcb.js | Regenerated SWD/crystal block ordering and USB resistor net naming changes. |
| examples/PicoProbe/PicoProbe.net.ref | Regenerated netlist reference reflecting updated ordering and net renames. |
| examples/Multimeter/Multimeter.svgpcb.js | Regenerated SWD connector placement ordering and net ordering. |
| examples/Multimeter/Multimeter.net.ref | Regenerated netlist reference reflecting updated ordering. |
| examples/Keyboard/Keyboard.svgpcb.js | Regenerated SWD connector placement ordering and SWD net ordering. |
| examples/Keyboard/Keyboard.net.ref | Regenerated netlist reference reflecting updated ordering. |
| examples/JacdacKeyswitch/JacdacKeyswitch.svgpcb.js | Regenerated SWD connector placement ordering and SWD net ordering. |
| examples/JacdacKeyswitch/JacdacKeyswitch.net.ref | Regenerated netlist reference reflecting updated ordering. |
| examples/HighSwitch/HighSwitch.svgpcb.js | Regenerated SWD connector placement ordering and SWD net ordering. |
| examples/HighSwitch/HighSwitch.net.ref | Regenerated netlist reference reflecting updated ordering. |
| examples/Fcml/Fcml.svgpcb.js | Regenerated SWD/USB resistor/crystal component ordering and corresponding netlist changes. |
| examples/Fcml/Fcml.net.ref | Regenerated netlist reference reflecting updated ordering and net renames. |
| examples/Datalogger/Datalogger.svgpcb.js | Regenerated SWD connector placement ordering and SWD net ordering. |
| examples/Datalogger/Datalogger.net.ref | Regenerated netlist reference reflecting updated ordering. |
| examples/BasicKeyboard/BasicKeyboard.svgpcb.js | Updates XIAO RP2040 net naming (mcu.device.vcc_out) and regenerated board limits. |
| examples/BasicKeyboard/BasicKeyboard.net.ref | Regenerated netlist reference reflecting XIAO wrapper path naming change. |
| edg/parts/microcontroller/Rp2040.py | Major refactor: RP2040 device pinmap modeling updates + new wrapper-style Xiao_Rp2040 implementation. |
| edg/electronics_model/SubboardBlock.py | Moves fp_external_blocks assignment into _def_to_proto to occur before constraints close. |
| edg/core/TransformUtil.py | Treats undefined port arrays as empty during transform traversal. |
| edg/core/Core.py | Changes finalize behavior to mark containers closed (preventing further mutation after finalize). |
| edg/core/Blocks.py | Avoids double-finalizing constraints by removing a redundant finalize call. |
| edg/abstract_parts/IoControllerWrapped.py | Adds pin-assign remapping utilities for wrapper footprint blocks. |
| edg/abstract_parts/IoControllerProgramming.py | Refactors SWD mixin to swd_connect_swo/tdi/reset booleans and delegates pin selection to pin_assigns. |
| edg/abstract_parts/IoControllerMixins.py | Updates mixin constructor to accept **kwargs to better support cooperative multiple inheritance. |
| edg/abstract_parts/IoController.py | Adds explicit IO export/wrap/tap APIs for wrapper blocks and pin-assign filtering with transforms. |
| edg/abstract_parts/init.py | Exports IoControllerWrapped from the package. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| inner_pin_assigns = self._export_ios_inner(inner, transforms) | ||
| self.assign(inner.pin_assigns, inner_pin_assigns) | ||
| self.assign(self.actual_pin_assigns, inner.actual_pin_assigns) | ||
| self.assign(self.io_current_draw, self.ic.io_current_draw) |
|
|
||
| def _remap_assigns_to_value(self, assigns: Dict[str, str]) -> List[str]: | ||
| """Given a dict of pin assigns from _remap_pinning_assigns, returns a list of assign strings | ||
| eefor use in self.actual_pin_assigns""" |
Comment on lines
22
to
+24
| class TestBlinkyBasic(SimpleBoardTop): | ||
| """The simplest cirucit, a microcontroller dev board with a LED.""" | ||
| """The simplest cirucit, a microcontroller dev board with a LED. | ||
| This also tests the dev board wrapper concept.""" |
ducky64
added a commit
that referenced
this pull request
May 31, 2026
Refactors the ESP32 and iCE40 microcontroller devices to use the new wrapper APIs microcontroller style from #502, #497 Deprecates BaseIoControllerExportable, now that all usages have been refactored out. Add pin filtering to PinMapUtil and implement it in device models. This is needed to restrict automatic allocation in wrapped microcontroller models, otherwise they allocate pins that don't exist on the modules. Add pin filtering to all wrappers. Allow pin names as part of pin_assign specifications; this is needed by wrapper remapping if the pin name and GPIO name don't line up. Fix the ground connection style of wrappers to account for when ground is unneeded in power source mode. Other refactorings: - Cleans up the _export_ios_inner implementation, to use a single dict and to not request() transformed-out IOs - Move the microcontroller wrapper test to the ESP32C3 as a more complex example with fewer pins to deal with - Deletes the owlbot example. It was a misnomer, and it uses the horribly abstraction breaking camera I2C pins which are no longer supported Resolves #389
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.
Prototype of the WrapperSubboardBlock-based microcontroller dev board that wraps the model subcircuit, instead of the older one which tried to deduplicate definition with a more complex kinda-dependency-injection setup.
This new version also eliminates the BaseIoControllerExportable, which was very magical, and instead provides _export_ios_inner, _wrap_inner (both of which takes optional port transforms), and _export_tap_ios_inner sub-block APIs that are more explicit.
Refactors the IoController SWD mixin to instead take swd_connect_swo/tdi as bool parameters, with pin assignment delegated to the standard pin_assigns parameter. There is no backwards compatibility path.
Fixes:
Future PRs:
On the path to #389