Files
ESPEasy/tools/pio/post_esp32.py
T
Gijs Noorlander 784404792c [PIO] Generate filename at build, not in post processing
Generate filename, included in the build
Use post Python scripts to move files to the right directory
Use post Python scripts to generate .bin.gz files.
2020-05-03 01:05:20 +02:00

24 lines
797 B
Python

Import("env")
def esp32_create_factory_bin(source, target, env):
print("Generating factory bin for genuine esp units")
#offset = 0x1000
offset = 0x0
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}-factory.bin")
sections = env.subst(env.get('FLASH_EXTRA_IMAGES'))
new_file = open(new_file_name,"wb")
for section in sections:
sect_adr,sect_file = section.split(" ")
source = open(sect_file,"rb")
new_file.seek(int(sect_adr,0)-offset)
new_file.write(source.read());
source.close()
firmware = open(env.subst("$BUILD_DIR/${PROGNAME}.bin"),"rb")
new_file.seek(0x10000-offset)
new_file.write(firmware.read())
new_file.close()
firmware.close()
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_factory_bin)