In your platformio.ini
, add
extra_scripts = post:extra_script.py
At the same directory level as the platformio.ini
, create a new extra_script.py
file and fill it with the content
Import("env")
# Custom HEX from ELF
env.AddPostAction(
"$BUILD_DIR/${PROGNAME}.elf",
env.VerboseAction(" ".join([
"$OBJCOPY", "-O", "ihex", "-R", ".eeprom",
"$BUILD_DIR/${PROGNAME}.elf", "$BUILD_DIR/${PROGNAME}.hex"
]), "Building $BUILD_DIR/${PROGNAME}.hex")
)
After a new clean build (project task → Clean, Build), the .pio/build/<env>
folder should have firmware.hex
.