Skip to content

Commit

Permalink
Test esp32 fw merge
Browse files Browse the repository at this point in the history
  • Loading branch information
foorschtbar committed Oct 9, 2023
1 parent 4afdd2d commit 5085a84
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
43 changes: 43 additions & 0 deletions .github/merge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import os
import shutil

root_dir = '.pio/build'


for item in os.listdir(root_dir):
item_path = os.path.join(root_dir, item)

# Check if the item is a directory and its name starts with "esp32"
if os.path.isdir(item_path) and item.lower().startswith("esp32"):
print(f"Found an 'esp32' directory: {item_path}")

# Check if the directory contains a file which begins with "firmware"
firmware_path = ""
for file in os.listdir(item_path):
if file.lower().startswith("firmware") and not file.lower().find("combined"):
firmware_path = os.path.join(item_path, file)
print(f"> Found a 'firmware' file: {firmware_path}")

# build new filename
directory_path, filename_with_extension = os.path.split(firmware_path)
filename, file_extension = os.path.splitext(filename_with_extension)
firmware_combined_path = os.path.join(directory_path, filename + ".combined" + file_extension)

# copy boot_app0.bin
print(f"> Copying boot_app0.bin to {item_path}...")
shutil.copy(os.path.expanduser("~") + "/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin", item_path)

# merge firmware
print(f"> Merging firmware to {firmware_combined_path}...")
os.system(f"python -m esptool --chip esp32 merge_bin -o {firmware_combined_path} --flash_mode dio --flash_freq 40m --flash_size 4MB 0x1000 {item_path}/bootloader.bin 0x8000 {item_path}/partitions.bin 0xe000 {item_path}/boot_app0.bin 0x10000 {firmware_path}")

# remove unmerged firmware
print(f"> Removing unmerged firmware {firmware_path}...")
os.remove(firmware_path)

print("> Done.")
break

if firmware_path == "":
print("> No firmware file for merging found.")
# python -m esptool --chip esp32 merge_bin -o esp32_uc2_1.bin --flash_mode dio --flash_freq 40m --flash_size 4MB 0x1000 bootloader.bin 0x8000 partitions.bin 0xe000 boot_app0.bin 0x10000 firmware.bin
6 changes: 5 additions & 1 deletion .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,15 @@ jobs:
- name: Install pio and its dependencies 🔧
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
pip install --upgrade platformio esptool
- name: Run PlatformIO build on selected platforms 🏗️
run: platformio run -e ESP8266_generic -e ESP8266_nodemcuv2 -e ESP32_generic -e ESP32_d1_mini32 -e ESP8266_d1_mini -e ESP32_ulanzi

- name: Merge ESP32 firmware to single binaries 🔧
run: |
python .github/merge.py
- name: Upload build artifacts 💾
uses: actions/upload-artifact@v3
with:
Expand Down

0 comments on commit 5085a84

Please sign in to comment.