diff --git a/.github/workflows/merge-criteria.yml b/.github/workflows/merge-criteria.yml index 2d770c6b..52b407c2 100644 --- a/.github/workflows/merge-criteria.yml +++ b/.github/workflows/merge-criteria.yml @@ -33,6 +33,9 @@ jobs: - name: Filter changed directories id: changed-files-filtered + env: + REQUESTED_COMMIT_SHA: ${{ inputs.commit_sha }} + CHANGED_DIRECTORIES: ${{ steps.changed-files.outputs.all_changed_files }} # The build pipeline is triggered only for the project in which the changes happened. # For example if a change was made in flight_computer/src/main.cpp, a pipeline will # run only for the 'flight_computer' project. @@ -42,14 +45,13 @@ jobs: # Additionally, the pipeline will also run for all three projects if it is triggered # when pushing to main. run: | - contains_dot=$(echo '${{ steps.changed-files.outputs.all_changed_files }}' | jq 'map(select(. == ".")) | length') - contains_dotgithub=$(echo '${{ steps.changed-files.outputs.all_changed_files }}' | jq 'map(select(. == ".github")) | length') - is_manual_trigger=$(echo '${{ github.event.inputs.commit_sha }}') + contains_dot=$(jq 'map(select(. == ".")) | length' <<< "$CHANGED_DIRECTORIES") + contains_dotgithub=$(jq 'map(select(. == ".github")) | length' <<< "$CHANGED_DIRECTORIES") - if [[ -n "$is_manual_trigger" || "${GITHUB_REF}" == "refs/heads/main" || $contains_dot -gt 0 || $contains_dotgithub -gt 0 ]]; then + if [[ -n "$REQUESTED_COMMIT_SHA" || "$GITHUB_REF" == "refs/heads/main" || $contains_dot -gt 0 || $contains_dotgithub -gt 0 ]]; then filtered_array='["flight_computer","ground_station","telemetry"]' else - filtered_array=$(echo '${{ steps.changed-files.outputs.all_changed_files }}' | jq -c '[.[] | select(. == "flight_computer" or . == "ground_station" or . == "telemetry")]') + filtered_array=$(jq -c '[.[] | select(. == "flight_computer" or . == "ground_station" or . == "telemetry")]' <<< "$CHANGED_DIRECTORIES") fi echo "$filtered_array" @@ -74,6 +76,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v7 + with: + ref: ${{ inputs.commit_sha }} - name: Run clang-format uses: jidicula/clang-format-action@v4.18.0 @@ -97,6 +101,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v7 + with: + ref: ${{ inputs.commit_sha }} - name: Check cache uses: actions/cache@v6 @@ -179,6 +185,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v7 + with: + ref: ${{ inputs.commit_sha }} - name: Check cache uses: actions/cache@v6 @@ -190,7 +198,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v7 with: - python-version: '3.11' + python-version: ${{ matrix.project == 'ground_station' && '3.14.10' || '3.15.2' }} cache: 'pip' - name: Install dependencies diff --git a/README.md b/README.md index 7f715925..ba7842ba 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,24 @@ platformio run -d flight_computer --environment debug Pull requests are automatically checked for formatting, build errors, and static-analysis warnings. +### Reproducing Windows release builds + +On 64-bit Windows, create a virtual environment with the Python version used by the GitHub Actions upload job. Install `requirements.txt` as shown above and build the same commit as that job. + +| Project | Python | +| --- | --- | +| `flight_computer` | 3.15.2 | +| `telemetry` | 3.15.2 | +| `ground_station` | 3.14.10 | + +Use a dedicated PlatformIO Core directory for each project to isolate the installed SCons version. Set `$project` to the directory you want to build. + +```powershell +$project = 'flight_computer' +$env:PLATFORMIO_CORE_DIR = "$env:LOCALAPPDATA\CATS\${project}-platformio" +python -m platformio run -d $project +``` + ## Contributing Contributions are welcome. Examples include: diff --git a/flight_computer/platformio.ini b/flight_computer/platformio.ini index cb6cfbff..13cc925d 100644 --- a/flight_computer/platformio.ini +++ b/flight_computer/platformio.ini @@ -6,10 +6,12 @@ default_envs = release [env] -platform = ststm32 +platform = platformio/ststm32@20.0.0 board = genericSTM32F411CE #framework = stm32cube -platform_packages = platformio/toolchain-gccarmnoneeabi@^1.100301.220327 +platform_packages = + platformio/toolchain-gccarmnoneeabi@1.140201.0 + platformio/tool-scons@4.40801.0 upload_protocol = stlink debug_tool = stlink board_build.ldscript = src/target/VEGA/STM32F411CCUX_FLASH.ld diff --git a/ground_station/AGENTS.md b/ground_station/AGENTS.md index 7c767775..01b94837 100644 --- a/ground_station/AGENTS.md +++ b/ground_station/AGENTS.md @@ -81,8 +81,9 @@ QR navigation, and live compass checks on hardware. Preserve those deltas when rebasing a vendored library and record the exact upstream tag or commit. - Do not blanket-format vendored libraries. Preserve upstream source unless a documented CATS compatibility patch is necessary. -- Use PlatformIO 6.1.19 with Python 3.11 from the root `requirements.txt`. Upload-only packages are pinned in - `ground_station/requirements-upload.txt`; never install the unrelated Python package named `serial`. +- Install PlatformIO 6.1.19 from the root `requirements.txt`. Use Python 3.14.10 for Windows release builds and + Python 3.11 for WSL pre-commit checks. Upload-only packages are pinned in `ground_station/requirements-upload.txt`; + never install the unrelated Python package named `serial`. - On Windows, if `platformio` is not on `PATH`, use `& "$env:USERPROFILE\.platformio\penv\Scripts\platformio.exe"` and verify that it reports version 6.1.19. Do not create a separate legacy environment just to make the command available. diff --git a/ground_station/platformio.ini b/ground_station/platformio.ini index a6ffa67b..b690780e 100644 --- a/ground_station/platformio.ini +++ b/ground_station/platformio.ini @@ -6,6 +6,7 @@ board = esp32-s2-saola-1 framework = arduino platform = https://github.com/tasmota/platform-espressif32/releases/download/2026.05.50/platform-espressif32.zip +platform_packages = platformio/tool-scons@4.40801.0 board_build.boot=qio board_build.bootloader=qio @@ -19,6 +20,7 @@ board_build.mcu = esp32s2 lib_deps = adafruit/Adafruit SPIFlash@5.1.1 + adafruit/Adafruit NeoPixel@1.15.5 adafruit/SdFat - Adafruit Fork@2.3.103 bblanchon/ArduinoJson@7.4.3 jchristensen/JC_Button@2.1.6 @@ -26,6 +28,9 @@ lib_deps = Wire paulstoffregen/Time@1.6.1 +; Keep the pinned NeoPixel dependency of SPIFlash out of the firmware build. +lib_ignore = Adafruit NeoPixel + build_flags = -fexceptions ; Required by the Nayuki C++ QR encoder -DFIRMWARE_VERSION='"1.3.3"' ; Enter Firmware Version here diff --git a/ground_station/pre_config.py b/ground_station/pre_config.py index d8f7a01e..7ec6b6c9 100644 --- a/ground_station/pre_config.py +++ b/ground_station/pre_config.py @@ -9,12 +9,28 @@ # below the PlatformIO package root. A shared PlatformIO home can retain the # package metadata while losing the installer-added PATH adjustment, leaving # an otherwise valid compiler undiscoverable on Windows. -toolchain_root = env.PioPlatform().get_package_dir("toolchain-xtensa-esp-elf") +platform = env.PioPlatform() +toolchain_root = platform.get_package_dir("toolchain-xtensa-esp-elf") if toolchain_root: - nested_toolchain_bin = os.path.join(toolchain_root, "xtensa-esp-elf", "bin") + nested_toolchain_root = os.path.join(toolchain_root, "xtensa-esp-elf") + nested_toolchain_bin = os.path.join(nested_toolchain_root, "bin") compiler_name = "xtensa-esp32s2-elf-g++.exe" if os.name == "nt" else "xtensa-esp32s2-elf-g++" if os.path.isfile(os.path.join(nested_toolchain_bin, compiler_name)): env.PrependENVPath("PATH", nested_toolchain_bin) + toolchain_root = nested_toolchain_root + +# Keep source paths in diagnostics and debug information independent of the build machine. +project_root = env.subst("$PROJECT_DIR").replace(os.sep, "/") +core_root = platform.config.get("platformio", "core_dir").replace(os.sep, "/") +prefix_map_flags = [ + f"-ffile-prefix-map={project_root}=.", + f"-ffile-prefix-map={core_root}=platformio", +] +if toolchain_root: + # Use the same DWARF paths for flat and nested toolchain installations. + compiler_root = toolchain_root.replace(os.sep, "/") + prefix_map_flags.append(f"-fdebug-prefix-map={compiler_root}=platformio/packages/toolchain-xtensa-esp-elf") +env.Append(CCFLAGS=prefix_map_flags, LINKFLAGS=prefix_map_flags) env.Append( # Unfortunately we can't use the standard standard, diff --git a/telemetry/platformio.ini b/telemetry/platformio.ini index 5910fa1a..8eb3fca4 100644 --- a/telemetry/platformio.ini +++ b/telemetry/platformio.ini @@ -4,8 +4,12 @@ [env:telemetry] -platform = ststm32 -platform_packages = platformio/toolchain-gccarmnoneeabi@^1.100301.220327 +platform = platformio/ststm32@20.0.0 +platform_packages = + platformio/toolchain-gccarmnoneeabi@1.140201.0 + platformio/framework-stm32cubeg0@1.6.3 + platformio/tool-ldscripts-ststm32@0.3.0 + platformio/tool-scons@4.40801.0 board = disco_g071rb framework = stm32cube