diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index 5026a8d..752d298 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -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 @@ -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: | @@ -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: diff --git a/README.md b/README.md index 009bbe1..2a3808e 100644 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file +* 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 \ No newline at end of file diff --git a/ci/micropython.sh b/ci/micropython.sh index 0a4b53a..2cbff92 100644 --- a/ci/micropython.sh +++ b/ci/micropython.sh @@ -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 } diff --git a/modules/default.py b/modules/default.py new file mode 100644 index 0000000..eef495b --- /dev/null +++ b/modules/default.py @@ -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//manifest.py +include("$(BOARD_DIR)/manifest.py") + +# Include pga/modules/py_frozen +freeze("py_frozen/") \ No newline at end of file diff --git a/modules/default.txt b/modules/default.txt new file mode 100644 index 0000000..8d75d26 --- /dev/null +++ b/modules/default.txt @@ -0,0 +1 @@ +example.py \ No newline at end of file diff --git a/modules/frozen.py b/modules/frozen.py deleted file mode 100644 index e69de29..0000000 diff --git a/modules/littlefs.txt b/modules/littlefs.txt deleted file mode 100644 index f2e897a..0000000 --- a/modules/littlefs.txt +++ /dev/null @@ -1 +0,0 @@ -lib/*/*.py \ No newline at end of file diff --git a/modules/py_frozen/frozen_example.py b/modules/py_frozen/frozen_example.py new file mode 100644 index 0000000..e789599 --- /dev/null +++ b/modules/py_frozen/frozen_example.py @@ -0,0 +1,5 @@ +# This file should be frozen into the MicroPython build +# try: `import frozen_example` + +def example(): + print("Hello Frozen Example") \ No newline at end of file diff --git a/modules/py_littlefs/example.py b/modules/py_littlefs/example.py new file mode 100644 index 0000000..51bd8e8 --- /dev/null +++ b/modules/py_littlefs/example.py @@ -0,0 +1,2 @@ +# This file should be added to the user-facing MicroPython filesystem +print("Hello World") \ No newline at end of file diff --git a/pga2040/manifest.py b/pga2040/manifest.py index 8505dcb..4819e73 100644 --- a/pga2040/manifest.py +++ b/pga2040/manifest.py @@ -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") \ No newline at end of file +# Board-specific frozen libs go here \ No newline at end of file diff --git a/pga2350/manifest.py b/pga2350/manifest.py index 8505dcb..4819e73 100644 --- a/pga2350/manifest.py +++ b/pga2350/manifest.py @@ -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") \ No newline at end of file +# Board-specific frozen libs go here \ No newline at end of file