PlatformIO Community

Export compiled hex file

Hello,
I’m all new to platformio and I’d like to use it for my Arduino boards replacing the Arduino IDE.
Is it possible to export compiled binary hex files?
On Arduino I select Sketch > Export compiled Binary and I get 2 hex files, with and without bootloader.

1 Like

Hi,

Sure, check a hidden .pioenvs directory in the project.

Thank you, I found the firmware.hex so I’m guessing that’s what I need.

I just found the firmware.bin wtihout hex,How I need to setup ? Please tell me

Whats your platformio.ini?

[env:genericSTM32F103ZE]

platform = ststm32
framework = stm32cube
board = genericSTM32F103ZE
upload_speed = 115200
upload_port = COM4
upload_protocol =serial

It‘s my setup . I was generated success, but can’t find .hex file

You’re right, by default they only build the .bin file. To change this, go into your PlatformIO folder (/home/<user>/.platform or C:\Users\<user>\.platform and open packages/ststm32/builder/main.py and change

    target_firm = env.ElfToBin(join("$BUILD_DIR", "${PROGNAME}"), target_elf)

to

    target_firm = env.ElfToHex(join("$BUILD_DIR", "${PROGNAME}"), target_elf)

and rebuild. The resulting hex file will be in .pioenvs/genericSTM32F103ZE/firmware.hex.

@ivankravets Maybe it’s good feature to be able to change what builder will be used via the platformio.ini?

2 Likes

@Weeeendi please file a feature request here https://github.com/platformio/platform-ststm32/issues

1 Like

Thanks for your help,and I hope create this feature too.

1 Like

Thanks,But I also want to know why I choose serial upload failed.what differents have between

common ISP upload and using upload_protocol = serial in platformio.ini

So I did this change, but it still saves it as a .elf file when compiling. Any ideas what I’ve done wrong? I’ve tried restarting vcode etc.

For which platform are you compiling, what’s your platformio.ini?

Hi Max,

I’m trying to compile Marlin 2.0 for the Fysetc Cheetah 1.1 with the STM32 chip. First time working with VScode and Platformio though, so it’s all new to me. lol.

Here’s info from platformio.ini:

[platformio]
src_dir = Marlin
boards_dir = buildroot/share/PlatformIO/boards
default_envs = STM32F103RC_fysetc

I finally got PlatformIO to produce a hex file, but I can’t find the file. what is pioenvs under? I have looked everywhere and can’t find it. I’m afraid I don’t have that file.

Never mind I just looked in the terminal

Note that .pioenvs is outdated, in recent PlatformIO versions the build folder is .pio\build\<environment name>. You should also be using an extra script + post action to generate the .hex now, not platform code modifications, see docs.