Skip to main content
Associate II
Jul 8, 2024 6:37 AM UTC
Solved

Hex file: adding dummy bytes - STM32 Cube IDE - GNU/LD

within the STM32 Cube IDE After creating a hex file, I noticed that some lines had less data than others due to linker separation. How can I use the STM32 Cube IDE to add dummy bytes to the memory?

Sanjay8344_0-1720420608647.png

 

This topic has been closed for replies.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
Jul 9, 2024 5:38 PM UTC

ALIGN(8) instead of ALIGN(4) at the end of each section ?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..

12 replies

AScha.3
Super User
Jul 8, 2024 7:09 AM UTC

> that some lines had less data than others

Thats "normal" in a (Intel-)HEX file.

see:

https://developer.arm.com/documentation/ka003292/latest/

 

>to add dummy bytes to the memory

Why ?

If you feel a post has answered your question, please click on " Best Answer ".
Associate II
Jul 8, 2024 8:27 AM UTC

In order to extract data from a hex file and write it into memory while working on the bootloader, I must do a remote update. In order to accomplish this, I must write 0xffff in a location where there is less data on the specific lines. I now know that the linker script can be used to change it but not How to do that.

Associate III
Jul 9, 2024 7:21 AM UTC

Other (better) hex generators will add fill bytes for you but I could not see a way to do that here.

Instead you can use fill statements in your linker script as you already understood. There is a nice summary here about how to proceed:

FILLing unused Memory with the GNU Linker | MCU on Eclipse

Ayoub Cheggari
Senior
Jul 9, 2024 3:08 PM UTC

You can do that without postbuild in the linker script and fill the sections by using Align command!

Associate II
Jul 9, 2024 4:50 PM UTC

Sanjay8344_0-1720543631547.png

When I flashed the .hex file with the STM 32 utility, it automatically divided into two halves and was written appropriately. And I need to write 0xFFFFFFFF at that specific spot if I want to write it manually using the bootloader.

 

Ayoub Cheggari
Senior
Jul 10, 2024 8:59 AM UTC

There is no way that a file is changed by a tool! As I said before, you need to check which section ends at 0x800017C and use ALIGN to make sure it fits there!