.hex file not getting generated

I’m trying to get .hex file from my code but it’s only giving me .bin and .elf files when i build it. I need .hex file to try my code on wokwi extension.
PlatfromIO is already in latest version and I’ve tried Cleaning and Building again and again but it’s not working at all.

Here’s my platform.ini file :-
platform = ststm32
board = genericSTM32F103RC
framework = arduino
lib_deps = mbed-sergunb/main@0.0.0+sha.21b85706ec2f
build_flags = -fformat=ihex

Anyone have any idea how so solve this problem ? Any help is much appreciated.

The builder script does not build trigger the hex file generation anymore. You have to register a post-action on the generated ELF file that will generate the HEX file. See “Custom HEX from ELF” in


Thanks for your reply sir but i don’t think i quite get what you mean. Sorry but can you please elaborate what you mean please ?

I really appreciate your response sir.

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

# Custom HEX from 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.