Skip to main content

Pairing a CircuitPython Version with Its Board ID in Circup

Passing the manual CircuitPython version and board ID together preserves the backend input shape used for compiled-library compatibility checks.

Updated 3 min readMarkdown
Part of seriesOpen-Source Contributions
Pairing a CircuitPython Version with Its Board ID in Circup

A local-device fix keeps both manual values together so Circup’s backend can check compiled-library compatibility correctly.

CircuitPython is Python for microcontroller boards. Circup, Adafruit’s command-line library manager, needs to know which board and CircuitPython version it is working with. That information helps it choose compatible libraries, including compiled .mpy files.

Usually Circup can detect the device details. But when a local device path does not provide the metadata Circup needs, a developer can pass it manually with --cpy-version and --board-id.

Figure 1. Circup forms a manual version and board-ID tuple before passing it to the selected backend.

Figure 1. The values travel together as (CircuitPython version, board ID), matching the backend's expected data shape.

The bug

When both options were supplied, Circup passed only the version string to the backend. The backend API expects a pair: the CircuitPython version and the board identifier. Later, the MPY compatibility check treated the string as if it were that pair. This could make list or update fail for local paths.

The intended input is:

circup --path /path/to/CIRCUITPY --cpy-version 11.0.0 --board-id fake list

The fix creates a tuple only when both values are present:

version_override = (
    (cpy_version, board_id)
    if cpy_version is not None and board_id is not None
    else None
)

The same tuple is passed to either the Web Workflow backend or the disk backend. That keeps the values in the shape the backend already expects and leaves automatic detection unchanged.

Why the pair matters

The CircuitPython version describes the firmware release. The board ID identifies the target board. Compiled modules may be specific to both. Passing one string where a two-value input is expected loses that relationship and can break the compatibility check.

Conceptually, the override is the ordered pair:

version_override = (CircuitPython version, board ID)

For example, a version by itself is not the complete manual override. Circup uses the pair when both flags are supplied, then hands that pair to the selected backend.

Review and merge

I submitted this change as @shaxntanu. During review, @FoamyGuy noted that CircuitPython 8.0.0 was no longer supported and asked me to use 11.0.0 instead. After I updated the example and regression test, @FoamyGuy approved and merged the PR.

Validation

A regression test checks that the backend receives ("11.0.0", "fake") when both flags are provided. The hosted GitHub Actions test job passed. The full local Windows run reported 65 passing tests and five failures in unchanged path-format and CLI/network-sensitive tests.

The fix was merged in Adafruit Circup PR #294, addressing issue #220.

What I took away

Small data-shape mismatches can travel a long way before failing. This fix keeps the version and board ID together at the point where Circup creates the backend, so later compatibility checks receive the information they were designed to use.

References

About the author

  • Tech enthusiast, interested in ECE and other multidisciplinary projects.

No comments yet. Be the first to comment.

Open-Source Contributions

Part 2 of 6

A place where I write about my open-source contributions, the stuff I worked on, the bugs I ran into, what I learned, and how the whole process actually went. Basically the story behind the PR, not just the green merged badge.

Up nextMaking Circup’s Terminal Colors Clearer on Dark BackgroundsBright ANSI colors improve visibility in dark terminal themes, while contrast on light backgrounds remains palette-dependent.