kopia lustrzana https://github.com/pimoroni/pimoroni-pico
Merge pull request #375 from pimoroni/experimental/build-tweaks
Customise MicroPython C++ modules per board to avoid blowing 640K binary limit on 2MB Pico boardspatch-drop-defunct-constructors
commit
7db6d62515
|
@ -1,136 +0,0 @@
|
|||
name: MicroPython+Blinka
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
env:
|
||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||
MICROPYTHON_VERSION: v1.18
|
||||
BLINKA_VERSION: 7.3.0
|
||||
PLATFORMDETECT_VERSION: 3.22.1
|
||||
BUILD_TYPE: Release
|
||||
BOARD_TYPE: PICO
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: ${{matrix.name}}
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
name: Linux
|
||||
cache-key: linux
|
||||
cmake-args: '-DPICO_SDK_PATH=$GITHUB_WORKSPACE/pico-sdk'
|
||||
apt-packages: ccache
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
# Check out MicroPython
|
||||
- name: Checkout MicroPython
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: micropython/micropython
|
||||
ref: ${{env.MICROPYTHON_VERSION}}
|
||||
submodules: false # MicroPython submodules are hideously broken
|
||||
path: micropython
|
||||
|
||||
# Checkout Blinka requirements
|
||||
- name: Checkout Blinka
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: adafruit/Adafruit_Blinka
|
||||
ref: ${{env.BLINKA_VERSION}}
|
||||
path: Adafruit_Blinka
|
||||
|
||||
- name: Checkout PlatformDetect
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: adafruit/Adafruit_Python_PlatformDetect
|
||||
ref: ${{env.PLATFORMDETECT_VERSION}}
|
||||
path: Adafruit_Python_PlatformDetect
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
path: pimoroni-pico-${{ github.sha }}
|
||||
|
||||
# Copy module files from Blinka/PlatformDetect into MicroPython
|
||||
- name: Copy modules
|
||||
run: |
|
||||
cp -r pimoroni-pico-${GITHUB_SHA}/micropython/modules_py/* micropython/ports/rp2/modules/
|
||||
mkdir -p micropython/ports/rp2/modules/adafruit_blinka/microcontroller/
|
||||
cp -r Adafruit_Blinka/src/adafruit_blinka/microcontroller/rp2040 micropython/ports/rp2/modules/adafruit_blinka/microcontroller/
|
||||
cp -r Adafruit_Blinka/src/adafruit_blinka/microcontroller/generic_micropython micropython/ports/rp2/modules/adafruit_blinka/microcontroller/
|
||||
mkdir -p micropython/ports/rp2/modules/adafruit_blinka/board/raspberrypi/
|
||||
cp Adafruit_Blinka/src/adafruit_blinka/microcontroller/__init__.py micropython/ports/rp2/modules/adafruit_blinka/microcontroller/
|
||||
cp Adafruit_Blinka/src/adafruit_blinka/board/__init__.py micropython/ports/rp2/modules/adafruit_blinka/board/
|
||||
cp Adafruit_Blinka/src/adafruit_blinka/board/pico_u2if.py micropython/ports/rp2/modules/adafruit_blinka/board/
|
||||
cp Adafruit_Blinka/src/adafruit_blinka/board/raspberrypi/__init__.py micropython/ports/rp2/modules/adafruit_blinka/board/raspberrypi/
|
||||
cp Adafruit_Blinka/src/adafruit_blinka/board/raspberrypi/pico.py micropython/ports/rp2/modules/adafruit_blinka/board/raspberrypi/
|
||||
cp Adafruit_Blinka/src/*.py micropython/ports/rp2/modules/
|
||||
cp -r Adafruit_Blinka/src/microcontroller micropython/ports/rp2/modules/
|
||||
cp Adafruit_Blinka/src/adafruit_blinka/__init__.py micropython/ports/rp2/modules/adafruit_blinka/
|
||||
cp -r Adafruit_Blinka/src/adafruit_blinka/agnostic micropython/ports/rp2/modules/adafruit_blinka/
|
||||
cp -r Adafruit_Python_PlatformDetect/adafruit_platformdetect micropython/ports/rp2/modules/
|
||||
|
||||
# Linux deps
|
||||
- name: Install deps
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
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
|
||||
shell: bash
|
||||
working-directory: micropython
|
||||
run: |
|
||||
git submodule update --init
|
||||
|
||||
- name: Fetch Pico SDK submodules
|
||||
shell: bash
|
||||
working-directory: micropython/lib/pico-sdk
|
||||
run: git submodule update --init
|
||||
|
||||
- name: Build mpy-cross
|
||||
shell: bash
|
||||
working-directory: micropython/mpy-cross
|
||||
run: make
|
||||
|
||||
- name: Build MicroPython
|
||||
shell: bash
|
||||
working-directory: micropython/ports/rp2
|
||||
run: make USER_C_MODULES=../../../pimoroni-pico-${GITHUB_SHA}/micropython/modules/micropython.cmake -j2
|
||||
|
||||
- name: Rename .uf2 for artifact
|
||||
shell: bash
|
||||
working-directory: micropython/ports/rp2/build-${{env.BOARD_TYPE}}
|
||||
run: cp firmware.uf2 ${{github.event.repository.name}}-${{github.event.release.tag_name}}-micropython-${{env.MICROPYTHON_VERSION}}-blinka-${{env.BLINKA_VERSION}}-platformdetect-${{env.PLATFORMDETECT_VERSION}}.uf2
|
||||
|
||||
- name: Store .uf2 as artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{github.event.repository.name}}-${{github.event.release.tag_name}}-micropython-${{env.MICROPYTHON_VERSION}}-blinka-${{env.BLINKA_VERSION}}-platformdetect-${{env.PLATFORMDETECT_VERSION}}.uf2
|
||||
path: micropython/ports/rp2/build-${{env.BOARD_TYPE}}/${{github.event.repository.name}}-${{github.event.release.tag_name}}-micropython-${{env.MICROPYTHON_VERSION}}-blinka-${{env.BLINKA_VERSION}}-platformdetect-${{env.PLATFORMDETECT_VERSION}}.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.BOARD_TYPE}}/firmware.uf2
|
||||
upload_url: ${{github.event.release.upload_url}}
|
||||
asset_name: ${{github.event.repository.name}}-${{github.event.release.tag_name}}-micropython-${{env.MICROPYTHON_VERSION}}-blinka-${{env.BLINKA_VERSION}}-platformdetect-${{env.PLATFORMDETECT_VERSION}}.uf2
|
||||
asset_content_type: application/octet-stream
|
|
@ -112,7 +112,7 @@ jobs:
|
|||
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
|
||||
cmake -S . -B build-${{matrix.board}} -DPICO_BUILD_DOCS=0 -DUSER_C_MODULES=../../../pimoroni-pico-${GITHUB_SHA}/micropython/modules/micropython-${{matrix.name}}.cmake -DMICROPY_BOARD=${{matrix.board}} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
|
||||
- name: Build MicroPython
|
||||
shell: bash
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
include(pimoroni_i2c/micropython)
|
||||
|
||||
include(breakout_dotmatrix/micropython)
|
||||
include(breakout_encoder/micropython)
|
||||
include(breakout_ioexpander/micropython)
|
||||
include(breakout_ltr559/micropython)
|
||||
include(breakout_colourlcd160x80/micropython)
|
||||
include(breakout_as7262/micropython)
|
||||
include(breakout_rgbmatrix5x5/micropython)
|
||||
include(breakout_matrix11x7/micropython)
|
||||
include(breakout_msa301/micropython)
|
||||
include(breakout_pmw3901/micropython)
|
||||
include(breakout_mics6814/micropython)
|
||||
include(breakout_potentiometer/micropython)
|
||||
include(breakout_rtc/micropython)
|
||||
include(breakout_trackball/micropython)
|
||||
include(breakout_sgp30/micropython)
|
||||
include(breakout_bh1745/micropython)
|
||||
include(breakout_bme68x/micropython)
|
||||
include(breakout_bme280/micropython)
|
||||
include(breakout_bmp280/micropython)
|
||||
include(breakout_icp10125/micropython)
|
||||
include(breakout_scd41/micropython)
|
||||
include(breakout_vl53l5cx/micropython)
|
||||
|
||||
include(pico_scroll/micropython)
|
||||
include(pico_rgb_keypad/micropython)
|
||||
include(pico_unicorn/micropython)
|
||||
include(pico_explorer/micropython)
|
||||
include(pico_wireless/micropython)
|
||||
|
||||
include(bitmap_fonts/micropython)
|
||||
|
||||
include(plasma/micropython)
|
||||
include(hub75/micropython)
|
||||
include(pwm/micropython)
|
||||
include(servo/micropython)
|
||||
include(encoder/micropython)
|
||||
include(motor/micropython)
|
||||
include(qrcode/micropython/micropython)
|
||||
include(adcfft/micropython)
|
||||
|
||||
include(st7789/micropython)
|
||||
|
||||
include(modules_py/modules_py)
|
||||
|
||||
function(enable_ulab)
|
||||
include(ulab/code/micropython)
|
||||
|
||||
target_compile_definitions(usermod_ulab INTERFACE
|
||||
# Support for complex ndarrays
|
||||
ULAB_SUPPORTS_COMPLEX=0
|
||||
|
||||
# Determines, whether scipy is defined in ulab. The sub-modules and functions
|
||||
# of scipy have to be defined separately
|
||||
ULAB_HAS_SCIPY=0
|
||||
|
||||
# The maximum number of dimensions the firmware should be able to support
|
||||
# Possible values lie between 1, and 4, inclusive
|
||||
ULAB_MAX_DIMS=2
|
||||
|
||||
# By setting this constant to 1, iteration over array dimensions will be implemented
|
||||
# as a function (ndarray_rewind_array), instead of writing out the loops in macros
|
||||
# This reduces firmware size at the expense of speed
|
||||
ULAB_HAS_FUNCTION_ITERATOR=1
|
||||
|
||||
# If NDARRAY_IS_ITERABLE is 1, the ndarray object defines its own iterator function
|
||||
# This option saves approx. 250 bytes of flash space
|
||||
NDARRAY_IS_ITERABLE=1
|
||||
|
||||
# Slicing can be switched off by setting this variable to 0
|
||||
NDARRAY_IS_SLICEABLE=1
|
||||
|
||||
# The default threshold for pretty printing. These variables can be overwritten
|
||||
# at run-time via the set_printoptions() function
|
||||
ULAB_HAS_PRINTOPTIONS=1
|
||||
NDARRAY_PRINT_THRESHOLD=10
|
||||
NDARRAY_PRINT_EDGEITEMS=3
|
||||
|
||||
# determines, whether the dtype is an object, or simply a character
|
||||
# the object implementation is numpythonic, but requires more space
|
||||
ULAB_HAS_DTYPE_OBJECT=0
|
||||
|
||||
# the ndarray binary operators
|
||||
NDARRAY_HAS_BINARY_OPS=0
|
||||
|
||||
# Firmware size can be reduced at the expense of speed by using function
|
||||
# pointers in iterations. For each operator, the function pointer saves around
|
||||
# 2 kB in the two-dimensional case, and around 4 kB in the four-dimensional case.
|
||||
|
||||
NDARRAY_BINARY_USES_FUN_POINTER=1
|
||||
|
||||
NDARRAY_HAS_BINARY_OP_ADD=1
|
||||
NDARRAY_HAS_BINARY_OP_EQUAL=1
|
||||
NDARRAY_HAS_BINARY_OP_LESS=1
|
||||
NDARRAY_HAS_BINARY_OP_LESS_EQUAL=1
|
||||
NDARRAY_HAS_BINARY_OP_MORE=1
|
||||
NDARRAY_HAS_BINARY_OP_MORE_EQUAL=1
|
||||
NDARRAY_HAS_BINARY_OP_MULTIPLY=1
|
||||
NDARRAY_HAS_BINARY_OP_NOT_EQUAL=1
|
||||
NDARRAY_HAS_BINARY_OP_POWER=1
|
||||
NDARRAY_HAS_BINARY_OP_SUBTRACT=1
|
||||
NDARRAY_HAS_BINARY_OP_TRUE_DIVIDE=1
|
||||
)
|
||||
endfunction()
|
|
@ -0,0 +1,7 @@
|
|||
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}/../../")
|
||||
|
||||
include(micropython-common)
|
|
@ -0,0 +1,9 @@
|
|||
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}/../../")
|
||||
|
||||
include(micropython-common)
|
||||
|
||||
enable_ulab()
|
|
@ -0,0 +1,9 @@
|
|||
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}/../../")
|
||||
|
||||
include(micropython-common)
|
||||
|
||||
enable_ulab()
|
|
@ -0,0 +1,9 @@
|
|||
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}/../../")
|
||||
|
||||
include(micropython-common)
|
||||
|
||||
enable_ulab()
|
|
@ -1,52 +0,0 @@
|
|||
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}/../../")
|
||||
|
||||
include(pimoroni_i2c/micropython)
|
||||
|
||||
include(breakout_dotmatrix/micropython)
|
||||
include(breakout_encoder/micropython)
|
||||
include(breakout_ioexpander/micropython)
|
||||
include(breakout_ltr559/micropython)
|
||||
include(breakout_colourlcd160x80/micropython)
|
||||
include(breakout_as7262/micropython)
|
||||
include(breakout_rgbmatrix5x5/micropython)
|
||||
include(breakout_matrix11x7/micropython)
|
||||
include(breakout_msa301/micropython)
|
||||
include(breakout_pmw3901/micropython)
|
||||
include(breakout_mics6814/micropython)
|
||||
include(breakout_potentiometer/micropython)
|
||||
include(breakout_rtc/micropython)
|
||||
include(breakout_trackball/micropython)
|
||||
include(breakout_sgp30/micropython)
|
||||
include(breakout_bh1745/micropython)
|
||||
include(breakout_bme68x/micropython)
|
||||
include(breakout_bme280/micropython)
|
||||
include(breakout_bmp280/micropython)
|
||||
include(breakout_icp10125/micropython)
|
||||
include(breakout_scd41/micropython)
|
||||
include(breakout_vl53l5cx/micropython)
|
||||
|
||||
include(pico_scroll/micropython)
|
||||
include(pico_rgb_keypad/micropython)
|
||||
include(pico_unicorn/micropython)
|
||||
include(pico_explorer/micropython)
|
||||
include(pico_wireless/micropython)
|
||||
|
||||
include(bitmap_fonts/micropython)
|
||||
|
||||
include(plasma/micropython)
|
||||
include(hub75/micropython)
|
||||
include(pwm/micropython)
|
||||
include(servo/micropython)
|
||||
include(encoder/micropython)
|
||||
include(motor/micropython)
|
||||
include(ulab/code/micropython)
|
||||
include(qrcode/micropython/micropython)
|
||||
include(adcfft/micropython)
|
||||
|
||||
include(st7789/micropython)
|
||||
|
||||
include(modules_py/modules_py)
|
|
@ -1 +1 @@
|
|||
Subproject commit 24caf74d90e88a62a030309d229155e210d897ac
|
||||
Subproject commit d438344943ab4383dae86b4620075ea877dec535
|
Ładowanie…
Reference in New Issue