Skip to content

Commit

Permalink
CI: Add dir2uf2, refactor various manifest tooling.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Aug 10, 2024
1 parent c3f946b commit df97992
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 14 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/micropython.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ jobs:
# MicroPython version will be contained in github.event.release.tag_name for releases
RELEASE_FILE: ${{ matrix.name }}-${{ github.event.release.tag_name || github.sha }}-micropython
PIMORONI_PICO_DIR: "${{ github.workspace }}/pimoroni-pico"
MICROPY_BOARD_DIR: "${{ github.workspace }}/src-${{ github.sha }}/${{ matrix.BOARD }}"
USER_C_MODULES: "${{ github.workspace }}/src-${{ github.sha }}/modules/${{ matrix.modules }}.cmake"
USER_FS_MANIFEST: "${{ github.workspace }}/src-${{ github.sha }}/modules/${{ matrix.modules }}.txt"
USER_FS_SOURCE: "${{ github.workspace }}/src-${{ github.sha }}/modules/littlefs"
TAG_OR_SHA: ${{ github.event.release.tag_name || github.sha }}
MICROPY_BOARD: ${{ matrix.board }}
MICROPY_BOARD_VARIANT: ${{ matrix.variant }}
MICROPY_BOARD_DIR: "${{ github.workspace }}/src-${{ github.sha }}/${{ matrix.BOARD }}"
MICROPY_FROZEN_MANIFEST: "${{ github.workspace }}/src-${{ github.sha }}/modules/${{ matrix.modules }}.py"
BOARD_NAME: ${{ matrix.name }}
BUILD_TOOLS: src-${{ github.sha }}/ci/micropython.sh

Expand Down Expand Up @@ -81,12 +84,19 @@ jobs:
source $BUILD_TOOLS
micropython_clone
- name: "Py_Decl: Checkout py_decl"
- name: "Py_Decl: Checkout"
uses: actions/checkout@v4
with:
repository: gadgetoid/py_decl
ref: v0.0.2
path: py_decl

- name: "dir2uf2: Checkout"
uses: actions/checkout@v4
with:
repository: gadgetoid/dir2uf2
ref: v0.0.7
path: dir2uf2

- name: "MicroPython: Build MPY Cross"
run: |
Expand All @@ -111,6 +121,12 @@ jobs:
run: |
python3 py_decl/py_decl.py --to-json --verify build-${{ matrix.name }}/${{ env.RELEASE_FILE }}.uf2
- name: "dir2uf2: Append filesystem to UF2"
shell: bash
run: |
python3 -m pip install littlefs-python==0.12.0
./dir2uf2/dir2uf2 --fs-compact --append-to build-${{ matrix.name }}/${{ env.RELEASE_FILE }}.uf2 --manifest ${{env.USER_FS_MANIFEST}} --filename with-filesystem.uf2 ${{env.USER_FS_SOURCE}}/
- name: Store .uf2 as artifact
uses: actions/upload-artifact@v4
with:
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ should automatically handle building MicroPython for you.
* pga2350 - MicroPython and Pico SDK board definitions for PGA2350, with PSRAM variant
* modules/c/example - An example MicroPython C++ module, demonstrating C class bindings
* modules/py_frozen - Python files intended to be frozen into the firmware
* modules/py_littlefs - Python files intended to be visible/editable in the LittleFS user filesystem
* modules/py_littlefs - Python files intended to be visible/editable in the LittleFS user filesystem
* modules/default.py - The MicroPython manifest file, for specifying frozen libs
* modules/default.txt - The dir2uf2 LittleFS manifest file, for specifying included files
* modules/default.cmake - The MicroPython USER_C_MODULES file, for specifying included C/C++ modules
1 change: 1 addition & 0 deletions ci/micropython.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function cmake_configure {
-DMICROPY_BOARD_DIR=$MICROPY_BOARD_DIR \
-DMICROPY_BOARD=$MICROPY_BOARD \
-DMICROPY_BOARD_VARIANT=$MICROPY_BOARD_VARIANT \
-DMICROPY_FROZEN_MANIFEST=$MICROPY_FROZEN_MANIFEST \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
}
Expand Down
8 changes: 8 additions & 0 deletions modules/default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Include the manifest.py from micropython/ports/rp2/boards/manifest.py
include("$(PORT_DIR)/boards/manifest.py")

# Include the manifest.py from micropython/<board>/manifest.py
include("$(BOARD_DIR)/manifest.py")

# Include pga/modules/py_frozen
freeze("py_frozen/")
1 change: 1 addition & 0 deletions modules/default.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example.py
Empty file removed modules/frozen.py
Empty file.
1 change: 0 additions & 1 deletion modules/littlefs.txt

This file was deleted.

5 changes: 5 additions & 0 deletions modules/py_frozen/frozen_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file should be frozen into the MicroPython build
# try: `import frozen_example`

def example():
print("Hello Frozen Example")
2 changes: 2 additions & 0 deletions modules/py_littlefs/example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file should be added to the user-facing MicroPython filesystem
print("Hello World")
6 changes: 1 addition & 5 deletions pga2040/manifest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
# Include the manifest.py from micropython/ports/rp2/boards/manifest.py
include("$(PORT_DIR)/boards/manifest.py")

# Include frozen.py from pga/modules/frozen.py
include("../modules/frozen.py")
# Board-specific frozen libs go here
6 changes: 1 addition & 5 deletions pga2350/manifest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
# Include the manifest.py from micropython/ports/rp2/boards/manifest.py
include("$(PORT_DIR)/boards/manifest.py")

# Include frozen.py from pga/modules/frozen.py
include("../modules/frozen.py")
# Board-specific frozen libs go here

0 comments on commit df97992

Please sign in to comment.