Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Jul 29, 2024
0 parents commit 20e7fe9
Show file tree
Hide file tree
Showing 23 changed files with 805 additions and 0 deletions.
201 changes: 201 additions & 0 deletions .github/workflows/micropython.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
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 2MB
shortname: tinyfx_2m
board: PIMORONI_TINYFX
- name: TinyFX 4MB
shortname: tinyfx_4m
board: PIMORONI_TINYFX
variant: FLASH_4MB

env:
RELEASE_FILE: pimoroni-${{matrix.shortname}}-${{github.event.release.tag_name || github.sha}}-micropython.uf2
RELEASE_FILE_WITH_OS: pimoroni-${{matrix.shortname}}-${{github.event.release.tag_name || github.sha}}-micropython-with-examples.uf2
FIRMWARE_DIR: "$GITHUB_WORKSPACE/picofx/boards"
BOARD_DIR: "$GITHUB_WORKSPACE/picofx/boards/${{matrix.board}}"
EXAMPLES_DIR: "$GITHUB_WORKSPACE/picofx/examples"

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.5
path: dir2uf2

- name: "HACK: MicroPython out of tree board pins.csv & variants patches"
shell: bash
working-directory: micropython
run: |
git apply "${{env.BOARD_DIR}}/932f76c6ba64c5a3e68de3324556d9979f09303b.patch"
git apply "${{env.BOARD_DIR}}/5dff78f38edc0354e854e6c73af61c5064afe9d3.patch"
# Install apt packages
- name: Install CCache & Compiler
shell: bash
run:
sudo apt update && sudo apt install ccache gcc-arm-none-eabi

# 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}} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DMICROPY_BOARD_VARIANT=${{env.VARIANT}}
- 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}}
- name: "Py_Decl: Verify UF2"
shell: bash
run: |
python3 py_decl/py_decl.py --to-json --verify micropython/ports/rp2/build/${{ env.RELEASE_FILE }}
- 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}} --manifest ${{env.BOARD_DIR}}/uf2-manifest.txt --filename with-examples.uf2 ${{env.EXAMPLES_DIR}}/
- name: Store .uf2 as artifact
uses: actions/upload-artifact@v4
with:
name: ${{env.RELEASE_FILE}}
path: micropython/ports/rp2/build/${{env.RELEASE_FILE}}

- name: Store .uf2 + Examples as artifact
uses: actions/upload-artifact@v4
with:
name: ${{env.RELEASE_FILE_WITH_OS}}
path: ${{env.RELEASE_FILE_WITH_OS}}

- 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}}
upload_url: ${{github.event.release.upload_url}}
asset_name: ${{env.RELEASE_FILE}}
asset_content_type: application/octet-stream

- name: Upload .uf2 + Examples
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
asset_path: ${{env.RELEASE_FILE_WITH_OS}}
upload_url: ${{github.event.release.upload_url}}
asset_name: ${{env.RELEASE_FILE_WITH_OS}}
asset_content_type: application/octet-stream
30 changes: 30 additions & 0 deletions .github/workflows/python-linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Python Linting

on:
push:
pull_request:

jobs:
build:
name: Python Linting
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4

- name: Install Python Deps
run: python3 -m pip install flake8

- name: Lint PicoFX
shell: bash
run: |
python3 -m flake8 --show-source --ignore E501 picofx
- name: Lint Examples
shell: bash
run: |
python3 -m flake8 --show-source --ignore E501 examples
- name: Lint TinyFX Libs
shell: bash
run: |
python3 -m flake8 --show-source --ignore E501 boards/PIMORONI_TINYFX/lib
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Pimoroni Ltd

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# PicoFX

## A tiny RGB and Mono LED effects sequencer for MicroPython


101 changes: 101 additions & 0 deletions boards/5dff78f38edc0354e854e6c73af61c5064afe9d3.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
From 5dff78f38edc0354e854e6c73af61c5064afe9d3 Mon Sep 17 00:00:00 2001
From: Damien George <[email protected]>
Date: Mon, 24 Jun 2024 12:37:13 +1000
Subject: [PATCH] rp2: Rework board variant support to require mpconfigvariant
file.

Following how the board variants now work in the esp32 port.

Signed-off-by: Damien George <[email protected]>
---
ports/rp2/CMakeLists.txt | 12 ++++++++++++
ports/rp2/boards/WEACTSTUDIO/mpconfigboard.cmake | 16 ----------------
.../rp2/boards/WEACTSTUDIO/mpconfigvariant.cmake | 1 +
.../WEACTSTUDIO/mpconfigvariant_FLASH_2M.cmake | 1 +
.../WEACTSTUDIO/mpconfigvariant_FLASH_4M.cmake | 1 +
.../WEACTSTUDIO/mpconfigvariant_FLASH_8M.cmake | 1 +
6 files changed, 16 insertions(+), 16 deletions(-)
create mode 100644 ports/rp2/boards/WEACTSTUDIO/mpconfigvariant.cmake
create mode 100644 ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_2M.cmake
create mode 100644 ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_4M.cmake
create mode 100644 ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_8M.cmake

diff --git a/ports/rp2/CMakeLists.txt b/ports/rp2/CMakeLists.txt
index 8f5680092c92..8fff4251487f 100644
--- a/ports/rp2/CMakeLists.txt
+++ b/ports/rp2/CMakeLists.txt
@@ -38,10 +38,22 @@ if(NOT EXISTS ${MICROPY_BOARD_DIR}/mpconfigboard.cmake)
message(FATAL_ERROR "Invalid MICROPY_BOARD specified: ${MICROPY_BOARD}")
endif()

+# If a board variant is specified, check that it exists.
+if(MICROPY_BOARD_VARIANT)
+ if(NOT EXISTS ${MICROPY_BOARD_DIR}/mpconfigvariant_${MICROPY_BOARD_VARIANT}.cmake)
+ message(FATAL_ERROR "Invalid MICROPY_BOARD_VARIANT specified: ${MICROPY_BOARD_VARIANT}")
+ endif()
+endif()
+
set(MICROPY_USER_FROZEN_MANIFEST ${MICROPY_FROZEN_MANIFEST})

# Include board config, it may override MICROPY_FROZEN_MANIFEST
include(${MICROPY_BOARD_DIR}/mpconfigboard.cmake)
+if(NOT MICROPY_BOARD_VARIANT)
+ include(${MICROPY_BOARD_DIR}/mpconfigvariant.cmake OPTIONAL)
+else()
+ include(${MICROPY_BOARD_DIR}/mpconfigvariant_${MICROPY_BOARD_VARIANT}.cmake)
+endif()

# Set the PICO_BOARD if it's not already set (allow a board to override it).
if(NOT PICO_BOARD)
diff --git a/ports/rp2/boards/WEACTSTUDIO/mpconfigboard.cmake b/ports/rp2/boards/WEACTSTUDIO/mpconfigboard.cmake
index 848b50f604db..d922644bf626 100644
--- a/ports/rp2/boards/WEACTSTUDIO/mpconfigboard.cmake
+++ b/ports/rp2/boards/WEACTSTUDIO/mpconfigboard.cmake
@@ -6,19 +6,3 @@ list(APPEND PICO_BOARD_HEADER_DIRS ${MICROPY_BOARD_DIR})

# Freeze board.py
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
-
-# Select the 16MB variant as the default
-set(PICO_BOARD "weactstudio_16MiB")
-
-# Provide different variants for the downloads page
-if(MICROPY_BOARD_VARIANT STREQUAL "FLASH_2M")
- set(PICO_BOARD "weactstudio_2MiB")
-endif()
-
-if(MICROPY_BOARD_VARIANT STREQUAL "FLASH_4M")
- set(PICO_BOARD "weactstudio_4MiB")
-endif()
-
-if(MICROPY_BOARD_VARIANT STREQUAL "FLASH_8M")
- set(PICO_BOARD "weactstudio_8MiB")
-endif()
diff --git a/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant.cmake b/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant.cmake
new file mode 100644
index 000000000000..4e68b2112f1d
--- /dev/null
+++ b/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant.cmake
@@ -0,0 +1 @@
+set(PICO_BOARD "weactstudio_16MiB")
diff --git a/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_2M.cmake b/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_2M.cmake
new file mode 100644
index 000000000000..b8d7202dada5
--- /dev/null
+++ b/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_2M.cmake
@@ -0,0 +1 @@
+set(PICO_BOARD "weactstudio_2MiB")
diff --git a/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_4M.cmake b/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_4M.cmake
new file mode 100644
index 000000000000..75afb1ba4006
--- /dev/null
+++ b/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_4M.cmake
@@ -0,0 +1 @@
+set(PICO_BOARD "weactstudio_4MiB")
diff --git a/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_8M.cmake b/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_8M.cmake
new file mode 100644
index 000000000000..359e47c01161
--- /dev/null
+++ b/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_8M.cmake
@@ -0,0 +1 @@
+set(PICO_BOARD "weactstudio_8MiB")
Loading

0 comments on commit 20e7fe9

Please sign in to comment.