-
Notifications
You must be signed in to change notification settings - Fork 22
Add frozen module build infrastructure for CircuitPython firmware #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: Mikefly123 <61564344+Mikefly123@users.noreply.github.com>
Co-authored-by: Mikefly123 <61564344+Mikefly123@users.noreply.github.com>
Co-authored-by: Mikefly123 <61564344+Mikefly123@users.noreply.github.com>
|
@copilot I get this error when running the setup: make[1]: *** No rule to make target `fetch-submodules'. Stop.
make: *** [clone-circuitpython] Error 2 |
Changed from `fetch-submodules` to `fetch-all-submodules` which is the correct target in CircuitPython 9.2.0. Updated all documentation references. Co-authored-by: Mikefly123 <61564344+Mikefly123@users.noreply.github.com>
... Fixed in ffc8d90. Changed |
|
@copilot to reduce the size of the circuit python install required can we limit the submodules fetched to only those required to build firmware for the RP2040 and RP2350? |
Changed from `make fetch-all-submodules` to `python3 tools/ci_fetch_deps.py raspberrypi` which only fetches submodules needed for the raspberrypi port (RP2040/RP2350), significantly reducing download size and setup time. Updated all documentation to reflect this change. Co-authored-by: Mikefly123 <61564344+Mikefly123@users.noreply.github.com>
Implemented in 0d55df0. Changed to use |
|
@copilot now this error is being thrown:
|
Added `install-circuitpython-deps` target to install Python packages required for building CircuitPython firmware (cascadetoml, jinja2, typer, etc.). This fixes the gen_stage2.py import error during builds. Updated all documentation to reflect this requirement. Co-authored-by: Mikefly123 <61564344+Mikefly123@users.noreply.github.com>
Fixed in eacd5fc. The error was caused by missing Python build dependencies. Added |
|
@copilot can you make sure we are installing the dependences inside of the UV virtual environment? Installing CircuitPython build dependencies... × This environment is externally managed note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. |
Changed from pip3 --user to UV pip install to avoid externally-managed-environment errors on macOS. The Makefile now uses the UV tool from the root repository to install CircuitPython build dependencies in the virtual environment. Updated documentation to reflect this change and added troubleshooting entry for the macOS error. Co-authored-by: Mikefly123 <61564344+Mikefly123@users.noreply.github.com>
Fixed in 933289b. Changed from |
|
@copilot the cascadetoml error is still persisting:
|
Changed firmware build to use `uv run --no-project make` instead of directly calling make. This ensures the CircuitPython build scripts (like gen_stage2.py) have access to the Python packages installed in UV's virtual environment (cascadetoml, jinja2, typer). Updated documentation to emphasize using the Makefile for builds. Co-authored-by: Mikefly123 <61564344+Mikefly123@users.noreply.github.com>
Fixed in 29c5219. The issue was that CircuitPython's build scripts use system Python, which doesn't have access to packages in UV's virtual environment. The firmware build now uses |
|
@copilot the builds work now, which is great! We are having an issue with our CI linter though, where Interrogate is complaining about no docs in the firmware folder. Can we setup interrogate to ignore all the contents of that folder? |
Added firmware directory to Interrogate's exclude list in pyproject.toml to prevent documentation coverage checks on the firmware build infrastructure files. Co-authored-by: Mikefly123 <61564344+Mikefly123@users.noreply.github.com>
Fixed in 3f03d8a. Added |
|
@copilot I am encountering this error after adding the frozen modules definitions to mpconfigboard. This is my mpconfigboard: |
... This error occurs because CircuitPython expects frozen modules but To fix:
Quick test: Comment out all The error indicates the build process found frozen module references but no actual modules to freeze, causing the QSTR not to be generated. You need to populate the |
|



Implements complete build system for creating custom CircuitPython firmware with PySquared libraries compiled as frozen modules, eliminating the need for filesystem-based library deployment.
Summary
This PR adds a complete build infrastructure for creating custom CircuitPython firmware with PySquared libraries frozen (compiled into the firmware binary). Includes automated build system, dependency management, comprehensive documentation, and CI/CD workflows. The build system is optimized to only fetch CircuitPython submodules needed for RP2040/RP2350 boards, significantly reducing download size and setup time. Automatically installs required Python build dependencies in UV virtual environment and runs the entire build process within UV's Python environment to ensure all dependencies are accessible.
Build Infrastructure
firmware/Makefile- Automated build targets:setup,firmware,all-boards,clean,install-circuitpython-depsuv run --no-projectto execute CircuitPython builds in UV's Python environmentfirmware/add_dependencies.py- Parsespyproject.toml, identifies all 15 dependencies (PyPI + git), generates submodule commandsfirmware/boards/- Board configuration templates andmpconfigboard.mkexamples for PROVES Kit variantsDocumentation
docs/frozen-modules.md(360+ lines) - Prerequisites, build process, troubleshooting (including Python dependency issues, macOS externally-managed-environment errors, UV environment usage, and common frozen module configuration errors), CI/CD patternsfirmware/QUICKSTART.md- Command reference with troubleshooting table including dependency installation and macOS-specific issuesfirmware/EXAMPLE.md- End-to-end walkthrough with deployment scenarioCI/CD
.github/workflows/build-firmware.yaml- Automated builds on version tags, matrix build for all boards, uploads.uf2artifacts to releasespyproject.toml- Added firmware directory to Interrogate's exclude list to prevent documentation coverage checks on build infrastructureUsage
Important: Dependencies must be added to the
circuitpython/frozen/directory as git submodules before addingFROZEN_MPY_DIRSentries to board configuration files. See documentation for proper setup sequence.Benefits
.uf2file instead of 50+ library filesTechnical Notes
frozen/pysquaredto avoid duplicationcircuitpython/frozen/directorympconfigboard.mkfiles specifyFROZEN_MPY_DIRSfor each library (only after libraries are added)python3 tools/ci_fetch_deps.py raspberrypito fetch only RP2040/RP2350 dependencies (optimized fromfetch-all-submodules)requirements-dev.txtfor build tools (fixes gen_stage2.py import errors)uv run --no-projectto ensure CircuitPython build scripts (gen_stage2.py, etc.) execute in UV's Python environment where dependencies are installedFROZEN_MPY_DIRSreferences cause build errorsCommon Issues and Solutions
MP_QSTR__dot_frozenundeclared error: Occurs whenFROZEN_MPY_DIRSentries point to non-existent directories. Ensure all referenced libraries exist incircuitpython/frozen/before adding them to board configuration../add_dependencies.py --listto see required libraries and add them as git submodules before building.Requires ARM cross-compiler (
gcc-arm-none-eabi) for actual builds.How was this tested
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.