I am building a firmware updater for an STM32 MCU. I have so far programmed bootloader software on the device, separate from the main application in FLASH.
What I need to do is generate a binary file which will be the replacement code for the main application in FLASH. This means I can transfer the file over UART and overwrite the main application. How do I go about producing such a file?
The code was programmed using the stm32CubeIDE which generates an .elf file after building. I will add a header to this binary code before transmitting over UART.
Thank you very much in advance for your help,
Harry
In CubeIDE go to Project Settings -> "C/C++ Build" group -> Settings -> "Tool Settings" tab -> MCU Post build outputs -> "Convert to Intel Hex file" check box
(If you do not see those options, you may need to restart the IDE - such a bug still exists)
This will make the IDE convert the output into HEX-file, which is easily parsable. You can find the format description in Wikipedia. You can parse it before sending to the bootloader.
Or, you can set the checkbox "Convert to binary file", which will make a raw binary file. But it may give some troubles if your code starts not from zero address.