cancel
Showing results for 
Search instead for 
Did you mean: 

.bss section taking up flash space?

ron239955_stm1
Associate III

Hi all, I have an STM32H743 project that I've been working on. I've worked on a fair amount of projects in STM32CubeIDE in the past, but now I have a problem I haven't encountered before: the linker is putting my .bss section in flash as well as RAM. I'm not sure why an uninitialized section would be placed in flash... I've attached the output from the build analyzer as well as my linker script. The script is almost the default, except that I've added D2/D3 RAM and have moved stack & heap to DTCM. I've used very similar scripts in other projects and BSS ends up only in RAM in those projects.

Can anyone find what I'm doing wrong? Thanks!

 

5 REPLIES 5
Pavel A.
Evangelist III

Can you show any of your other "good" .ld files?

These lines outside of sections blocks  are suspicious:

 . = ALIGN(4);

 

Not sure I'd rely on the memory view to understand what's actually happening

Use an ELF dumping tool like OBJDUMP, OBJCOPY or FROMELF, see what's getting into BITS / NOBITS sections. How large the .BSS foot-print in FLASH actual is vs the amount of RAM being cleared.

The .MAP might also help understand what's going on.

I don't have the fortitude or motivation to fight the .LD syntax and ordering for you, that'll need to be your battle. But it's likely to be something to do with the ordering and attributes that the linker thinks it's working with. It's not using a "best fit" or "multi-pass" approach, but for the most part a linear traversal of rules.

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

Right! Humans should not edit manually makefiles and .ld scripts. In the AI era, this will be beyond capability of a typical human very soon ))

ron239955_stm1
Associate III

Here's an .ld from another project that does the right thing with the bss section. This other project didn't need as much memory, so I didn't need to add D2RAM/D3RAM sections. 

If there's no obvious error to point out, I'll have to dig into this further. I know next to nothing about the .ld format, so I guess it's time to learn!

 

 

Again - try to remove lines " . = ALIGN(4);" that are not within any { section }

(lines 139, 155).