From 777d5dd8b8ec39b9df45872670d9d3520f1ca836 Mon Sep 17 00:00:00 2001 From: Pirata Date: Thu, 21 May 2026 10:50:42 -0300 Subject: [PATCH 1/3] Add Merged binary to release assets --- .github/actions/build-firmware/action.yml | 12 +++++ Buildscripts/CDN/generate-firmware-files.py | 2 +- Buildscripts/Flashing/merge.ps1 | 20 +++++++++ Buildscripts/Flashing/merge.sh | 50 +++++++++++++++++++++ 4 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 Buildscripts/Flashing/merge.ps1 create mode 100644 Buildscripts/Flashing/merge.sh diff --git a/.github/actions/build-firmware/action.yml b/.github/actions/build-firmware/action.yml index 08871adb4..a0dcd35a1 100644 --- a/.github/actions/build-firmware/action.yml +++ b/.github/actions/build-firmware/action.yml @@ -26,6 +26,12 @@ runs: - name: 'Release' shell: bash run: Buildscripts/release.sh ${{ inputs.board_id }} + - name: 'Merge binary' + shell: bash + run: | + cd release/Tactility-${{ inputs.board_id }} + bash ./merge.sh ${{ inputs.arch }} + mv Binaries/merged_binary.bin ../Tactility-${{ inputs.board_id }}.bin - name: 'Upload Artifact: Release' uses: actions/upload-artifact@v4 with: @@ -38,3 +44,9 @@ runs: name: Tactility-${{ inputs.board_id }}-symbols path: release/Tactility-${{ inputs.board_id }}-symbols retention-days: 30 + - name: 'Upload Artifact: Merged binary' + uses: actions/upload-artifact@v4 + with: + name: Tactility-${{ inputs.board_id }}.bin + path: release/Tactility-${{ inputs.board_id }}.bin + retention-days: 30 diff --git a/Buildscripts/CDN/generate-firmware-files.py b/Buildscripts/CDN/generate-firmware-files.py index 0489f0743..23fd6126e 100644 --- a/Buildscripts/CDN/generate-firmware-files.py +++ b/Buildscripts/CDN/generate-firmware-files.py @@ -191,7 +191,7 @@ def main(in_path: str, out_path: str, version: str): devices=[] ) for artifact_directory in artifact_directories: - if artifact_directory.endswith("-symbols") or artifact_directory.startswith("TactilitySDK-"): + if artifact_directory.endswith("-symbols") or artifact_directory.endswith(".bin") or artifact_directory.startswith("TactilitySDK-"): continue device_id = artifact_directory.removeprefix("Tactility-") if not device_id: diff --git a/Buildscripts/Flashing/merge.ps1 b/Buildscripts/Flashing/merge.ps1 new file mode 100644 index 000000000..c288edc59 --- /dev/null +++ b/Buildscripts/Flashing/merge.ps1 @@ -0,0 +1,20 @@ +param( + $port +) + +if ((Get-Command "esptool" -ErrorAction SilentlyContinue) -eq $null) +{ + Write-Host "Unable to find esptool in your path. Make sure you have Python installed and on your path. Then run `pip install esptool`." +} + +# Create merge command based on partitions +$json = Get-Content .\Binaries\flasher_args.json -Raw | ConvertFrom-Json +$jsonClean = $json.flash_files -replace '[\{\}\@\;]', '' +$jsonClean = $jsonClean -replace '[\=]', ' ' + +cd Binaries +# "--chip esp32s3" is irrelevant, just need to be added, works for all variant +$command = "esptool --chip esp32s3 merge-bin --output merged_binary.bin $jsonClean" +Invoke-Expression $command +cd .. + diff --git a/Buildscripts/Flashing/merge.sh b/Buildscripts/Flashing/merge.sh new file mode 100644 index 000000000..2b960aea2 --- /dev/null +++ b/Buildscripts/Flashing/merge.sh @@ -0,0 +1,50 @@ +#!/bin/sh + +# Usage: +# merge.sh [chip] +# +# Arguments: +# chip - optional ESP32 SOC variant (e.g. esp32, esp32s3, esp32c6) +# +# Requirements: +# jq - run 'pip install jq' +# esptool.py - run 'pip install esptool' +# +# Documentation: +# https://docs.espressif.com/projects/esptool/en/latest/esp32/ +# + +# Source: https://stackoverflow.com/a/53798785 +function is_bin_in_path { + builtin type -P "$1" &> /dev/null +} + +function require_bin { + program=$1 + if ! is_bin_in_path $program; then + exit 1 + else + exit 0 + fi +} + +# Find either esptool (installed via system package manager) or esptool.py (installed via pip) +if ! is_bin_in_path esptool; then + if ! is_bin_in_path esptool.py; then + echo "\e[31m⚠️ esptool not found! Install it from your package manager or install python and run 'pip install esptool'\e[0m" + exit 1 + else + esptoolPath=esptool.py + fi +else + esptoolPath=esptool +fi + +chip=${1:-esp32s3} + +# Take the flash_arg file contents and join each line in the file into a single line +flash_args=`tr '\n' ' ' < Binaries/flash_args` +cd Binaries +$esptoolPath --chip "$chip" merge-bin --output merged_binary.bin $flash_args +cd - + From 7f7ba255c42d80c0cc034af01be7556121d067ed Mon Sep 17 00:00:00 2001 From: Pirata Date: Thu, 21 May 2026 11:15:28 -0300 Subject: [PATCH 2/3] fix missing esptool on CI --- .github/actions/build-firmware/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/build-firmware/action.yml b/.github/actions/build-firmware/action.yml index a0dcd35a1..2317b64e0 100644 --- a/.github/actions/build-firmware/action.yml +++ b/.github/actions/build-firmware/action.yml @@ -29,6 +29,7 @@ runs: - name: 'Merge binary' shell: bash run: | + python -m pip install esptool cd release/Tactility-${{ inputs.board_id }} bash ./merge.sh ${{ inputs.arch }} mv Binaries/merged_binary.bin ../Tactility-${{ inputs.board_id }}.bin From 70a945b1b4af80e527496712d2c1d891dd7504df Mon Sep 17 00:00:00 2001 From: Pirata Date: Thu, 21 May 2026 12:49:13 -0300 Subject: [PATCH 3/3] Fixes requested resolves: https://github.com/TactilityProject/Tactility/pull/524#discussion_r3282067255 https://github.com/TactilityProject/Tactility/pull/524#discussion_r3282067270 https://github.com/TactilityProject/Tactility/pull/524#discussion_r3282067300 https://github.com/TactilityProject/Tactility/pull/524#discussion_r3282067313 https://github.com/TactilityProject/Tactility/pull/524#discussion_r3282067324 --- Buildscripts/Flashing/merge.ps1 | 20 +++++++++++++------- Buildscripts/Flashing/merge.sh | 12 +++++++----- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Buildscripts/Flashing/merge.ps1 b/Buildscripts/Flashing/merge.ps1 index c288edc59..1a9a408fc 100644 --- a/Buildscripts/Flashing/merge.ps1 +++ b/Buildscripts/Flashing/merge.ps1 @@ -1,10 +1,12 @@ param( - $port + # "--chip esp32s3" is irrelevant, just need to be added, fallback to "esp32s3" + [string]$chip = "esp32s3" ) -if ((Get-Command "esptool" -ErrorAction SilentlyContinue) -eq $null) +if ($null -eq (Get-Command "esptool" -ErrorAction SilentlyContinue)) { Write-Host "Unable to find esptool in your path. Make sure you have Python installed and on your path. Then run `pip install esptool`." + exit 1 } # Create merge command based on partitions @@ -12,9 +14,13 @@ $json = Get-Content .\Binaries\flasher_args.json -Raw | ConvertFrom-Json $jsonClean = $json.flash_files -replace '[\{\}\@\;]', '' $jsonClean = $jsonClean -replace '[\=]', ' ' -cd Binaries -# "--chip esp32s3" is irrelevant, just need to be added, works for all variant -$command = "esptool --chip esp32s3 merge-bin --output merged_binary.bin $jsonClean" -Invoke-Expression $command -cd .. +$mergeArgs = @('--chip', $chip, 'merge-bin', '--output', 'merged_binary.bin') + ($jsonClean -split '\s+' | Where-Object { $_ }) +Push-Location Binaries +& esptool @mergeArgs +$exitCode = $LASTEXITCODE +Pop-Location + +if ($exitCode -ne 0) { + exit $exitCode +} diff --git a/Buildscripts/Flashing/merge.sh b/Buildscripts/Flashing/merge.sh index 2b960aea2..2a8cff8a5 100644 --- a/Buildscripts/Flashing/merge.sh +++ b/Buildscripts/Flashing/merge.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # Usage: # merge.sh [chip] @@ -43,8 +43,10 @@ fi chip=${1:-esp32s3} # Take the flash_arg file contents and join each line in the file into a single line -flash_args=`tr '\n' ' ' < Binaries/flash_args` -cd Binaries -$esptoolPath --chip "$chip" merge-bin --output merged_binary.bin $flash_args -cd - +flash_args="$(tr '\n' ' ' < Binaries/flash_args)" +read -r -a flash_args_array <<< "$flash_args" +( + cd Binaries || exit 1 + "$esptoolPath" --chip "$chip" merge-bin --output merged_binary.bin "${flash_args_array[@]}" +) || exit 1