Skip to content

Commit d531d6c

Browse files
authored
Merge pull request #2 from cjkas/scz/123
Scz/123
2 parents 6a28589 + 84e713d commit d531d6c

16 files changed

Lines changed: 458 additions & 571 deletions

.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ jobs:
3636
with:
3737
python-version: "3.12"
3838

39-
- name: Install PlatformIO
40-
run: pip install platformio
39+
- name: Install PlatformIO and esptool
40+
run: pip install platformio esptool
4141

4242
- name: Build firmware
4343
run: pio run -e ${{ matrix.env }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ data/
1414
build/
1515
coredump_report.txt
1616
coredump.bin
17-
logs/
17+
logs/
18+
elf_archive/

archive_elf.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"""
2+
PlatformIO post-build script: archive firmware.elf files.
3+
4+
Copies firmware.elf to elf_archive/ with a timestamp after each build.
5+
Keeps only the last 10 files to avoid filling up disk space.
6+
7+
Usage in platformio.ini
8+
-----------------------
9+
extra_scripts = post:archive_elf.py
10+
"""
11+
12+
Import("env")
13+
14+
import os
15+
import shutil
16+
from datetime import datetime
17+
18+
MAX_ARCHIVES = 10
19+
ARCHIVE_DIR = os.path.join(env.subst("$PROJECT_DIR"), "elf_archive")
20+
21+
22+
def archive_elf(source, target, env):
23+
elf_path = os.path.join(env.subst("$BUILD_DIR"), "firmware.elf")
24+
if not os.path.isfile(elf_path):
25+
print("[archive_elf] firmware.elf not found, skipping.")
26+
return
27+
28+
os.makedirs(ARCHIVE_DIR, exist_ok=True)
29+
30+
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
31+
dest = os.path.join(ARCHIVE_DIR, f"firmware_{timestamp}.elf")
32+
shutil.copy2(elf_path, dest)
33+
print(f"[archive_elf] Saved {dest}")
34+
35+
# Keep only the last MAX_ARCHIVES files
36+
files = sorted(
37+
[f for f in os.listdir(ARCHIVE_DIR) if f.endswith(".elf")],
38+
)
39+
while len(files) > MAX_ARCHIVES:
40+
old = os.path.join(ARCHIVE_DIR, files.pop(0))
41+
os.remove(old)
42+
print(f"[archive_elf] Removed old archive {old}")
43+
44+
45+
env.AddPostAction("$BUILD_DIR/firmware.elf", archive_elf)

platformio.ini

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,39 @@
11
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter
4+
; Upload options: custom upload port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
; Advanced options: extra scripting
7+
;
8+
; Please visit documentation for the other options and examples
29
; https://docs.platformio.org/page/projectconf.html
310

411
[platformio]
5-
default_envs = esp32dev
12+
default_envs = esp32devdbg
613

7-
; Shared settings for all environments
814
[env]
915
platform = espressif32
1016
framework = arduino
11-
lib_deps =
17+
lib_deps =
1218
bblanchon/ArduinoJson@^7.2.2
1319
lsatan/SmartRC-CC1101-Driver-Lib@^2.5.7
1420
knolleary/PubSubClient@^2.8
1521
esp32async/ESPAsyncWebServer@^3.10.3
1622
esp32async/AsyncTCP@^3.4.10
17-
extra_scripts = pre:minify.py
23+
extra_scripts =
24+
pre:minify.py
25+
post:archive_elf.py
1826
board_build.partitions = huge_app.csv
1927
board_build.filesystem = littlefs
2028
build_flags =
29+
-DCORE_DEBUG_LEVEL=3
2130
-DCONFIG_ESP_COREDUMP_ENABLE_TO_FLASH=1
2231
-DCONFIG_ESP_COREDUMP_DATA_FORMAT_ELF=1
2332
-DCONFIG_ESP_COREDUMP_CHECKSUM_CRC32=1
2433
-DCONFIG_ESP_TASK_WDT_PANIC=1
2534
-DCONFIG_ESP_COREDUMP_DECODE_INFO=1
2635
monitor_speed = 115200
27-
monitor_filters =
36+
monitor_filters =
2837
time
2938
esp32_exception_decoder
3039
log2file
@@ -35,5 +44,3 @@ board = esp32dev
3544
[env:esp32devdbg]
3645
board = esp32dev
3746
build_type = debug
38-
39-

0 commit comments

Comments
 (0)