Skip to content

Commit

Permalink
Added GitHub workflow to build and publish all firmware files if cont…
Browse files Browse the repository at this point in the history
…ent in the folder "EleksTubeHax_pio" in the main branch is updated - added helper scripts - added switch in and scripts in platformio.ini - replaced esptool.exe with a never version to be able to merge files locally on windows (option merge_bin was missing) (#103)
  • Loading branch information
Martinius79 authored Nov 9, 2024
1 parent 577e4d2 commit 1aa6b5b
Show file tree
Hide file tree
Showing 5 changed files with 442 additions and 4 deletions.
131 changes: 131 additions & 0 deletions .github/workflows/pio-build-and-publish-all-firmware-files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
name: EleksTubeHAX generate firmware files

on:
push:
branches:
- main
paths:
- 'EleksTubeHAX_pio/**'
workflow_dispatch:

jobs:
set-version:
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.set_version.outputs.VERSION }}
steps:
- name: Set version number
id: set_version
run: |
MAJOR_VERSION=1
MINOR_VERSION=0
BUILD_NUMBER=${{ github.run_number }}
VERSION="${MAJOR_VERSION}.${MINOR_VERSION}.${BUILD_NUMBER}"
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
build-firmware:
needs: set-version
strategy:
matrix:
hardware: ['Elekstube_CLOCK', 'Elekstube_CLOCK_Gen2', 'SI_HAI_CLOCK', 'NovelLife_SE_CLOCK', 'PunkCyber_CLOCK']
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.set-version.outputs.VERSION }}
steps:
- uses: actions/checkout@v4

- uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio

- uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Modify _USER_DEFINES.h file
run: |
echo "Copy _USER_DEFINES - empty.h to _USER_DEFINES.h"
cp "./EleksTubeHAX_pio/src/_USER_DEFINES - empty.h" "./EleksTubeHAX_pio/src/_USER_DEFINES.h"
echo "Modify _USER_DEFINES.h for hardware: ${{ matrix.hardware }}"
python3 ./EleksTubeHAX_pio/script_modify_user_defines.py "${{ matrix.hardware }}"
echo "Modified _USER_DEFINES.h content:"
cat "./EleksTubeHAX_pio/src/_USER_DEFINES.h"
- name: Update FIRMWARE_VERSION in GLOBAL_DEFINES.h
run: |
echo "Updating FIRMWARE_VERSION in GLOBAL_DEFINES.h"
echo "Version: $VERSION"
sed -i "s/\(FIRMWARE_VERSION.*v\)1\.0/\1$VERSION/" "./EleksTubeHAX_pio/src/GLOBAL_DEFINES.h"
echo "Modified FIRMWARE_VERSION:"
grep '^#define FIRMWARE_VERSION' "./EleksTubeHAX_pio/src/GLOBAL_DEFINES.h"
- name: Install PlatformIO Core
run: pip install --upgrade platformio

- name: Uncomment CREATE_FIRMWAREFILE in platformio.ini
run: |
echo "Uncomment CREATE_FIRMWAREFILE in platformio.ini!"
sed -i 's/; -D CREATE_FIRMWAREFILE/-D CREATE_FIRMWAREFILE/' "./EleksTubeHAX_pio/platformio.ini"
# Debug output
echo "Modified platformio.ini content:"
cat "./EleksTubeHAX_pio/platformio.ini"
- name: Build PlatformIO Project for 4MB flash
run: pio run --environment esp32dev
working-directory: ./EleksTubeHAX_pio

- name: Rename firmware files
run: |
cd EleksTubeHAX_pio/.pio/build/esp32dev/
echo "Rename firmware files!"
if [ "${{ matrix.hardware }}" = "Elekstube_CLOCK" ]; then
echo "move *_combined.bin to FW_Elekstube_HAX_${{ env.VERSION }}_original.bin"
mv *_combined.bin "FW_Elekstube_HAX_${{ env.VERSION }}_original.bin"
elif [ "${{ matrix.hardware }}" = "Elekstube_CLOCK_Gen2" ]; then
echo "move *_combined.bin to FW_Elekstube_HAX_${{ env.VERSION }}_Gen2-1.bin"
mv *_combined.bin "FW_Elekstube_HAX_${{ env.VERSION }}_Gen2-1.bin"
elif [ "${{ matrix.hardware }}" = "SI_HAI_CLOCK" ]; then
echo "move *_combined.bin to FW_SI_HAI_CLOCK_HAX_${{ env.VERSION }}.bin"
mv *_combined.bin "FW_SI_HAI_CLOCK_HAX_${{ env.VERSION }}.bin"
elif [ "${{ matrix.hardware }}" = "NovelLife_SE_CLOCK" ]; then
echo "move *_combined.bin to FW_NovelLife_SE_HAX_${{ env.VERSION }}.bin"
mv *_combined.bin "FW_NovelLife_SE_HAX_${{ env.VERSION }}.bin"
elif [ "${{ matrix.hardware }}" = "PunkCyber_CLOCK" ]; then
echo "move *_combined.bin to FW_PunkCyber_Glow_PCBway_HAX_${{ env.VERSION }}.bin"
mv *_combined.bin "FW_PunkCyber_Glow_PCBway_HAX_${{ env.VERSION }}.bin"
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: firmware-${{ matrix.hardware }}
path: |
EleksTubeHAX_pio/.pio/build/esp32dev/FW_*.bin
if-no-files-found: error

combine-artifacts:
needs: [set-version, build-firmware]
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.set-version.outputs.VERSION }}
steps:
- name: Check VERSION
run: |
echo "VERSION=$VERSION"
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: all-firmware
pattern: firmware-*
merge-multiple: true

- name: Upload combined artifact
uses: actions/upload-artifact@v4
with:
name: all-firmware-v${{ env.VERSION }}
path: all-firmware/**/*.bin
if-no-files-found: error
9 changes: 5 additions & 4 deletions EleksTubeHAX_pio/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ board = esp32dev
framework = arduino

build_flags =
-DCORE_DEBUG_LEVEL=5 ; Set to 0 for no debug; saves flash memory
; Set to 5 for full debug
-DCORE_DEBUG_LEVEL=5 ; Set to 0 for no debug; saves flash memory; Set to 5 for full debug
; -D CREATE_FIRMWAREFILE ; "activate" the extra_script script_build_fs_and_merge.py

; https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html
board_build.partitions = partition_noOta_1Mapp_3Mspiffs.csv
Expand All @@ -38,7 +38,7 @@ lib_deps =
; These libraries and source files are causing boot-loop-crash. Do not use. TO-DO: replace with different libraries and source files.
;milesburton/DallasTemperature
;OneWire

; === Tested and working with following versions. If you have issues, revert to libraries listed below. ===
; arduino-libraries/NTPClient@^3.2.1
; adafruit/Adafruit NeoPixel@^1.12.0
Expand All @@ -56,4 +56,5 @@ extra_scripts =
script_configure_tft_lib.py
; modify the library files from the APDS9660 gesture sensor library to match ID if the used sensor
script_adjust_gesture_sensor_lib.py

; build the filesystem image and merge it with the other firmware files to one combinded binary with the name of the defined hardware in name
script_build_fs_and_merge.py
Loading

0 comments on commit 1aa6b5b

Please sign in to comment.