If the STM32F1 series in Aeduino ide 2.3.4 can output hex files

Hello, I would like to ask if the STM32F1 series in Aeduino ide 2.3.4 can output hex files. I am currently completing my assignment, but I have noticed that it seems unable to generate hex files. A netizen suggested that I use a preference. txt file for conversion, but after checking, I found that the 2XX version of Arduino ide can no longer find this file in the preference section. I confirm to have read the privacy policy and to accept the terms of service. How can we help you?

Hi @lingyu.

Yes.

Maybe their advice made sense in the context under which they wrote it, but it is nonsense in this context. Arduino IDE 2.3.4 doesn't use a preferences.txt file. Arduino IDE 1.x does use a file of that name, but even when using Arduino IDE 1.x, it would not be necessary to work with that file directly in order to accomplish your goal.

I'll provide instructions you can follow to obtain the hex file generated by compiling a sketch for an STM32F1 series board in Arduino IDE:

  1. Open the sketch for which you want to generate a hex file in Arduino IDE.
  2. Select the appropriate board from Arduino IDE's Tools > Board menu.
  3. Select the appropriate options for any other submenus of Arduino IDE's "Tools" menu (e.g., Tools > Board part number).
  4. Select Sketch > Export Compiled Binary from Arduino IDE's menus.
    A compilation will start.
  5. Wait for the compilation to finish successfully.
  6. Select Sketch > Show Sketch Folder from the Arduino IDE menus.
    The folder of the sketch you have open in Arduino IDE will open in your file browser.
  7. Navigate to the build subfolder of the sketch folder.
  8. Navigate down one more subfolder level.
    This subfolder will be named according to the machine identifier for the board you compiled for (e.g., STMicroelectronics.stm32.GenF1).

You will not see a .hex file, as well as the other files that were generated by the compilation.

Rather "You will now see" :wink:

1 Like



Thank you very much for your help! Although I have tried this method before, I tried again and there is still no hex file in the document. I don't know if there were any other mistakes.

Do you specifically need the HEX file? The BIN file basically contains the same information (just not human readable) and can be used to program your device.

You can also convert BIN to HEX if you know which HEX format is expected (Intel, Motorola, ...).

Yes, I need hex files to simulate in Proteus. I have also tried using tools to convert formats, but it seems that the conversion is not quite correct. I want to try to solve the problem from the source.

Probably better to convert the .elf file to a .hex; it’ll have more info about the data. I don’t know exactly what options you’ll need for objconv to make st32 programming tools happy with the results, though.

I assumed you were using the popular "STM32 MCU based boards" platform (AKA "STM32duino"). That platform is configured to produce a .hex file in addition to the .bin, .elf, and .map files.

However, I can see from the screenshot you shared that you are instead using the alternative "STM32F1xx/GD32F1xx boards" platform from Roger Clark. This platform does not generate the .hex file.

So one possible solution would be to switch to using the actively maintained "STM32 MCU based boards" platform. If you want to do that, you can follow the instructions here to install it in Arduino IDE:

https://github.com/stm32duino/Arduino_Core_STM32/wiki/Getting-Started#add-stm32-boards-support-to-arduino

If you do want to continue using the "STM32F1xx/GD32F1xx boards" platform, then you would need to generate the .hex file yourself, as explained by @sterretje and @westfw.

Oh, I tried replacing it with "STM32 MCU based boards" and it really worked! Thank you so much!!!

You are welcome. I'm glad it is working now.

Regards, Per

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.