generated from pimoroni/pga
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ff987d3
Showing
26 changed files
with
814 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
name: MicroPython | ||
|
||
on: | ||
push: | ||
pull_request: | ||
release: | ||
types: [created] | ||
|
||
env: | ||
MICROPYTHON_VERSION: feature/psram | ||
MICROPYTHON_FLAVOUR: pimoroni | ||
PIMORONI_PICO_VERSION: feature/sdk-2.0.0 | ||
|
||
jobs: | ||
build: | ||
name: ${{ matrix.name }} (${{ matrix.board }} ${{ matrix.variant }} ${{ matrix.modules }}) | ||
runs-on: ubuntu-20.04 | ||
continue-on-error: true | ||
strategy: | ||
matrix: | ||
include: | ||
- name: pga2040 | ||
board: pga2040 | ||
modules: default | ||
- name: pga2350 | ||
board: pga2350 | ||
modules: default | ||
- name: pga2350-psram # Friendly-name for output files | ||
board: pga2350 # /<board> | ||
variant: PSRAM # /<board>/mpconfigvariant_<variant>.cmake | ||
modules: default # /modules/<modules>.cmake | ||
|
||
env: | ||
# 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" | ||
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 | ||
|
||
steps: | ||
- name: "CCache: Restore saved cache" | ||
uses: actions/cache@v4 | ||
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: "Src: Checkout" | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
path: src-${{ github.sha }} | ||
|
||
- name: "Pimoroni Pico: Checkout" | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: pimoroni/pimoroni-pico | ||
ref: ${{env.PIMORONI_PICO_VERSION}} | ||
submodules: true | ||
path: pimoroni-pico | ||
|
||
- name: Install Arm GNU Toolchain (arm-none-eabi-gcc) | ||
uses: carlosperate/arm-none-eabi-gcc-action@v1 | ||
with: | ||
release: '9-2020-q2' | ||
|
||
- name: "CCache: Install" | ||
run: | | ||
source $BUILD_TOOLS | ||
apt_install_build_deps | ||
- name: "MicroPython: Checkout" | ||
run: | | ||
source $BUILD_TOOLS | ||
micropython_clone | ||
- 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: | | ||
source $BUILD_TOOLS | ||
micropython_build_mpy_cross | ||
- name: "MicroPython: Configure" | ||
shell: bash | ||
run: | | ||
source $BUILD_TOOLS | ||
micropython_version | ||
cmake_configure | ||
- name: "MicroPython: Build" | ||
shell: bash | ||
run: | | ||
source $BUILD_TOOLS | ||
cmake_build | ||
- name: "Py_Decl: Verify .uf2" | ||
shell: bash | ||
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: "Artifacts: Upload .uf2" | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.RELEASE_FILE }}.uf2 | ||
path: build-${{ matrix.name }}/${{ 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.RELEASE_FILE }}-with-filesystem.uf2 | ||
|
||
- name: "Release: Upload .uf2" | ||
if: github.event_name == 'release' | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
asset_path: build-${{ matrix.name }}/${{ env.RELEASE_FILE }}.uf2 | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_name: ${{ env.RELEASE_FILE }}.uf2 | ||
asset_content_type: application/octet-stream | ||
|
||
- name: "Release: Upload .uf2 with filesystem" | ||
if: github.event_name == 'release' | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
asset_path: ${{ env.RELEASE_FILE }}-with-filesystem.uf2 | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_name: ${{ env.RELEASE_FILE }}-with-filesystem.uf2 | ||
asset_content_type: application/octet-stream |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Prerequisites | ||
*.d | ||
|
||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
*.obj | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
*.dylib | ||
*.dll | ||
|
||
# Fortran module files | ||
*.mod | ||
*.smod | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
*.lib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
|
||
**/build | ||
.vscode | ||
|
||
# Apple filesystem cruft | ||
.DS_Store | ||
venv |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Pimoroni PGA Boilerplate | ||
|
||
This repository is intended to provide a baseline MicroPython build for PGA2040 | ||
and PGA2350, in addition to being a minimal example of how you might set up your | ||
own custom MicroPython flavour to support your PGA-based project. | ||
|
||
Use this repository as a boilerplate to set up your own project, and GitHub actions | ||
should automatically handle building MicroPython for you. | ||
|
||
## Contents | ||
|
||
* pga2040 - MicroPython and Pico SDK board definitions for PGA2040 | ||
* 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 | ||
* 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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
export TERM=${TERM:="xterm-256color"} | ||
|
||
function log_success { | ||
echo -e "$(tput setaf 2)$1$(tput sgr0)" | ||
} | ||
|
||
function log_inform { | ||
echo -e "$(tput setaf 6)$1$(tput sgr0)" | ||
} | ||
|
||
function log_warning { | ||
echo -e "$(tput setaf 1)$1$(tput sgr0)" | ||
} | ||
|
||
function micropython_clone { | ||
log_inform "Using MicroPython $MICROPYTHON_VERSION" | ||
git clone https://github.com/$MICROPYTHON_FLAVOUR/micropython | ||
cd micropython | ||
git checkout $MICROPYTHON_VERSION | ||
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 | ||
cd ../ | ||
} | ||
|
||
function micropython_build_mpy_cross { | ||
cd micropython/mpy-cross | ||
ccache --zero-stats || true | ||
CROSS_COMPILE="ccache " make | ||
ccache --show-stats || true | ||
cd ../../ | ||
} | ||
|
||
function apt_install_build_deps { | ||
sudo apt update && sudo apt install ccache | ||
} | ||
|
||
function micropython_version { | ||
echo "MICROPY_GIT_TAG=$MICROPYTHON_VERSION, $BOARD_NAME $TAG_OR_SHA" >> $GITHUB_ENV | ||
echo "MICROPY_GIT_HASH=$MICROPYTHON_VERSION-$TAG_OR_SHA" >> $GITHUB_ENV | ||
} | ||
|
||
function cmake_configure { | ||
cmake -S micropython/ports/rp2 -B build-$BOARD_NAME \ | ||
-DPICO_BUILD_DOCS=0 \ | ||
-DPICO_NO_COPRO_DIS=1 \ | ||
-DUSER_C_MODULES=$USER_C_MODULES \ | ||
-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 | ||
} | ||
|
||
function cmake_build { | ||
ccache --zero-stats || true | ||
cmake --build build-$BOARD_NAME -j 2 | ||
ccache --show-stats || true | ||
cd build-$BOARD_NAME | ||
cp firmware.uf2 $RELEASE_FILE.uf2 | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <example.h> | ||
|
||
MP_DEFINE_CONST_FUN_OBJ_1(example__del__obj, example__del__); | ||
|
||
MP_DEFINE_CONST_FUN_OBJ_3(example_method_obj, example_method); | ||
|
||
// Class Methods | ||
static const mp_rom_map_elem_t example_locals_dict_table[] = { | ||
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&example__del__obj) }, | ||
{ MP_ROM_QSTR(MP_QSTR_mul), MP_ROM_PTR(&example_method_obj) } | ||
}; | ||
|
||
static MP_DEFINE_CONST_DICT(example_locals_dict, example_locals_dict_table); | ||
|
||
MP_DEFINE_CONST_OBJ_TYPE( | ||
Example_type, | ||
MP_QSTR_Example, | ||
MP_TYPE_FLAG_NONE, | ||
make_new, example_make_new, | ||
locals_dict, (mp_obj_dict_t*)&example_locals_dict | ||
); | ||
|
||
// Module Methods | ||
static const mp_map_elem_t example_globals_table[] = { | ||
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_example) }, // Module name | ||
{ MP_OBJ_NEW_QSTR(MP_QSTR_Example), (mp_obj_t)&Example_type }, // Class name & type | ||
}; | ||
|
||
static MP_DEFINE_CONST_DICT(mp_module_example_globals, example_globals_table); | ||
|
||
const mp_obj_module_t example_user_c_module = { | ||
.base = { &mp_type_module }, | ||
.globals = (mp_obj_dict_t*)&mp_module_example_globals, | ||
}; | ||
|
||
// First argument should match the __name__ given in the globals table | ||
MP_REGISTER_MODULE(MP_QSTR_example, example_user_c_module); |
Oops, something went wrong.