Skip to main content
MImda.1
Associate II
January 30, 2021
Solved

What information stores in the .bin file and where exactly they are stored in stm32 firmware?

  • January 30, 2021
  • 4 replies
  • 3245 views

I want to keep 2 application files inside the flash and jump to either using a command. When using the STM32 cubeIDE for development, the .bin file is generated under debug folder. I couldn't find the .hex file though. I want to know what is the metadata that is included in the .bin file and where they are. In one of the documents I read, it said the first address contains the magic number, then firmware size, firmware header size, and so on. How can I know exactly what are they and where it is stored in a firmware file. thank you

This topic has been closed for replies.
Best answer by Pavel A.

If you are a newbie, you're missing a lot ;)

The debugger is your best friend, get to know and use it.

Step by-instruction thru the above code, do you arrive to the first instruction of your program - the reset handler in startup_xxxx.s?

Next, do you arrive to SystemInit() and main() ?

-- pa

4 replies

Uwe Bonnes
Chief
January 30, 2021

Binfiles have no metadata. It is meant to put into flash at the right starting address without ant morphing.

Pavel A.
January 30, 2021

Linker scripts in typical GCC projects are cleverly composed so that all code and data make one contiguous array.

Conversion to binary extracts this array to a file. It does not add or change a single bit.

Some other IDEs such as IAR may add a checksum but not CubeIDE. It does not do anything else.

However, the first several words in the image are the stack address and vectors,

from this one can guess the base address of the image and what memory it uses for stack.

-- pa

MImda.1
MImda.1Author
Associate II
January 31, 2021

Thank you for your response. I am actually a newbie. I used this code in the bootloader to jump to my application. But it didn't work. this is the general code snippet that is used for jumping. what am I missing?

 typedef void (*pFunction)(void);
 
 pFunction JumpToApplication;
 uint32_t JumpAddress;
 
 JumpAddress = *(__IO uint32_t*) (PROG_ADDRESS_START+4);
 JumpToApplication = (pFunction) PROG_ADDRESS_START;
 __set_MSP(*(__IO uint32_t*) PROG_ADDRESS_START);
 JumpToApplication();

i used bin files to upload using cube programmer. so according to your answers, it does not contain any info. so in that case jump address may not be valid. but SP is correct. what am I missing?

Pavel A.
Pavel A.Best answer
January 31, 2021

If you are a newbie, you're missing a lot ;)

The debugger is your best friend, get to know and use it.

Step by-instruction thru the above code, do you arrive to the first instruction of your program - the reset handler in startup_xxxx.s?

Next, do you arrive to SystemInit() and main() ?

-- pa