Electrical – Generate and flash a binary file for STM32

bootloaderembeddedstm32

I created a bootloader image for my STM32 and I stored it in a specific area of the memory. I have a new Keil project which represents the application layer. By default, Keil generates a HEX file. What I want to do is to keep the bootloader image and flash the application layer in another area in the memory. The final FW will verify a GPIO input. If it is in a high level, the bootloader image will be launched and it will upgrade the application layer with a new image, otherwise (The GPIO input is in a low level), The normal mode is activated and the application will run. My question is:

  1. Should I convert the generated Hex file of the application layer to a BIN file in order to flash it to a specific area of the memory?
  2. How Can I specify the start address the application layer and its length ?.
  3. If I use a tool to convert a HEX file to binary, what should I do with the empty address reserved for the bootloader image ?

Best Answer

  1. That depends on your bootloader application. Can it read HEX files?
  2. You use the target dialog in the target options, or a scatter loading file.
  3. You do not include empty regions this in the image. Keil includes a tool to create binary files.

Note that you might want to sign your binary file with a checksum. The arm linker cannot do this. But you can do this with SRecord. (also removing/converting regions)