2018-08-20 03:01 AM
Can a hex and bin files be generated from each other?
2018-08-20 03:30 AM
Not in a strict sense. After downloading it, it is not a HEX file anymore, just binary Flash contents.
But yes, if no readout-protection is enabled, you can read it back, and save it to a file.
Consult the help documentation of your toolchain.
I think the ST-Link utility can do this as well.
2018-08-20 08:54 AM
.HEX .S19 or .BIN files can be used to describe the same data. The hex files tend to be larger, but can be sparse (not describe empty locations), and out-of-order.
Several tools can convert between formats, ie BIN2HEX, HEX2BIN, SRECORDS, etc. The formats are not inherently complicated.
ST-LINK and DFU tools can be used to pull the data from a device that isn't protected. STM32 CubeProgrammer GUI seems to lack the feature to save by command line version can.
Keil debugger have SAVE command.