mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-21 21:06:10 +02:00
merge development03
This commit is contained in:
parent
1af142c46e
commit
aa9da851a1
67 changed files with 2607 additions and 967 deletions
BIN
scripts/__pycache__/htmlPreprocessorDefines.cpython-311.pyc
Normal file
BIN
scripts/__pycache__/htmlPreprocessorDefines.cpython-311.pyc
Normal file
Binary file not shown.
79
scripts/add_littlefs_binary.py
Normal file
79
scripts/add_littlefs_binary.py
Normal file
|
@ -0,0 +1,79 @@
|
|||
import os
|
||||
import subprocess
|
||||
import shutil
|
||||
from SCons.Script import DefaultEnvironment
|
||||
Import("env")
|
||||
|
||||
|
||||
def build_littlefs():
|
||||
if os.path.isfile('data/settings.json') == False:
|
||||
return # nothing to do
|
||||
|
||||
result = subprocess.run(["pio", "run", "--target", "buildfs", "--environment", env['PIOENV']])
|
||||
if result.returncode != 0:
|
||||
print("Error building LittleFS:")
|
||||
exit(1)
|
||||
else:
|
||||
print("LittleFS build successful")
|
||||
|
||||
def merge_bins():
|
||||
if os.path.isfile('data/settings.json') == False:
|
||||
return # nothing to do
|
||||
|
||||
BOOTLOADER_OFFSET = 0x0000
|
||||
PARTITIONS_OFFSET = 0x8000
|
||||
FIRMWARE_OFFSET = 0x10000
|
||||
|
||||
if env['PIOENV'][:13] == "esp32-wroom32":
|
||||
BOOTLOADER_OFFSET = 0x1000
|
||||
|
||||
flash_size = int(env.BoardConfig().get("upload.maximum_size", "1310720")) # 0x140000
|
||||
app0_offset = 0x10000
|
||||
if env['PIOENV'][:7] == "esp8266":
|
||||
app0_offset = 0
|
||||
elif env['PIOENV'][:7] == "esp8285":
|
||||
app0_offset = 0
|
||||
|
||||
littlefs_offset = 0x290000
|
||||
if flash_size == 0x330000:
|
||||
littlefs_offset = 0x670000
|
||||
elif flash_size == 0x640000:
|
||||
littlefs_offset = 0xc90000
|
||||
|
||||
# save current wd
|
||||
start = os.getcwd()
|
||||
os.chdir('.pio/build/' + env['PIOENV'] + '/')
|
||||
|
||||
with open("bootloader.bin", "rb") as bootloader_file:
|
||||
bootloader_data = bootloader_file.read()
|
||||
|
||||
with open("partitions.bin", "rb") as partitions_file:
|
||||
partitions_data = partitions_file.read()
|
||||
|
||||
with open("firmware.bin", "rb") as firmware_file:
|
||||
firmware_data = firmware_file.read()
|
||||
|
||||
with open("littlefs.bin", "rb") as littlefs_file:
|
||||
littlefs_data = littlefs_file.read()
|
||||
|
||||
with open("firmware.factory.bin", "wb") as merged_file:
|
||||
merged_file.write(b'\xFF' * BOOTLOADER_OFFSET)
|
||||
merged_file.write(bootloader_data)
|
||||
|
||||
merged_file.write(b'\xFF' * (PARTITIONS_OFFSET - (BOOTLOADER_OFFSET + len(bootloader_data))))
|
||||
merged_file.write(partitions_data)
|
||||
|
||||
merged_file.write(b'\xFF' * (FIRMWARE_OFFSET - (PARTITIONS_OFFSET + len(partitions_data))))
|
||||
merged_file.write(firmware_data)
|
||||
|
||||
merged_file.write(b'\xFF' * (littlefs_offset - (FIRMWARE_OFFSET + len(firmware_data))))
|
||||
merged_file.write(littlefs_data)
|
||||
|
||||
os.chdir(start)
|
||||
|
||||
def main(target, source, env):
|
||||
build_littlefs()
|
||||
merge_bins()
|
||||
|
||||
# ensure that script is called once firmeware was compiled
|
||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", main)
|
|
@ -28,8 +28,8 @@ def applyPatch(libName, patchFile):
|
|||
# list of patches to apply (relative to /src)
|
||||
applyPatch("ESPAsyncWebServer-esphome", "../patches/AsyncWeb_Prometheus.patch")
|
||||
|
||||
if env['PIOENV'][:13] == "opendtufusion":
|
||||
applyPatch("GxEPD2", "../patches/GxEPD2_SW_SPI.patch")
|
||||
if (env['PIOENV'][:5] == "esp32") or (env['PIOENV'][:13] == "opendtufusion"):
|
||||
applyPatch("GxEPD2", "../patches/GxEPD2_HAL.patch")
|
||||
|
||||
if (env['PIOENV'][:13] == "opendtufusion"): # or (env['PIOENV'][:13] == "esp32-wroom32"):
|
||||
if (env['PIOENV'][:13] == "opendtufusion") or (env['PIOENV'][:5] == "esp32"):
|
||||
applyPatch("RF24", "../patches/RF24_Hal.patch")
|
||||
|
|
|
@ -27,11 +27,22 @@ def getFlagsOfEnv(env):
|
|||
elif len(flags[i]) > 0:
|
||||
build_flags = build_flags + [flags[i]]
|
||||
|
||||
def parseDefinesH():
|
||||
global build_flags
|
||||
pattern = r'^\s*#\s*define\s+(\w+)'
|
||||
|
||||
with open("defines.h", "r") as f:
|
||||
for line in f:
|
||||
match = re.match(pattern, line)
|
||||
if match:
|
||||
build_flags += [match.group(1)]
|
||||
|
||||
|
||||
def get_build_flags():
|
||||
getFlagsOfEnv("env:" + env['PIOENV'])
|
||||
config = configparser.ConfigParser()
|
||||
config.read('platformio.ini')
|
||||
parseDefinesH()
|
||||
|
||||
# translate board
|
||||
board = config["env:" + env['PIOENV']]['board']
|
||||
|
|
|
@ -76,8 +76,9 @@ def renameFw(path_define, env):
|
|||
fname = version[:-1] + "_" + sha + "_" + env + ".bin"
|
||||
|
||||
os.rename("src/.pio/build/" + env + "/firmware.bin", dst + fname)
|
||||
os.rename("src/.pio/build/" + env + "/firmware.elf.7z", dst + fname[:-3] + "elf.7z")
|
||||
|
||||
if env[:5] == "esp32":
|
||||
if env[:5] == "esp32" or env[:4] == "open":
|
||||
os.rename("src/.pio/build/" + env + "/bootloader.bin", dst + "bootloader.bin")
|
||||
os.rename("src/.pio/build/" + env + "/partitions.bin", dst + "partitions.bin")
|
||||
genOtaBin(dst)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue