-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4afdd2d
commit 5085a84
Showing
2 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters