diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index a5313cee..32a344d8 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -19,9 +19,9 @@ jobs: uses: actions/cache@v3 with: path: ${{runner.workspace}} - key: workspace-micropython-${{env.MICROPYTHON_VERSION}}-pico + key: workspace-micropython-${{env.MICROPYTHON_VERSION}}-nano-specs restore-keys: | - workspace-micropython-${{env.MICROPYTHON_VERSION}}-pico + workspace-micropython-${{env.MICROPYTHON_VERSION}}-nano-specs # Check out MicroPython - name: Checkout MicroPython @@ -129,18 +129,24 @@ jobs: echo "MICROPY_GIT_TAG=$MICROPYTHON_VERSION, ${{matrix.name}} ${{github.event.release.tag_name || github.sha}}" >> $GITHUB_ENV echo "MICROPY_GIT_HASH=$MICROPYTHON_VERSION-${{github.event.release.tag_name || github.sha}}" >> $GITHUB_ENV - - name: "HACK: Clean ports/rp2/modules" # We should move to using manifest.py to include our custom modules + - name: "HACK: Clean ports/rp2/modules and ports/rp2/CMakeLists.txt" shell: bash working-directory: micropython/ports/rp2 run: | rm -rf modules git checkout modules - - name: "HACK: Revert Pico SDK Patch" # Avoid an already-patched MicroPython tree breaking our build + - name: "HACK: Revert Patches" # Avoid an already-patched MicroPython tree breaking our build shell: bash - working-directory: micropython/lib/pico-sdk + working-directory: micropython run: | - git checkout . + git checkout lib/pico-sdk + git checkout ports/rp2/CMakeLists.txt + + - name: "HACK: CMakeLists.txt Disable C++ Exceptions Patch" + shell: bash + working-directory: micropython + run: git apply $GITHUB_WORKSPACE/pimoroni-pico-${{ github.sha }}/micropython/micropython_nano_specs.patch - name: "HACK: Pico SDK Patch" if: matrix.patch == true diff --git a/micropython/micropython_nano_specs.patch b/micropython/micropython_nano_specs.patch new file mode 100644 index 00000000..7801b58a --- /dev/null +++ b/micropython/micropython_nano_specs.patch @@ -0,0 +1,20 @@ +diff --git a/ports/rp2/CMakeLists.txt b/ports/rp2/CMakeLists.txt +index 094031c6852a..5f268414c08f 100644 +--- a/ports/rp2/CMakeLists.txt ++++ b/ports/rp2/CMakeLists.txt +@@ -374,6 +374,15 @@ target_compile_options(${MICROPY_TARGET} PRIVATE + target_link_options(${MICROPY_TARGET} PRIVATE + -Wl,--defsym=__micropy_c_heap_size__=${MICROPY_C_HEAP_SIZE} + ) ++# Do not include stack unwinding & exception handling for C++ user modules ++target_compile_definitions(usermod INTERFACE PICO_CXX_ENABLE_EXCEPTIONS=0) ++target_compile_options(usermod INTERFACE $<$: ++ -fno-exceptions ++ -fno-unwind-tables ++ -fno-rtti ++ -fno-use-cxa-atexit ++>) ++target_link_options(usermod INTERFACE -specs=nano.specs) + + set_source_files_properties( + ${PICO_SDK_PATH}/src/rp2_common/pico_double/double_math.c