platformio / platform-espressif32

Espressif 32: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/espressif32
Apache License 2.0
907 stars 616 forks source link

BUG: PlatformIO build fails in CI env #1215

Closed musicmindmachine closed 11 months ago

musicmindmachine commented 11 months ago

Builds fail in CI in python after 6.4.0 update. Everything builds locally on multiple environments with clean installs, etc. Tried with and without caching in the workflow. Seems to fail with the upstream master or any recent pinned version for me. Am I missing something that changed?

Workflow File:

name: CI Build for Production Firmware

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
    pull_request:
        branches: [master]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
    # This workflow contains a single job called "build"
    build:
        name: Build Firmware for Production
        # The type of runner that the job will run on
        runs-on: ubuntu-latest
        strategy:
            fail-fast: false
            matrix: # Matrix allows us to run this job multiple times with different inputs
                board:
                    # ----------------------
                    # PIO ENVs to build for (flavors)
                    # ----------------------
                    - 'synergy'

        steps:
            - uses: actions/checkout@v3
            - uses: actions/cache@v3
              with:
                  path: |
                      ~/.cache/pip
                      ~/.platformio/.cache
                  key: ${{ matrix.board }}-pio
            - uses: actions/setup-python@v4
              with:
                  python-version: '3.9'

            - name: Install PlatformIO Core
              run: pip install --upgrade platformio

            - name: Checkout Repo
              uses: actions/checkout@v2
              with:
                  submodules: 'true'

            - name: Install platformIO libraries
              run: pio lib install

         #  - name: Upgrade PIO
         #    run: pio pkg update --no-save --environment ${{ matrix.board }}

            - name: Run PlatformIO Build for Board [${{ matrix.board }}]
              run: platformio run --environment ${{ matrix.board }}

GitHub Action CI log file:

CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/synergy.html
PLATFORM: Espressif 32 (6.4.0) > Synergy UF2 ESP32S2
HARDWARE: ESP32S2 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 @ 3.0.0+sha.e8f8228 
 - tool-esptoolpy @ 1.40501.0 (4.5.1) 
 - toolchain-riscv32-esp @ 12.2.0+20230208 
 - toolchain-xtensa-esp32s2 @ 12.2.0+20230208
KeyError: 'framework-arduinoespressif32-libs':
  File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/platformio/builder/main.py", line 173:
    env.SConscript("$BUILD_SCRIPT")
  File "/home/runner/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/home/runner/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 285:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/home/runner/.platformio/platforms/espressif32/builder/main.py", line 346:
    target_elf = env.BuildProgram()
  File "/home/runner/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Util/envs.py", line 242:
    return self.method(*nargs, **kwargs)
  File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/platformio/builder/tools/piobuild.py", line 61:
    env.ProcessProgramDeps()
  File "/home/runner/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Util/envs.py", line 242:
    return self.method(*nargs, **kwargs)
  File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/platformio/builder/tools/piobuild.py", line 121:
    env.BuildFrameworks(env.get("PIOFRAMEWORK"))
  File "/home/runner/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Util/envs.py", line 242:
    return self.method(*nargs, **kwargs)
  File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/platformio/builder/tools/piobuild.py", line 342:
    SConscript(env.GetFrameworkScript(name), exports="env")
  File "/home/runner/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 662:
    return method(*args, **kw)
  File "/home/runner/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/home/runner/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 285:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/home/runner/.platformio/platforms/espressif32/builder/frameworks/arduino.py", line 41:
    SConscript(
  File "/home/runner/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 662:
    return method(*args, **kw)
  File "/home/runner/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/home/runner/.platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 285:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/home/runner/.platformio/packages/framework-arduinoespressif32/tools/platformio-build.py", line 40:
    FRAMEWORK_LIBS_DIR = platform.get_package_dir("framework-arduinoespressif32-libs")
  File "/opt/hostedtoolcache/Python/3.9.18/x[64](https://github.com/<owner>/
  <repo>/actions/runs/6636439661/job/18028930102?pr=280#step:9:65)/lib/python3.9/site-packages/platformio/platform/_packages.py", line 32:
    pkg = self.get_package(name)
  File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/platformio/platform/_packages.py", line 29:
    return self.pm.get_package(spec or self.get_package_spec(name))
  File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/platformio/platform/_packages.py", line 21:
    owner=self.packages[name].get("owner"),
========================== [FAILED] Took 0.83 seconds ==========================

platform.ini file:

[platformio]
description =testing_os

; Default Dirs
src_dir = src
build_dir = build
lib_dir = lib
test_dir = test
data_dir = default_files
monitor_dir = monitor

; default build enviornment
default_envs = 
    synergy 

; Global Env Stuff
[env]
test_framework = googletest

;Scope for normal library deps
[lib_deps_all]
lib_deps = 
    fastled/FastLED@3.5.0
    adafruit/Adafruit TinyUSB Library@1.18.3
    adafruit/SdFat - Adafruit Fork@2.2.1
    bblanchon/ArduinoJson@6.21.3
    lennarthennigs/Button2@2.2.2

[embedded_boards_dir]
    boards_dir = boards

; Seperate scoped config vers for synergy boards
[embedded_config_esp32s2_synergy]
monitor_dir = monitor 
extends = env
framework = arduino
platform = espressif32
test_framework = googletest
test_speed = 115200
test_build_src = true
lib_ldf_mode = chain+
extra_scripts = pre:scripts/pre-build-tnyusb-hotfix.py
    pre:scripts/pre-build-tnyusb-cdc-descriptors-hotfix.py
    pre:scripts/update-fw-build-number.py
    post:scripts/elfsize.py
    post:scripts/linkerflags.py

    post:scripts/post-build-make-uf2-firmware-file.py
    post:scripts/post-build-make-combined-bin.py
    post:scripts/post-build-bin-files-copy.py

    ; post:scripts/post-uplolad-wait-for-cdc.py
    ; post:scripts/upload-delay-post-upload.py

    ; post:scripts/post-upload-copy-default_files.py
    ; post:scripts/elfsize-post-build.py
check_tool = pvs-studio ;, cppcheck, pvs-studio
board_build.lib_ldf_mode = chain+
build_src_filter = ${env.src_filter} -<../src/.exclude/> -<../include/.exclude/>
board_build.test_speed = 115200
board_build.test_filter = none
board_build.test_build_src = true
board_build.filesystem = fatfs
board_build.f_cpu = 240000000L ; Force to 80MHz to lock APB clock lower
monitor_speed = 115200

[env:synergy]
platform = espressif32
framework = arduino
platform_packages =
    platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git
extends = env, lib_deps_all, embedded_config_esp32s2_synergy, embedded_boards_dir

board_build.variants_dir = variants
board = synerg

build_flags = 
    ; -DPIO_UNIT_TESTING=1
    -DNDEBUG=1
    -DDEBUG_LEDG_LEVEL=0
    -DCORE_DEBUG_LEVEL=0
    -DHTTPS_LOGLEVEL=0
    -DCFG_TUSB_DEBUG=0
    -DUSB_CDC_ALWAYS_USE_DEBUG=0
    -DDISSABLE_USB_SERIAL_ONLY=0
    -DARDUINOJSON_DECODE_UNICODE=0
    -DFAT_REBOOT_ON_FORMAT=1
    -DFAT_FORCE_BOOT_INIT_VOLUME=0
    -DENABLE_ULP_BUTTON_SLEEP_WAKEUP=1
    -DPREFERENCES_ALWAYS_DEFAULT_ON_BOOT=0
    -DPIO_ENV_NAME=\"synergy\"
debug_build_flags = 
    ; -DPIO_UNIT_TESTING=1
    -DNDEBUG=1
    -DDEBUG_LEDG_LEVEL=0
    -DCORE_DEBUG_LEVEL=0
    -DHTTPS_LOGLEVEL=0
    -DCFG_TUSB_DEBUG=0
    -DUSB_CDC_ALWAYS_USE_DEBUG=0
    -DDISSABLE_USB_SERIAL_ONLY=0
    -DARDUINOJSON_DECODE_UNICODE=0
    -DFAT_REBOOT_ON_FORMAT=1
    -DFAT_FORCE_BOOT_INIT_VOLUME=0
    -DENABLE_ULP_BUTTON_SLEEP_WAKEUP=1
    -DPREFERENCES_ALWAYS_DEFAULT_ON_BOOT=0
    -DPIO_ENV_NAME=\"synergy\"
; 
; upload_port = COM9
; monitor_port = COM40
; upload_port = COM40
; test_port = COM40
; test_speed = 115200
Jason2866 commented 11 months ago

This is the reason for failing

platform_packages =
    platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git

Branch master is since a while not anymore based on IDF 4.4 -> Arduino Core 2.0.x Branch master is now based to build on IDF 5.1 and the Arduino code (3.0.0-alpha) is changed to be compatible to. Major changes are done, not compatible. For core 2.0.14 do

platform_packages =
    platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32/releases/download/2.0.14/esp32-2.0.14.zip
musicmindmachine commented 11 months ago

Thanks! Yeah I saw the 3.0.0 alpha in there from the upstream in the logs after I unpinned the version and swapped to the upstream. For some reason, pinning a few versions worked locally but not on CI.

I ended up changing out my workflow cache; then re-pinned a version of platformio/framework-arduinoespressif32 that ended up working after the cache clear. I'll give the bump to 2.0.14 a shot next!