Merge pull request #6 from pimoroni/feature/phil-wave #137
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: MicroPython Firmware | |
on: | |
push: | |
pull_request: | |
release: | |
types: [created] | |
env: | |
MICROPYTHON_VERSION: v1.23.0 | |
PIMORONI_PICO_VERSION: v1.23.0-1 | |
WORKFLOW_VERSION: v3 | |
jobs: | |
deps: | |
runs-on: ubuntu-20.04 | |
name: Dependencies | |
steps: | |
- name: Workspace Cache | |
id: cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{runner.workspace}} | |
key: workspace-micropython-${{env.MICROPYTHON_VERSION}}-${{env.WORKFLOW_VERSION}} | |
restore-keys: | | |
workspace-micropython-${{env.MICROPYTHON_VERSION}}-${{env.WORKFLOW_VERSION}} | |
# Check out MicroPython | |
- name: Checkout MicroPython | |
if: steps.cache.outputs.cache-hit != 'true' | |
uses: actions/checkout@v4 | |
with: | |
repository: micropython/micropython | |
ref: ${{env.MICROPYTHON_VERSION}} | |
submodules: false # MicroPython submodules are hideously broken | |
path: micropython | |
- name: Fetch Pico submodules | |
if: steps.cache.outputs.cache-hit != 'true' | |
shell: bash | |
working-directory: micropython | |
run: | | |
git submodule update --init lib/pico-sdk | |
git submodule update --init lib/cyw43-driver | |
git submodule update --init lib/lwip | |
git submodule update --init lib/mbedtls | |
git submodule update --init lib/micropython-lib | |
git submodule update --init lib/tinyusb | |
git submodule update --init lib/btstack | |
- name: Build mpy-cross | |
if: steps.cache.outputs.cache-hit != 'true' | |
shell: bash | |
working-directory: micropython/mpy-cross | |
run: make | |
build: | |
needs: deps | |
name: Build ${{matrix.name}} | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
include: | |
- name: TinyFX | |
shortname: tiny_fx | |
board: PIMORONI_TINYFX | |
- name: TinyFX W | |
shortname: tiny_fx_w | |
board: PIMORONI_TINYFX | |
variant: w | |
env: | |
RELEASE_FILE: pimoroni-${{matrix.shortname}}-${{github.event.release.tag_name || github.sha}}-micropython | |
FIRMWARE_DIR: "$GITHUB_WORKSPACE/picofx/boards" | |
ROOT_DIR: "$GITHUB_WORKSPACE/picofx" | |
BOARD_DIR: "$GITHUB_WORKSPACE/picofx/boards/${{matrix.board}}" | |
EXAMPLES_DIR: "$GITHUB_WORKSPACE/picofx/examples/tiny_fx" | |
FILESYSTEM_DIR: "$GITHUB_WORKSPACE/picofx/temp" | |
FILESYSTEM_SUFFIX: "with-libs-and-examples" | |
BOARD: "PIMORONI_TINYFX" | |
BOARD_VARIANT: ${{ matrix.variant }} | |
steps: | |
- name: Compiler Cache | |
uses: actions/cache@v4 | |
with: | |
path: /home/runner/.ccache | |
key: ccache-micropython-${{matrix.shortname}}-${{github.ref}}-${{github.sha}} | |
restore-keys: | | |
ccache-micropython-${{matrix.shortname}}-${{github.ref}} | |
ccache-micropython-${{matrix.shortname}}- | |
- name: Workspace Cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{runner.workspace}} | |
key: workspace-micropython-${{env.MICROPYTHON_VERSION}}-${{env.WORKFLOW_VERSION}} | |
restore-keys: | | |
workspace-micropython-${{env.MICROPYTHON_VERSION}}-${{env.WORKFLOW_VERSION}} | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
path: picofx | |
# Check out Pimoroni Pico | |
- uses: actions/checkout@v4 | |
with: | |
repository: pimoroni/pimoroni-pico | |
ref: ${{env.PIMORONI_PICO_VERSION}} | |
submodules: true | |
path: pimoroni-pico | |
- name: "Py_Decl: Checkout py_decl" | |
uses: actions/checkout@v4 | |
with: | |
repository: gadgetoid/py_decl | |
ref: v0.0.1 | |
path: py_decl | |
# Check out dir2u2f | |
- uses: actions/checkout@v4 | |
with: | |
repository: gadgetoid/dir2uf2 | |
ref: v0.0.6 | |
path: dir2uf2 | |
- name: "HACK: MicroPython out of tree board pins.csv patch" | |
shell: bash | |
working-directory: micropython | |
run: | | |
git apply "${{env.FIRMWARE_DIR}}/932f76c6ba64c5a3e68de3324556d9979f09303b.patch" | |
- name: "HACK: MicroPython RP2 board variant patch" | |
shell: bash | |
working-directory: micropython | |
run: | | |
git apply "${{env.FIRMWARE_DIR}}/5dff78f38edc0354e854e6c73af61c5064afe9d3.patch" | |
- name: "HACK: MicroPython RP2 MICROPY_DEF_BOARD patch" | |
shell: bash | |
working-directory: micropython | |
run: | | |
git apply "${{env.FIRMWARE_DIR}}/11becbe22321ca1d7bd631144976f246175730ce.patch" | |
- name: Install Arm GNU Toolchain (arm-none-eabi-gcc) | |
uses: carlosperate/arm-none-eabi-gcc-action@v1 | |
with: | |
release: '9-2020-q2' | |
- name: Install CCache | |
run: | | |
sudo apt update && sudo apt install ccache | |
# Build firmware | |
- name: Configure MicroPython | |
shell: bash | |
working-directory: micropython/ports/rp2 | |
run: | | |
cmake -S . -B build -DPICO_BUILD_DOCS=0 -DUSER_C_MODULES=${{env.BOARD_DIR}}/micropython.cmake -DMICROPY_BOARD_DIR=${{env.BOARD_DIR}} -DMICROPY_BOARD=${{env.BOARD}} -DMICROPY_BOARD_VARIANT=${{env.BOARD_VARIANT}} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DPICO_BOARD_HEADER_DIRS=${{env.BOARD_DIR}} | |
- name: Build MicroPython | |
shell: bash | |
working-directory: micropython/ports/rp2 | |
run: | | |
ccache --zero-stats || true | |
cmake --build build -j 2 | |
ccache --show-stats || true | |
- name: Rename .uf2 for artifact | |
shell: bash | |
working-directory: micropython/ports/rp2/build | |
run: | | |
cp firmware.uf2 ${{env.RELEASE_FILE}}.uf2 | |
- name: "Py_Decl: Verify UF2" | |
shell: bash | |
run: | | |
python3 py_decl/py_decl.py --to-json --verify micropython/ports/rp2/build/${{ env.RELEASE_FILE }}.uf2 | |
- name: "HACK: Mangle PicoFX Lib into user filesystem" | |
shell: bash | |
run: | | |
mkdir -p ${{env.FILESYSTEM_DIR}}/lib | |
cp -v -r ${{env.ROOT_DIR}}/picofx ${{env.FILESYSTEM_DIR}}/lib | |
cp -v -r ${{env.BOARD_DIR}}/visible_libs/. ${{env.FILESYSTEM_DIR}}/lib | |
cp -v -r ${{env.EXAMPLES_DIR}}/. ${{env.FILESYSTEM_DIR}} | |
- name: Append Filesystem | |
shell: bash | |
run: | | |
python3 -m pip install littlefs-python==0.12.0 | |
./dir2uf2/dir2uf2 --fs-compact --append-to micropython/ports/rp2/build/${{env.RELEASE_FILE}}.uf2 --manifest ${{env.BOARD_DIR}}/uf2-manifest.txt --filename ${{env.FILESYSTEM_SUFFIX}}.uf2 ${{env.FILESYSTEM_DIR}}/ | |
- name: Store .uf2 as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{env.RELEASE_FILE}} | |
path: micropython/ports/rp2/build/${{env.RELEASE_FILE}}.uf2 | |
- name: Store .uf2 + Filesystem as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{env.RELEASE_FILE}}-${{env.FILESYSTEM_SUFFIX}} | |
path: ${{env.RELEASE_FILE}}-${{env.FILESYSTEM_SUFFIX}}.uf2 | |
- name: Upload .uf2 | |
if: github.event_name == 'release' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
with: | |
asset_path: micropython/ports/rp2/build/${{env.RELEASE_FILE}}.uf2 | |
upload_url: ${{github.event.release.upload_url}} | |
asset_name: ${{env.RELEASE_FILE}}.uf2 | |
asset_content_type: application/octet-stream | |
- name: Upload .uf2 + Filesystem | |
if: github.event_name == 'release' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
with: | |
asset_path: ${{env.RELEASE_FILE}}-${{env.FILESYSTEM_SUFFIX}}.uf2 | |
upload_url: ${{github.event.release.upload_url}} | |
asset_name: ${{env.RELEASE_FILE}}-${{env.FILESYSTEM_SUFFIX}}.uf2 | |
asset_content_type: application/octet-stream |