Skip to main content
Associate II
September 18, 2025
Question

Binary file output format

  • September 18, 2025
  • 6 replies
  • 781 views

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?

6 replies

TDK
Super User
September 18, 2025

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
Technical Moderator
September 18, 2025
"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."
Tesla DeLorean
Guru
September 18, 2025

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 VenmoUp vote any posts that you find helpful, it shows what's working..
Associate II
September 18, 2025

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.

Tesla DeLorean
Guru
September 18, 2025

>>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 VenmoUp vote any posts that you find helpful, it shows what's working..
TDK
Super User
September 18, 2025

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""."
Pavel A.
Super User
September 19, 2025

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

Ask your favorite AI assistant? :)