cancel
Showing results for 
Search instead for 
Did you mean: 

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

MImda.1
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

4 REPLIES 4
Uwe Bonnes
Principal III

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

Pavel A.
Evangelist III

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
Associate III

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?

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