Skip to content

Commit

Permalink
Replace with build derived from inky-frame.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Dec 4, 2024
1 parent 849e8a6 commit 4c111cb
Show file tree
Hide file tree
Showing 223 changed files with 8,710 additions and 19,275 deletions.
176 changes: 60 additions & 116 deletions .github/workflows/micropython.yml
Original file line number Diff line number Diff line change
@@ -1,154 +1,98 @@
name: MicroPython Firmware
name: MicroPython

on:
push:
pull_request:
release:
types: [created]

env:
MICROPYTHON_VERSION: v1.20.0
PIMORONI_PICO_VERSION: 302d6ae0ebccbec8b676a5eb5e1ec9b273f4eecd

jobs:
deps:
runs-on: ubuntu-20.04
name: Dependencies
steps:
- name: Workspace Cache
id: cache
uses: actions/cache@v3
with:
path: ${{runner.workspace}}
key: workspace-micropython-${{env.MICROPYTHON_VERSION}}
restore-keys: |
workspace-micropython-${{env.MICROPYTHON_VERSION}}
# Check out MicroPython
- name: Checkout MicroPython
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/checkout@v3
with:
repository: micropython/micropython
ref: ${{env.MICROPYTHON_VERSION}}
submodules: false # MicroPython submodules are hideously broken
path: micropython

- name: Fetch base MicroPython submodules
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
working-directory: micropython
run: git submodule update --init

- name: Fetch Pico SDK submodules
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
working-directory: micropython/lib/pico-sdk
run: git submodule update --init

- 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
name: MicroPython ${{ matrix.name }}
runs-on: ubuntu-24.04
continue-on-error: true
strategy:
matrix:
include:
- name: Cosmic Unicorn
shortname: cosmic_unicorn
board: PIMORONI_COSMIC_UNICORN
- name: Galactic Unicorn
shortname: galactic_unicorn
board: PIMORONI_GALACTIC_UNICORN
- name: pico_w_unicorn
- name: pico2_w_unicorn

env:
RELEASE_FILE: pimoroni-${{matrix.shortname}}-${{github.event.release.tag_name || github.sha}}-micropython.uf2
FIRMWARE_DIR: "$GITHUB_WORKSPACE/unicorn/firmware"
BOARD_DIR: "$GITHUB_WORKSPACE/unicorn/firmware/${{matrix.board}}"
# 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
CI_PROJECT_ROOT: ${{ github.workspace }}/src-${{ github.sha }}
CI_BUILD_ROOT: ${{ github.workspace }}

steps:
- name: Compiler Cache
uses: actions/cache@v3
- name: Compiler Cache Fixup
run: |
mkdir -p /home/runner/.ccache
- name: "CCache: Restore saved 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@v3
with:
path: ${{runner.workspace}}
key: workspace-micropython-${{env.MICROPYTHON_VERSION}}
key: ccache-micropython-${{ matrix.name }}-${{ github.ref }}-${{ github.sha }}
restore-keys: |
workspace-micropython-${{env.MICROPYTHON_VERSION}}
ccache-micropython-${{ matrix.name }}-${{ github.ref }}
ccache-micropython-${{ matrix.name }}-
- uses: actions/checkout@v3
- name: "Checkout Project"
uses: actions/checkout@v4
with:
submodules: true
path: unicorn
path: ${{ env.CI_PROJECT_ROOT }}

# Check out Pimoroni Pico
- uses: actions/checkout@v3
- name: "Install Arm GNU Toolchain (arm-none-eabi-gcc)"
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
repository: pimoroni/pimoroni-pico
ref: ${{env.PIMORONI_PICO_VERSION}}
submodules: true
path: pimoroni-pico
release: '13.3.Rel1'

# HACK: Patch startup overclock into Pico SDK
- name: "HACK: Startup Overclock Patch"
- name: "Prepare tools & dependencies"
shell: bash
working-directory: micropython/lib/pico-sdk
run: |
git apply "${{env.FIRMWARE_DIR}}/startup_overclock.patch"
# Install apt packages
- name: Install CCache & Compiler
shell: bash
run:
sudo apt update && sudo apt install ccache gcc-arm-none-eabi
source $CI_PROJECT_ROOT/ci/micropython.sh && ci_debug
mkdir -p $CI_BUILD_ROOT
ci_apt_install_build_deps
ci_prepare_all
# Build firmware
- name: Configure MicroPython
- name: "MicroPython: Configure"
shell: bash
working-directory: micropython/ports/rp2
run: |
cmake -S . -B build-${{matrix.shortname}} -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
source $CI_PROJECT_ROOT/ci/micropython.sh && ci_debug
micropython_version
ci_cmake_configure ${{ matrix.name }}
- name: Build MicroPython
- name: "MicroPython: Build"
shell: bash
working-directory: micropython/ports/rp2
run: |
ccache --zero-stats || true
cmake --build build-${{matrix.shortname}} -j 1
ccache --show-stats || true
- name: Rename .uf2 for artifact
shell: bash
working-directory: micropython/ports/rp2/build-${{matrix.shortname}}
run: |
cp firmware.uf2 ${{env.RELEASE_FILE}}
source $CI_PROJECT_ROOT/ci/micropython.sh && ci_debug
python3 -m venv "$CI_BUILD_ROOT/.dir2uf2"
source "$CI_BUILD_ROOT/.dir2uf2/bin/activate"
ci_cmake_build ${{ matrix.name }}
mv "$CI_BUILD_ROOT/${{ matrix.name }}.uf2" "$CI_BUILD_ROOT/$RELEASE_FILE.uf2"
mv "$CI_BUILD_ROOT/${{ matrix.name }}-with-filesystem.uf2" "$CI_BUILD_ROOT/$RELEASE_FILE-with-filesystem.uf2"
- name: "Artifacts: Upload .uf2"
uses: actions/upload-artifact@v4
with:
name: ${{ env.RELEASE_FILE }}.uf2
path: ${{ env.CI_BUILD_ROOT }}/${{ env.RELEASE_FILE }}.uf2

- name: "Artifacts: Upload .uf2 (With Filesystem)"
uses: actions/upload-artifact@v4
with:
name: ${{ env.RELEASE_FILE }}-with-filesystem.uf2
path: ${{ env.CI_BUILD_ROOT }}/${{ env.RELEASE_FILE }}-with-filesystem.uf2

- name: Store .uf2 as artifact
uses: actions/upload-artifact@v3
- name: "Release: Upload .uf2"
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
name: ${{env.RELEASE_FILE}}
path: micropython/ports/rp2/build-${{matrix.shortname}}/${{env.RELEASE_FILE}}
files: ${{ env.CI_BUILD_ROOT }}/${{ env.RELEASE_FILE }}.uf2

- name: Upload .uf2
- name: "Release: Upload .uf2 (With Filesystem)"
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
uses: softprops/action-gh-release@v1
with:
asset_path: micropython/ports/rp2/build-${{matrix.shortname}}/${{env.RELEASE_FILE}}
upload_url: ${{github.event.release.upload_url}}
asset_name: ${{env.RELEASE_FILE}}
asset_content_type: application/octet-stream
files: ${{ env.CI_BUILD_ROOT }}/${{ env.RELEASE_FILE }}-with-filesystem.uf2
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
# Cosmic Unicorn & Galactic Unicorn
# Pico-powered Unicorn
## Galactic, Cosmic, Stellar!

This repository is home to the MicroPython firmware and examples for
Galactic, Cosmic and Stellar Unicorn - our Pico-powered LED matrix boards.

## Download Firmware

There are two choices, a regular build that just updates the firmware on
your board and a "-with-examples" build which includes a ready-to-go set
of examples (everything in [examples/launcher](examples/launcher))
that you can interact with right on your display.

:warning: If you've changed any of the code on your board then back up before
flashing "-with-examples" - *your files will be erased!*

You can find the latest release at [https://github.com/pimoroni/unicorn/releases/latest](https://github.com/pimoroni/unicorn/releases/latest).

## Guides & Documentation

## Get Unicorn
14 changes: 14 additions & 0 deletions boards/manifest-common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# https://github.com/micropython/micropython-lib/blob/master/micropython/bundles/bundle-networking/manifest.py
require("bundle-networking")
require("urllib.urequest")
require("umqtt.simple")

# SD Card
require("sdcard")

# Bluetooth
require("aioble")

freeze("../../pimoroni-pico/micropython/modules_py", "pimoroni.py")
freeze("../../pimoroni-pico/micropython/modules_py", "boot.py")
freeze("../../pimoroni-pico/micropython/modules_py", "lte.py")
2 changes: 2 additions & 0 deletions boards/pico2_w_unicorn/manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include("$(PORT_DIR)/boards/manifest.py")
include("../manifest-common.py")
3 changes: 3 additions & 0 deletions boards/pico2_w_unicorn/manifest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.py
lib/*
lib/*/*
17 changes: 17 additions & 0 deletions boards/pico2_w_unicorn/mpconfigboard.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# cmake file for Pimoroni Inky with Raspberry Pi Pico W
set(MICROPY_BOARD RPI_PICO_W)
set(PICO_BOARD "pico2_w")

# The C malloc is needed by cyw43-driver Bluetooth and Pimoroni Pico modules
set(MICROPY_C_HEAP_SIZE 4096)

set(MICROPY_PY_LWIP ON)
set(MICROPY_PY_NETWORK_CYW43 ON)

# Bluetooth
set(MICROPY_PY_BLUETOOTH ON)
set(MICROPY_BLUETOOTH_BTSTACK ON)
set(MICROPY_PY_BLUETOOTH_CYW43 ON)

# Board specific version of the frozen manifest
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
14 changes: 14 additions & 0 deletions boards/pico2_w_unicorn/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Board and hardware specific configuration
#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico2 W (Unicorn)"

// Leave 50/50 split - 2MB firmware, 2MB user filesystem
#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - (2 * 1024 * 1024))

// Enable networking.
#define MICROPY_PY_NETWORK_PPP_LWIP (1)
#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "Unicorn2W"
#include "enable_cyw43.h"

// For debugging mbedtls - also set
// Debug level (0-4) 1=warning, 2=info, 3=debug, 4=verbose
// #define MODUSSL_MBEDTLS_DEBUG_LEVEL 1
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ GP28,GPIO28
WL_GPIO0,EXT_GPIO0
WL_GPIO1,EXT_GPIO1
WL_GPIO2,EXT_GPIO2
LED,EXT_GPIO0
LED,EXT_GPIO0
7 changes: 7 additions & 0 deletions boards/pico2_w_unicorn/usermodules.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../")

include(galactic_unicorn/micropython)
include(cosmic_unicorn/micropython)
include(stellar_unicorn/micropython)

include(usermod-common)
2 changes: 2 additions & 0 deletions boards/pico_w_unicorn/manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include("$(PORT_DIR)/boards/manifest.py")
include("../manifest-common.py")
3 changes: 3 additions & 0 deletions boards/pico_w_unicorn/manifest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.py
lib/*
lib/*/*
17 changes: 17 additions & 0 deletions boards/pico_w_unicorn/mpconfigboard.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# cmake file for Pimoroni Inky with Raspberry Pi Pico W
set(MICROPY_BOARD RPI_PICO_W)
set(PICO_BOARD "pico_w")

# The C malloc is needed by cyw43-driver Bluetooth and Pimoroni Pico modules
set(MICROPY_C_HEAP_SIZE 4096)

set(MICROPY_PY_LWIP ON)
set(MICROPY_PY_NETWORK_CYW43 ON)

# Bluetooth
set(MICROPY_PY_BLUETOOTH ON)
set(MICROPY_BLUETOOTH_BTSTACK ON)
set(MICROPY_PY_BLUETOOTH_CYW43 ON)

# Board specific version of the frozen manifest
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
14 changes: 14 additions & 0 deletions boards/pico_w_unicorn/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Board and hardware specific configuration
#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico W (Unicorn)"

// Leave 848k for user filesystem
#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - (1200 * 1024))

// Enable networking.
#define MICROPY_PY_NETWORK_PPP_LWIP (1)
#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "Unicorn"
#include "enable_cyw43.h"

// For debugging mbedtls - also set
// Debug level (0-4) 1=warning, 2=info, 3=debug, 4=verbose
// #define MODUSSL_MBEDTLS_DEBUG_LEVEL 1
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ GP28,GPIO28
WL_GPIO0,EXT_GPIO0
WL_GPIO1,EXT_GPIO1
WL_GPIO2,EXT_GPIO2
LED,EXT_GPIO0
LED,EXT_GPIO0
3 changes: 3 additions & 0 deletions boards/pico_w_unicorn/usermodules.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../")

include(usermod-common)
Loading

0 comments on commit 4c111cb

Please sign in to comment.