cancel
Showing results for 
Search instead for 
Did you mean: 

Binary file output format

Armageddon
Associate III

Hello,

I want to create my own bootloader for STM32L4xxx, but I can't find any documentation explaining how the binary file generated during compilation on STM32CubeIDE is formatted.

I have a rough idea of how it's done, but I would like to have documentation that clarifies its formatting si I can decode it.

Do you know where I can find this documentation, please?

7 REPLIES 7
TDK
Super User

The *.BIN file is raw data. There is no formatting or extra metadata. It's exactly what gets put into flash when you upload it.

If you feel a post has answered your question, please click "Accept as Solution".
mƎALLEm
ST Employee

What is the format of .bin output files?

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

It's just the data as reflected in memory, so basically Data Representation 101

The objcopy output will the content starting at whatever the memory basis you put in the linker script, so perhaps 0x08001000 for an app, and 0x08000000 for the primary loader.

Perhaps use OBJCOPY or OBJDUMP, or FROMELF type tools to inspect / dump the content of you ELF "object file"

Use STM32 Cube Programmer to Inspect the content of memory, or write some simple memory dumping subroutines so you can inspect outside of the debugger.

Perhaps look to college level text's on "LINKERS, LOADERS, COMPILERS and ASSEMBLERS"

.HEX files have more documentation / formatting, as they pass address information along with the data, and ASCII representation, which means type likely be around 2.5x larger than the binary data they are communicating.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Armageddon
Associate III

Thank you, I think I confused it with another type of binary file from another manufacturer.

I looked at the debug and it's exactly as you say.

But I'm still puzzled that the only source of information for finding out the format of a binary file is on forums.

I'll try to dig around on the GNU side, but there must be a document on the subject.

Just understand that it's not that I don't believe you, you know more about this subject than I do. But in business and in certain situations, referencing a forum is not reliable.

TDK
Super User

It is probably stated in the GCC linker documentation. "Raw binary" is a pretty standard format.

If you feel a post has answered your question, please click "Accept as Solution".

>>But I'm still puzzled that the only source of information for finding out the format of a binary file is on forums.

How data is represented in files, and in memory, is something I learned in secondary school as a teen-ager. That and how code/data is held in ROMs and how MCU execute that code.

A binary file is just a sequence of bytes. That it exists at a specific address in memory is inferred or implied.

It's not really an STM32 thing, more of a foundational concept for computers.

Perhaps look for things describing computer forensics, as this will be illustrative of file content and inspection of the data within the file.

If you look at a text file, say .C or .TXT, you'll see a similar stream of bytes, but they'll primarily describe values within the ASCII range, including character symbols for "Line Feed" and "Carriage Return", etc.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Pavel A.
Super User

But in business and in certain situations, referencing a forum is not reliable.

Ask your favorite AI assistant? :)