2021-01-30 07:42 AM
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
Solved! Go to Solution.
2021-01-31 06:29 AM
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
2021-01-30 08:26 AM
Binfiles have no metadata. It is meant to put into flash at the right starting address without ant morphing.
2021-01-30 09:50 AM
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
2021-01-30 05:42 PM
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?
2021-01-31 06:29 AM
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