Skip to content

Refactor microcontroller dev boards to use composition#508

Merged
ducky64 merged 20 commits into
masterfrom
micro-wrapper-again
May 31, 2026
Merged

Refactor microcontroller dev boards to use composition#508
ducky64 merged 20 commits into
masterfrom
micro-wrapper-again

Conversation

@ducky64
Copy link
Copy Markdown
Collaborator

@ducky64 ducky64 commented 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

@ducky64 ducky64 requested a review from Copilot May 31, 2026 23:00
@ducky64 ducky64 marked this pull request as ready for review May 31, 2026 23:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors microcontroller dev-board wrapper implementations (ESP32 + iCE40) toward the newer composition-based wrapper APIs, adds pin filtering to prevent wrapped models from allocating non-existent pins, and updates/removes examples accordingly.

Changes:

  • Add PinMapUtil.filter_pins(...) and broaden pin assignment parsing to support pin names (not only pin numbers) for wrapper remapping.
  • Refactor iCE40UP and ESP32-family wrapper/device models to use the newer wrapper composition style and pin filtering.
  • Update example netlist reference outputs and remove the RobotOwl example artifacts/tests.

Reviewed changes

Copilot reviewed 58 out of 59 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
edg/abstract_parts/PinMappable.py Adds pin filtering support and pinname-aware matching in pin mapping utilities.
edg/parts/microcontroller/Ice40up.py Refactors iCE40UP device/wrapper structure to the newer wrapper style and updates pin/peripheral resources.
edg/abstract_parts/IoController.py Refactors IO export/wrap plumbing to better support transforms and wrapper composition.
edg/parts/microcontroller/test_mcu_wrapper.py Updates microcontroller wrapper tests (now targeting ESP32-C3 wrapper flow).
edg/abstract_parts/test_pinmappable.py Extends unit tests for pin mapping/allocation behaviors with the new filtering functionality.
examples/test_fcml.py Updates the FPGA instantiation to the refactored iCE40UP API.
examples/test_deskcontroller.py Updates refinements to match refactored MCU wrapper parameter structure.
examples/UsbSourceMeasure/UsbSourceMeasure.net.ref Refreshes golden netlist output to match refactored wrapper/program header mapping.
examples/SevenSegment/SevenSegment.net.ref Refreshes golden netlist output to match refactored wrapper/program header mapping.
examples/test_robotowl.py Removes the RobotOwl example test (example deleted/out of support scope).
examples/RobotOwl/RobotOwl.kicad_pro Removes RobotOwl KiCad project artifact as part of example deletion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread edg/abstract_parts/PinMappable.py Outdated
Comment on lines +345 to +358
elif isinstance(resource, PeripheralFixedPin):
filtered_keys = []
for key, pin in resource.inner_allowed_pins.items():
if pin in allowed_pins or resource.inner_pinnames[key] in allowed_pins:
filtered_keys.append(key)
if filtered_keys:
return PeripheralFixedPin(
resource.name,
resource.port_model,
{k: v for k, v in resource.inner_allowed_pins.items() if k in filtered_keys},
{k: v for k, v in resource.inner_pinnames.items() if k in filtered_keys},
)
else:
return None
Comment on lines 214 to 217
# hard macros I2C and SPI
PeripheralAnyResource("I2C1", i2c_model),
PeripheralAnyResource("I2C1", i2c_model),
PeripheralAnyResource("SPI1", spi_model),
@ducky64 ducky64 merged commit 5e0be14 into master May 31, 2026
12 checks passed
@ducky64 ducky64 deleted the micro-wrapper-again branch May 31, 2026 23:30
ducky64 added a commit that referenced this pull request Jun 1, 2026
... and refactors some examples to use this.

Also restructures STM microcontrollers to use the new system pindef
style from #508 . Updates the STM32F103 JLC metadata to reflect the part
choice change from a prior PR.

Resolves #504
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.

Unify microcontroller and breakout board versions

2 participants