kopia lustrzana https://github.com/pimoroni/pimoroni-pico
Merge pull request #291 from pimoroni/experiment/multi-board-ci
Build MicroPython for multiple boardspull/292/head
commit
faa83986af
|
@ -18,7 +18,7 @@ jobs:
|
||||||
name: Linux
|
name: Linux
|
||||||
cache-key: linux
|
cache-key: linux
|
||||||
cmake-args: '-DPICO_SDK_PATH=$GITHUB_WORKSPACE/pico-sdk -DPICO_SDK_POST_LIST_DIRS=$GITHUB_WORKSPACE/pico-extras'
|
cmake-args: '-DPICO_SDK_PATH=$GITHUB_WORKSPACE/pico-sdk -DPICO_SDK_POST_LIST_DIRS=$GITHUB_WORKSPACE/pico-extras'
|
||||||
apt-packages: clang-tidy gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
|
apt-packages: ccache
|
||||||
|
|
||||||
runs-on: ${{matrix.os}}
|
runs-on: ${{matrix.os}}
|
||||||
|
|
||||||
|
@ -26,6 +26,15 @@ jobs:
|
||||||
PICO_SDK_PATH: $GITHUB_WORKSPACE/pico-sdk
|
PICO_SDK_PATH: $GITHUB_WORKSPACE/pico-sdk
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Compiler Cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: /home/runner/.ccache
|
||||||
|
key: ccache-cmake-${{github.ref}}-${{github.sha}}
|
||||||
|
restore-keys: |
|
||||||
|
ccache-cmake-${{github.ref}}
|
||||||
|
ccache-cmake
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
|
@ -44,7 +53,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
repository: raspberrypi/pico-extras
|
repository: raspberrypi/pico-extras
|
||||||
path: pico-extras
|
path: pico-extras
|
||||||
submodules: false # lwip breaks audio submodule fetchin
|
submodules: false # lwip breaks audio submodule fetching
|
||||||
|
|
||||||
# Linux deps
|
# Linux deps
|
||||||
- name: Install deps
|
- name: Install deps
|
||||||
|
@ -52,16 +61,27 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
sudo apt update && sudo apt install ${{matrix.apt-packages}}
|
sudo apt update && sudo apt install ${{matrix.apt-packages}}
|
||||||
|
|
||||||
|
- name: Install ARM Toolchain
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
working-directory: ${{runner.workspace}}
|
||||||
|
run: |
|
||||||
|
wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
|
||||||
|
tar xf gcc-*.tar.bz2
|
||||||
|
cd gcc*/bin
|
||||||
|
pwd >> $GITHUB_PATH
|
||||||
|
|
||||||
- name: Create Build Environment
|
- name: Create Build Environment
|
||||||
run: cmake -E make_directory ${{runner.workspace}}/build
|
run: cmake -E make_directory ${{runner.workspace}}/build
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
shell: bash
|
shell: bash
|
||||||
working-directory: ${{runner.workspace}}/build
|
working-directory: ${{runner.workspace}}/build
|
||||||
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE ${{matrix.cmake-args}}
|
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ${{matrix.cmake-args}}
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
working-directory: ${{runner.workspace}}/build
|
working-directory: ${{runner.workspace}}/build
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
ccache --zero-stats || true
|
||||||
cmake --build . --config $BUILD_TYPE -j 2
|
cmake --build . --config $BUILD_TYPE -j 2
|
||||||
|
ccache --show-stats || true
|
||||||
|
|
|
@ -7,28 +7,28 @@ on:
|
||||||
types: [created]
|
types: [created]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
|
||||||
MICROPYTHON_VERSION: v1.18
|
MICROPYTHON_VERSION: v1.18
|
||||||
BUILD_TYPE: Release
|
BOARD_TYPE: PICO
|
||||||
BOARD_TYPE: PICO
|
# MicroPython version will be contained in github.event.release.tag_name for releases
|
||||||
|
RELEASE_FILE: pimoroni-badger2040-${{github.event.release.tag_name || github.sha}}-micropython.uf2
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
deps:
|
||||||
name: ${{matrix.name}}
|
runs-on: ubuntu-20.04
|
||||||
strategy:
|
name: Dependencies
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- os: ubuntu-20.04
|
|
||||||
name: Linux
|
|
||||||
cache-key: linux
|
|
||||||
cmake-args: '-DPICO_SDK_PATH=$GITHUB_WORKSPACE/pico-sdk'
|
|
||||||
apt-packages: clang-tidy gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
|
|
||||||
|
|
||||||
runs-on: ${{matrix.os}}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Workspace Cache
|
||||||
|
id: cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{runner.workspace}}
|
||||||
|
key: workspace-micropython-${{env.MICROPYTHON_VERSION}}
|
||||||
|
restore-keys: |
|
||||||
|
workspace-micropython-${{env.MICROPYTHON_VERSION}}
|
||||||
|
|
||||||
# Check out MicroPython
|
# Check out MicroPython
|
||||||
- name: Checkout MicroPython
|
- name: Checkout MicroPython
|
||||||
|
if: steps.cache.outputs.cache-hit != 'true'
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
repository: micropython/micropython
|
repository: micropython/micropython
|
||||||
|
@ -36,6 +36,47 @@ jobs:
|
||||||
submodules: false # MicroPython submodules are hideously broken
|
submodules: false # MicroPython submodules are hideously broken
|
||||||
path: micropython
|
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 Badger 2040
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Compiler Cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: /home/runner/.ccache
|
||||||
|
key: ccache-micropython-badger2040-${{github.ref}}-${{github.sha}}
|
||||||
|
restore-keys: |
|
||||||
|
ccache-micropython-badger2040-${{github.ref}}
|
||||||
|
ccache-micropython-badger2040-
|
||||||
|
|
||||||
|
- name: Workspace Cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{runner.workspace}}
|
||||||
|
key: workspace-micropython-${{env.MICROPYTHON_VERSION}}
|
||||||
|
restore-keys: |
|
||||||
|
workspace-micropython-${{env.MICROPYTHON_VERSION}}
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
|
@ -43,48 +84,51 @@ jobs:
|
||||||
|
|
||||||
# Copy Python module files
|
# Copy Python module files
|
||||||
- name: HACK - Copy board config fixup
|
- name: HACK - Copy board config fixup
|
||||||
|
if: env.BOARD_TYPE == 'PICO'
|
||||||
run: |
|
run: |
|
||||||
cp pimoroni-pico-${GITHUB_SHA}/micropython/badger2040-mpconfigboard.h micropython/ports/rp2/boards/PICO/mpconfigboard.h
|
cp pimoroni-pico-${GITHUB_SHA}/micropython/badger2040-mpconfigboard.h micropython/ports/rp2/boards/PICO/mpconfigboard.h
|
||||||
|
|
||||||
# Linux deps
|
# Linux deps
|
||||||
- name: Install deps
|
- name: Install Compiler & CCache
|
||||||
if: runner.os == 'Linux'
|
if: runner.os == 'Linux'
|
||||||
run: |
|
run: |
|
||||||
sudo apt update && sudo apt install ${{matrix.apt-packages}}
|
sudo apt update && sudo apt install ccache
|
||||||
python3 -m pip install pillow
|
python3 -m pip install pillow
|
||||||
|
|
||||||
- name: Fetch base MicroPython submodules
|
- name: Install ARM Toolchain
|
||||||
shell: bash
|
if: runner.os == 'Linux'
|
||||||
working-directory: micropython
|
working-directory: ${{runner.workspace}}
|
||||||
run: git submodule update --init
|
run: |
|
||||||
|
wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
|
||||||
|
tar xf gcc-*.tar.bz2
|
||||||
|
cd gcc*/bin
|
||||||
|
pwd >> $GITHUB_PATH
|
||||||
|
|
||||||
- name: Fetch Pico SDK submodules
|
- name: Configure MicroPython
|
||||||
shell: bash
|
shell: bash
|
||||||
working-directory: micropython/lib/pico-sdk
|
working-directory: micropython/ports/rp2
|
||||||
run: git submodule update --init
|
run: |
|
||||||
|
cmake -S . -B build-${{env.BOARD_TYPE}} -DPICO_BUILD_DOCS=0 -DUSER_C_MODULES=../../../pimoroni-pico-${GITHUB_SHA}/micropython/modules/badger2040-micropython.cmake -DMICROPY_BOARD=${{env.BOARD_TYPE}} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||||
- name: Build mpy-cross
|
|
||||||
shell: bash
|
|
||||||
working-directory: micropython/mpy-cross
|
|
||||||
run: make
|
|
||||||
|
|
||||||
- name: Build MicroPython
|
- name: Build MicroPython
|
||||||
shell: bash
|
shell: bash
|
||||||
working-directory: micropython/ports/rp2
|
working-directory: micropython/ports/rp2
|
||||||
run: make USER_C_MODULES=../../../pimoroni-pico-${GITHUB_SHA}/micropython/modules/badger2040-micropython.cmake -j2
|
run: |
|
||||||
|
ccache --zero-stats || true
|
||||||
|
cmake --build build-${{env.BOARD_TYPE}} -j 2
|
||||||
|
ccache --show-stats || true
|
||||||
|
|
||||||
- name: Rename .uf2 for artifact
|
- name: Rename .uf2 for artifact
|
||||||
shell: bash
|
shell: bash
|
||||||
working-directory: micropython/ports/rp2/build-${{env.BOARD_TYPE}}
|
working-directory: micropython/ports/rp2/build-${{env.BOARD_TYPE}}
|
||||||
run: |
|
run: |
|
||||||
cp firmware.uf2 ${{github.event.repository.name}}-${{github.sha}}-badger2040-micropython-${{env.MICROPYTHON_VERSION}}.uf2
|
cp firmware.uf2 ${{env.RELEASE_FILE}}
|
||||||
cp firmware.uf2 ${{github.event.repository.name}}-${{github.event.release.tag_name}}-badger2040-micropython-${{env.MICROPYTHON_VERSION}}.uf2
|
|
||||||
|
|
||||||
- name: Store .uf2 as artifact
|
- name: Store .uf2 as artifact
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: ${{github.event.repository.name}}-${{github.sha}}-badger2040-micropython-${{env.MICROPYTHON_VERSION}}.uf2
|
name: ${{env.RELEASE_FILE}}
|
||||||
path: micropython/ports/rp2/build-${{env.BOARD_TYPE}}/${{github.event.repository.name}}-${{github.sha}}-badger2040-micropython-${{env.MICROPYTHON_VERSION}}.uf2
|
path: micropython/ports/rp2/build-${{env.BOARD_TYPE}}/${{env.RELEASE_FILE}}
|
||||||
|
|
||||||
- name: Upload .uf2
|
- name: Upload .uf2
|
||||||
if: github.event_name == 'release'
|
if: github.event_name == 'release'
|
||||||
|
@ -94,5 +138,5 @@ jobs:
|
||||||
with:
|
with:
|
||||||
asset_path: micropython/ports/rp2/build-${{env.BOARD_TYPE}}/firmware.uf2
|
asset_path: micropython/ports/rp2/build-${{env.BOARD_TYPE}}/firmware.uf2
|
||||||
upload_url: ${{github.event.release.upload_url}}
|
upload_url: ${{github.event.release.upload_url}}
|
||||||
asset_name: ${{github.event.repository.name}}-${{github.event.release.tag_name}}-badger2040-micropython-${{env.MICROPYTHON_VERSION}}.uf2
|
asset_name: ${{env.RELEASE_FILE}}
|
||||||
asset_content_type: application/octet-stream
|
asset_content_type: application/octet-stream
|
||||||
|
|
|
@ -24,7 +24,7 @@ jobs:
|
||||||
name: Linux
|
name: Linux
|
||||||
cache-key: linux
|
cache-key: linux
|
||||||
cmake-args: '-DPICO_SDK_PATH=$GITHUB_WORKSPACE/pico-sdk'
|
cmake-args: '-DPICO_SDK_PATH=$GITHUB_WORKSPACE/pico-sdk'
|
||||||
apt-packages: clang-tidy gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
|
apt-packages: ccache
|
||||||
|
|
||||||
runs-on: ${{matrix.os}}
|
runs-on: ${{matrix.os}}
|
||||||
|
|
||||||
|
@ -82,6 +82,15 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
sudo apt update && sudo apt install ${{matrix.apt-packages}}
|
sudo apt update && sudo apt install ${{matrix.apt-packages}}
|
||||||
|
|
||||||
|
- name: Install ARM Toolchain
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
working-directory: ${{runner.workspace}}
|
||||||
|
run: |
|
||||||
|
wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
|
||||||
|
tar xf gcc-*.tar.bz2
|
||||||
|
cd gcc*/bin
|
||||||
|
pwd >> $GITHUB_PATH
|
||||||
|
|
||||||
- name: Fetch base MicroPython submodules
|
- name: Fetch base MicroPython submodules
|
||||||
shell: bash
|
shell: bash
|
||||||
working-directory: micropython
|
working-directory: micropython
|
||||||
|
|
|
@ -7,28 +7,25 @@ on:
|
||||||
types: [created]
|
types: [created]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
|
||||||
MICROPYTHON_VERSION: v1.18
|
MICROPYTHON_VERSION: v1.18
|
||||||
BUILD_TYPE: Release
|
|
||||||
BOARD_TYPE: PICO
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
deps:
|
||||||
name: ${{matrix.name}}
|
runs-on: ubuntu-20.04
|
||||||
strategy:
|
name: Dependencies
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- os: ubuntu-20.04
|
|
||||||
name: Linux
|
|
||||||
cache-key: linux
|
|
||||||
cmake-args: '-DPICO_SDK_PATH=$GITHUB_WORKSPACE/pico-sdk'
|
|
||||||
apt-packages: clang-tidy gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
|
|
||||||
|
|
||||||
runs-on: ${{matrix.os}}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Workspace Cache
|
||||||
|
id: cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{runner.workspace}}
|
||||||
|
key: workspace-micropython-${{env.MICROPYTHON_VERSION}}
|
||||||
|
restore-keys: |
|
||||||
|
workspace-micropython-${{env.MICROPYTHON_VERSION}}
|
||||||
|
|
||||||
# Check out MicroPython
|
# Check out MicroPython
|
||||||
- name: Checkout MicroPython
|
- name: Checkout MicroPython
|
||||||
|
if: steps.cache.outputs.cache-hit != 'true'
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
repository: micropython/micropython
|
repository: micropython/micropython
|
||||||
|
@ -36,52 +33,105 @@ jobs:
|
||||||
submodules: false # MicroPython submodules are hideously broken
|
submodules: false # MicroPython submodules are hideously broken
|
||||||
path: micropython
|
path: micropython
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: true
|
|
||||||
path: pimoroni-pico-${{ github.sha }}
|
|
||||||
|
|
||||||
# Copy Python module files
|
|
||||||
- name: Copy modules
|
|
||||||
run: |
|
|
||||||
cp -r pimoroni-pico-${GITHUB_SHA}/micropython/modules_py/* micropython/ports/rp2/modules/
|
|
||||||
|
|
||||||
# Linux deps
|
|
||||||
- name: Install deps
|
|
||||||
if: runner.os == 'Linux'
|
|
||||||
run: |
|
|
||||||
sudo apt update && sudo apt install ${{matrix.apt-packages}}
|
|
||||||
|
|
||||||
- name: Fetch base MicroPython submodules
|
- name: Fetch base MicroPython submodules
|
||||||
|
if: steps.cache.outputs.cache-hit != 'true'
|
||||||
shell: bash
|
shell: bash
|
||||||
working-directory: micropython
|
working-directory: micropython
|
||||||
run: git submodule update --init
|
run: git submodule update --init
|
||||||
|
|
||||||
- name: Fetch Pico SDK submodules
|
- name: Fetch Pico SDK submodules
|
||||||
|
if: steps.cache.outputs.cache-hit != 'true'
|
||||||
shell: bash
|
shell: bash
|
||||||
working-directory: micropython/lib/pico-sdk
|
working-directory: micropython/lib/pico-sdk
|
||||||
run: git submodule update --init
|
run: git submodule update --init
|
||||||
|
|
||||||
- name: Build mpy-cross
|
- name: Build mpy-cross
|
||||||
|
if: steps.cache.outputs.cache-hit != 'true'
|
||||||
shell: bash
|
shell: bash
|
||||||
working-directory: micropython/mpy-cross
|
working-directory: micropython/mpy-cross
|
||||||
run: make
|
run: make
|
||||||
|
|
||||||
|
build:
|
||||||
|
needs: deps
|
||||||
|
name: Build ${{matrix.board}}
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- name: pico
|
||||||
|
board: PICO
|
||||||
|
- name: tiny2040
|
||||||
|
board: PIMORONI_TINY2040
|
||||||
|
- name: picolipo_4mb
|
||||||
|
board: PIMORONI_PICOLIPO_4MB
|
||||||
|
- name: picolipo_16mb
|
||||||
|
board: PIMORONI_PICOLIPO_16MB
|
||||||
|
|
||||||
|
env:
|
||||||
|
# MicroPython version will be contained in github.event.release.tag_name for releases
|
||||||
|
RELEASE_FILE: pimoroni-${{matrix.name}}-${{github.event.release.tag_name || github.sha}}-micropython.uf2
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Compiler Cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: /home/runner/.ccache
|
||||||
|
key: ccache-micropython-${{matrix.name}}-${{github.ref}}-${{github.sha}}
|
||||||
|
restore-keys: |
|
||||||
|
ccache-micropython-${{matrix.name}}-${{github.ref}}
|
||||||
|
ccache-micropython-${{matrix.name}}-
|
||||||
|
|
||||||
|
- name: Workspace Cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{runner.workspace}}
|
||||||
|
key: workspace-micropython-${{env.MICROPYTHON_VERSION}}
|
||||||
|
restore-keys: |
|
||||||
|
workspace-micropython-${{env.MICROPYTHON_VERSION}}
|
||||||
|
|
||||||
|
- name: Install Compiler & CCache
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
run: |
|
||||||
|
sudo apt update && sudo apt install ccache
|
||||||
|
|
||||||
|
- name: Install ARM Toolchain
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
working-directory: ${{runner.workspace}}
|
||||||
|
run: |
|
||||||
|
wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
|
||||||
|
tar xf gcc-*.tar.bz2
|
||||||
|
cd gcc*/bin
|
||||||
|
pwd >> $GITHUB_PATH
|
||||||
|
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
path: pimoroni-pico-${{ github.sha }}
|
||||||
|
|
||||||
|
- name: Configure MicroPython
|
||||||
|
shell: bash
|
||||||
|
working-directory: micropython/ports/rp2
|
||||||
|
run: |
|
||||||
|
cmake -S . -B build-${{matrix.board}} -DPICO_BUILD_DOCS=0 -DUSER_C_MODULES=../../../pimoroni-pico-${GITHUB_SHA}/micropython/modules/micropython.cmake -DMICROPY_BOARD=${{matrix.board}} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||||
|
|
||||||
- name: Build MicroPython
|
- name: Build MicroPython
|
||||||
shell: bash
|
shell: bash
|
||||||
working-directory: micropython/ports/rp2
|
working-directory: micropython/ports/rp2
|
||||||
run: make USER_C_MODULES=../../../pimoroni-pico-${GITHUB_SHA}/micropython/modules/micropython.cmake -j2
|
run: |
|
||||||
|
ccache --zero-stats || true
|
||||||
|
cmake --build build-${{matrix.board}} -j 2
|
||||||
|
ccache --show-stats || true
|
||||||
|
|
||||||
- name: Rename .uf2 for artifact
|
- name: Rename .uf2 for artifact
|
||||||
shell: bash
|
shell: bash
|
||||||
working-directory: micropython/ports/rp2/build-${{env.BOARD_TYPE}}
|
working-directory: micropython/ports/rp2/build-${{matrix.board}}
|
||||||
run: cp firmware.uf2 ${{github.event.repository.name}}-${{github.event.release.tag_name}}-micropython-${{env.MICROPYTHON_VERSION}}.uf2
|
run: cp firmware.uf2 $RELEASE_FILE
|
||||||
|
|
||||||
- name: Store .uf2 as artifact
|
- name: Store .uf2 as artifact
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: ${{github.event.repository.name}}-${{github.event.release.tag_name}}-micropython-${{env.MICROPYTHON_VERSION}}.uf2
|
name: ${{env.RELEASE_FILE}}
|
||||||
path: micropython/ports/rp2/build-${{env.BOARD_TYPE}}/${{github.event.repository.name}}-${{github.event.release.tag_name}}-micropython-${{env.MICROPYTHON_VERSION}}.uf2
|
path: micropython/ports/rp2/build-${{matrix.board}}/${{env.RELEASE_FILE}}
|
||||||
|
|
||||||
- name: Upload .uf2
|
- name: Upload .uf2
|
||||||
if: github.event_name == 'release'
|
if: github.event_name == 'release'
|
||||||
|
@ -89,7 +139,7 @@ jobs:
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||||
with:
|
with:
|
||||||
asset_path: micropython/ports/rp2/build-${{env.BOARD_TYPE}}/firmware.uf2
|
asset_path: micropython/ports/rp2/build-${{matrix.board}}/firmware.uf2
|
||||||
upload_url: ${{github.event.release.upload_url}}
|
upload_url: ${{github.event.release.upload_url}}
|
||||||
asset_name: ${{github.event.repository.name}}-${{github.event.release.tag_name}}-micropython-${{env.MICROPYTHON_VERSION}}.uf2
|
asset_name: ${{env.RELEASE_FILE}}
|
||||||
asset_content_type: application/octet-stream
|
asset_content_type: application/octet-stream
|
||||||
|
|
|
@ -6,30 +6,25 @@ on:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: ${{matrix.name}}
|
name: Python Linting
|
||||||
strategy:
|
runs-on: ubuntu-20.04
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- os: ubuntu-20.04
|
|
||||||
name: Linux
|
|
||||||
cache-key: linux
|
|
||||||
apt-packages: python3 python3-pip
|
|
||||||
python-packages: flake8
|
|
||||||
|
|
||||||
runs-on: ${{matrix.os}}
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
# Linux deps
|
|
||||||
- name: Install deps
|
|
||||||
if: runner.os == 'Linux'
|
|
||||||
run: |
|
|
||||||
sudo apt update && sudo apt install ${{matrix.apt-packages}}
|
|
||||||
|
|
||||||
- name: Install Python Deps
|
- name: Install Python Deps
|
||||||
run: python3 -m pip install ${{matrix.python-packages}}
|
run: python3 -m pip install flake8
|
||||||
|
|
||||||
- name: Lint
|
- name: Lint micropython/modules_py
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
python3 -m flake8 --ignore E501 micropython/modules_py micropython/examples
|
python3 -m flake8 --ignore E501 micropython/modules_py
|
||||||
|
|
||||||
|
- name: Lint micropython/examples
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
python3 -m flake8 --ignore E501 micropython/examples
|
||||||
|
|
||||||
|
- name: Lint .py tools in C++ examples
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
python3 -m flake8 --ignore E501 examples
|
|
@ -3,156 +3,157 @@
|
||||||
# converts Hershey fonts into a format easier to consume by the Badger2040
|
# converts Hershey fonts into a format easier to consume by the Badger2040
|
||||||
# e-ink badge library - the result can be piped directly into a .hpp file.
|
# e-ink badge library - the result can be piped directly into a .hpp file.
|
||||||
|
|
||||||
import argparse, sys, os, glob
|
import argparse
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='Converts Hershey fonts into the format used by Badger2040.')
|
description="Converts Hershey fonts into the format used by Badger2040."
|
||||||
parser.add_argument('file', nargs="+", help='input files to convert')
|
)
|
||||||
|
parser.add_argument("file", nargs="+", help="input files to convert")
|
||||||
|
|
||||||
|
options = parser.parse_args()
|
||||||
|
|
||||||
options = None
|
|
||||||
try:
|
|
||||||
options = parser.parse_args()
|
|
||||||
except:
|
|
||||||
parser.print_help()
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
def convert_font(data):
|
def convert_font(data):
|
||||||
# parse hershey font data file, the file format contains one record per
|
# parse hershey font data file, the file format contains one record per
|
||||||
# character with the format:
|
# character with the format:
|
||||||
#
|
#
|
||||||
# 2761 8MXP[OZPYQZQ[P]N_
|
# 2761 8MXP[OZPYQZQ[P]N_
|
||||||
#
|
#
|
||||||
# first 5 characters: represent the character id (or a dummy value
|
# first 5 characters: represent the character id (or a dummy value
|
||||||
# of 12345). if it is a character id then a separate file contains the
|
# of 12345). if it is a character id then a separate file contains the
|
||||||
# mapping information to convert that into an ascii table entry. if all of
|
# mapping information to convert that into an ascii table entry. if all of
|
||||||
# the ids are 12345 then it seems that the files contain 95 entries that
|
# the ids are 12345 then it seems that the files contain 95 entries that
|
||||||
# start from ascii character 32 (space) in order
|
# start from ascii character 32 (space) in order
|
||||||
#
|
#
|
||||||
# next 3 characters: number of vertices (including special left/right
|
# next 3 characters: number of vertices (including special left/right
|
||||||
# bounds value)
|
# bounds value)
|
||||||
#
|
#
|
||||||
# next 2 characters: represent the "left" and "right" offsets for this
|
# next 2 characters: represent the "left" and "right" offsets for this
|
||||||
# character, to convert you must subtract 'R' from them. this pair counts
|
# character, to convert you must subtract 'R' from them. this pair counts
|
||||||
# as the first "vertex"
|
# as the first "vertex"
|
||||||
#
|
#
|
||||||
# subsequent pairs of characters: represent each vertex, as before converted
|
# subsequent pairs of characters: represent each vertex, as before converted
|
||||||
# into numbers by subtracting 'R'. there are vertex count (-1) of these
|
# into numbers by subtracting 'R'. there are vertex count (-1) of these
|
||||||
#
|
#
|
||||||
# note! within the vertex data can be extra newline characters which must
|
# note! within the vertex data can be extra newline characters which must
|
||||||
# be ignored.
|
# be ignored.
|
||||||
|
|
||||||
vertex_data = []
|
vertex_data = []
|
||||||
char_data = {}
|
char_data = {}
|
||||||
|
|
||||||
auto_char_code = 0
|
auto_char_code = 0
|
||||||
|
|
||||||
# we'll loop, extracting one character per iteration, until all of the
|
# we'll loop, extracting one character per iteration, until all of the
|
||||||
# data is consumed
|
# data is consumed
|
||||||
while(len(data) > 0):
|
while len(data) > 0:
|
||||||
# extract character id
|
char_code = auto_char_code
|
||||||
char_id = int(data[0:5])
|
auto_char_code += 1
|
||||||
|
|
||||||
char_code = auto_char_code
|
# extract vertex count
|
||||||
auto_char_code += 1
|
vertex_count = int(data[5:8])
|
||||||
|
vertex_count -= 1 # remove one for the bounds data
|
||||||
|
|
||||||
# extract vertex count
|
# extract bounds
|
||||||
vertex_count = int(data[5:8])
|
left = ord(data[8:9]) - ord("R")
|
||||||
vertex_count -= 1 # remove one for the bounds data
|
right = ord(data[9:10]) - ord("R")
|
||||||
|
|
||||||
# extract bounds
|
char_data[char_code] = {
|
||||||
left = ord(data[8:9]) - ord("R")
|
"width": right - left,
|
||||||
right = ord(data[9:10]) - ord("R")
|
"vertex_count": vertex_count,
|
||||||
|
"first_vertex_offset": len(vertex_data),
|
||||||
|
}
|
||||||
|
|
||||||
char_data[char_code] = {
|
# work out expected total length of character data
|
||||||
"width": right - left,
|
char_data_len = 10 + (vertex_count * 2)
|
||||||
"vertex_count": vertex_count,
|
|
||||||
"first_vertex_offset": len(vertex_data)
|
|
||||||
}
|
|
||||||
|
|
||||||
# work out expected total length of character data
|
# if there are any newlines within this data then remove them before we
|
||||||
char_data_len = 10 + (vertex_count * 2)
|
# move on the parse the vertices
|
||||||
|
while data.find("\n", char_data_len) != -1:
|
||||||
|
data = data.replace("\n", "", 1)
|
||||||
|
|
||||||
# if there are any newlines within this data then remove them before we
|
for i in range(0, vertex_count):
|
||||||
# move on the parse the vertices
|
offset = 10 + (i * 2)
|
||||||
while data.find('\n', char_data_len) != -1:
|
if data[offset:offset + 2] == " R":
|
||||||
data = data.replace('\n', '', 1)
|
# pen up for one
|
||||||
|
x = -128
|
||||||
|
y = -128
|
||||||
|
else:
|
||||||
|
x = ord(data[offset + 0:offset + 1]) - ord("R") - left
|
||||||
|
y = ord(data[offset + 1:offset + 2]) - ord("R")
|
||||||
|
|
||||||
for i in range(0, vertex_count):
|
vertex_data.append(str(x))
|
||||||
offset = 10 + (i * 2)
|
vertex_data.append(str(y))
|
||||||
if data[offset:offset + 2] == " R":
|
|
||||||
# pen up for one
|
|
||||||
x = -128
|
|
||||||
y = -128
|
|
||||||
else:
|
|
||||||
x = ord(data[offset + 0:offset + 1]) - ord("R") - left
|
|
||||||
y = ord(data[offset + 1:offset + 2]) - ord("R")
|
|
||||||
|
|
||||||
vertex_data.append(str(x))
|
data = data[char_data_len:]
|
||||||
vertex_data.append(str(y))
|
|
||||||
|
|
||||||
data = data[char_data_len:]
|
font_name = Path(input_filename).stem
|
||||||
|
|
||||||
font_name = Path(input_filename).stem
|
# create code for all of the vertices
|
||||||
|
vertex_code = """\
|
||||||
# create code for all of the vertices
|
|
||||||
vertex_code = '''\
|
|
||||||
static const int8_t {font_name}_vertices[{count}] = {{
|
static const int8_t {font_name}_vertices[{count}] = {{
|
||||||
{vertices}
|
{vertices}
|
||||||
}};
|
}};
|
||||||
'''.format(font_name=font_name, count=len(vertex_data), vertices=", ".join(vertex_data))
|
""".format(
|
||||||
|
font_name=font_name, count=len(vertex_data), vertices=", ".join(vertex_data)
|
||||||
|
)
|
||||||
|
|
||||||
# create code for chars and font
|
# create code for chars and font
|
||||||
#
|
#
|
||||||
# struct hershey_font_glyph_t {
|
# struct hershey_font_glyph_t {
|
||||||
# uint32_t width; // character width
|
# uint32_t width; // character width
|
||||||
# uint32_t vertex_count; // number of vertices
|
# uint32_t vertex_count; // number of vertices
|
||||||
# int8_t *vertices; // vertex data (indices: even = x, odd = y)
|
# int8_t *vertices; // vertex data (indices: even = x, odd = y)
|
||||||
# };
|
# };
|
||||||
chars = []
|
chars = []
|
||||||
for i in range(0, 95):
|
for i in range(0, 95):
|
||||||
if i in char_data:
|
if i in char_data:
|
||||||
chars.append(
|
chars.append(
|
||||||
" {{.width={width}, .vertex_count={vertex_count}, .vertices=&{font_name}_vertices[{offset}]}}".format(
|
" {{.width={width}, .vertex_count={vertex_count}, .vertices=&{font_name}_vertices[{offset}]}}".format(
|
||||||
width=char_data[i]["width"],
|
width=char_data[i]["width"],
|
||||||
vertex_count=char_data[i]["vertex_count"],
|
vertex_count=char_data[i]["vertex_count"],
|
||||||
font_name=font_name,
|
font_name=font_name,
|
||||||
offset=char_data[i]["first_vertex_offset"]
|
offset=char_data[i]["first_vertex_offset"],
|
||||||
))
|
)
|
||||||
else:
|
)
|
||||||
chars.append(" {.width=0, .vertex_count=0, .vertices=nullptr}")
|
else:
|
||||||
|
chars.append(" {.width=0, .vertex_count=0, .vertices=nullptr}")
|
||||||
|
|
||||||
# struct hershey_font_t {
|
# struct hershey_font_t {
|
||||||
# hershey_font_glyph_t chars[95];
|
# hershey_font_glyph_t chars[95];
|
||||||
# };
|
# };
|
||||||
font_code = '''\
|
font_code = """\
|
||||||
static const hershey_font_t {font_name} {{
|
static const hershey_font_t {font_name} {{
|
||||||
.chars = {{
|
.chars = {{
|
||||||
{chars}
|
{chars}
|
||||||
}}
|
}}
|
||||||
}};
|
}};
|
||||||
'''.format(font_name=font_name, chars=",\n".join(chars))
|
""".format(
|
||||||
|
font_name=font_name, chars=",\n".join(chars)
|
||||||
|
)
|
||||||
|
|
||||||
print(vertex_code)
|
print(vertex_code)
|
||||||
|
|
||||||
print(font_code)
|
print(font_code)
|
||||||
|
|
||||||
return """ {{ \"{font_name}\", &{font_name} }}""".format(font_name=font_name)
|
return """ {{ \"{font_name}\", &{font_name} }}""".format(font_name=font_name)
|
||||||
|
|
||||||
|
|
||||||
# create map of font name to font structure
|
# create map of font name to font structure
|
||||||
font_list = []
|
font_list = []
|
||||||
for input_filename in options.file:
|
for input_filename in options.file:
|
||||||
input_file = open(input_filename, mode='r')
|
input_file = open(input_filename, mode="r")
|
||||||
data = input_file.read()
|
data = input_file.read()
|
||||||
input_file.close()
|
input_file.close()
|
||||||
|
|
||||||
font_list.append(convert_font(data))
|
font_list.append(convert_font(data))
|
||||||
|
|
||||||
map_code = '''\
|
map_code = """\
|
||||||
std::map<std::string, const hershey_font_t*> fonts = {{
|
std::map<std::string, const hershey_font_t*> fonts = {{
|
||||||
{font_list}
|
{font_list}
|
||||||
}};
|
}};
|
||||||
'''.format(font_list=",\n".join(font_list))
|
""".format(
|
||||||
|
font_list=",\n".join(font_list)
|
||||||
|
)
|
||||||
|
|
||||||
print(map_code)
|
print(map_code)
|
||||||
|
|
|
@ -85,9 +85,10 @@ STR02 = """_mvdata = memoryview(_data)
|
||||||
|
|
||||||
def data():
|
def data():
|
||||||
return _mvdata
|
return _mvdata
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def write_func(stream, name, arg):
|
def write_func(stream, name, arg):
|
||||||
stream.write('def {}():\n return {}\n\n'.format(name, arg))
|
stream.write('def {}():\n return {}\n\n'.format(name, arg))
|
||||||
|
|
||||||
|
@ -123,6 +124,7 @@ def quit(msg):
|
||||||
print(msg)
|
print(msg)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
DESC = """data_to_py.py
|
DESC = """data_to_py.py
|
||||||
Utility to convert an arbitrary binary file to Python source.
|
Utility to convert an arbitrary binary file to Python source.
|
||||||
Sample usage:
|
Sample usage:
|
||||||
|
@ -137,7 +139,6 @@ if __name__ == "__main__":
|
||||||
parser.add_argument('outfile', type=str,
|
parser.add_argument('outfile', type=str,
|
||||||
help='Path and name of output file. Must have .py extension.')
|
help='Path and name of output file. Must have .py extension.')
|
||||||
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if not os.path.isfile(args.infile):
|
if not os.path.isfile(args.infile):
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/../../)
|
include_directories(${CMAKE_CURRENT_LIST_DIR}/../../)
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../")
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../../")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../../")
|
||||||
|
|
||||||
include(pimoroni_i2c/micropython)
|
include(pimoroni_i2c/micropython)
|
||||||
|
@ -41,3 +42,5 @@ include(pico_wireless/micropython)
|
||||||
include(plasma/micropython)
|
include(plasma/micropython)
|
||||||
include(hub75/micropython)
|
include(hub75/micropython)
|
||||||
include(ulab/code/micropython)
|
include(ulab/code/micropython)
|
||||||
|
|
||||||
|
include(modules_py/modules_py)
|
|
@ -0,0 +1,20 @@
|
||||||
|
function (copy_module TARGET SRC DST)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/../modules/${DST}.py
|
||||||
|
|
||||||
|
COMMAND
|
||||||
|
cp ${SRC} ${CMAKE_CURRENT_BINARY_DIR}/../modules/${DST}.py
|
||||||
|
|
||||||
|
DEPENDS ${src}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_sources(${TARGET} INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/../modules/${DST}.py)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Create a dummy usermod to hang our .py copies from
|
||||||
|
add_library(usermod_modules_py INTERFACE)
|
||||||
|
target_link_libraries(usermod INTERFACE usermod_modules_py)
|
||||||
|
|
||||||
|
# .py files to copy from modules_py to ports/rp2/modules
|
||||||
|
copy_module(usermod_modules_py ${CMAKE_CURRENT_LIST_DIR}/picosystem.py picosystem)
|
||||||
|
copy_module(usermod_modules_py ${CMAKE_CURRENT_LIST_DIR}/pimoroni.py pimoroni)
|
Ładowanie…
Reference in New Issue