cancel
Showing results for 
Search instead for 
Did you mean: 

Understanding the STM32F4 Linker Script for GCC?

Terence D
Senior
Posted on January 18, 2018 at 03:32

I have an STM32F429 dev board.  I've been playing around with the GCC version of the STemWin example that comes with the STM32CubeF4 package.  I've tweaked the Hello World example to do something entirely different - making some animated graphics appear on the STM32F429 LCD screen. 

I'm now trying to use the 

GUI_MEMDEV_

functions.  In order to create a

MEMDEV

of the entire LCD screen I need to increase the size of the 

GUI_NUMBYTES &sharpdefine

in GUIConf.c.  When doing so, I get the following GCC linker error:

STM32F429I_DISCO_MB1075.elf section `.bss' will not fit in region `RAM'

So, I understand I need to increase the size of the BSS section.  This is where I run into problems.  I understand bits and pieces of the linker script but I'm far from being an expert.

For example, the linker script has the following at the top:

MEMORY

{

RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K

CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K

FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K

}

It's my understanding I need to increase the size of the RAM section.  However, I'm not sure if this is possible.  My understanding is the STM32F429 has 256K of RAM.  However, I'm guessing that the 64K of CCMRAM plus the 192K of regular RAM equals all 256K of the RAM available???

Does the CCMRAM section contribute to the BSS?  Can I get rid of the CCMRAM section and just make the RAM section 256K?  If I do lengthen the RAM memory section to 256K do I need to change the origin value?  I'm guessing the RAM ranges up from the origin, right?  Meaning that it ranges from 0x20000000 to 0x20030000, right?

What a lot of this seems to come down to is my lack of understanding the GCC linker script specification.  Googling is not turning up much helpful info.  Anyone know where I can find documentation on this?

#stm32f4 #linker-script
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on January 18, 2018 at 03:58

The regions aren't contiguous, and you can't DMA from the CCMRAM, so combining them isn't an option.

On the STM32F429I-DISCO, you have SDRAM, you should use that for the frame buffer. You'd need to initialize the SDRAM before the startup code can use it can copy data there.

Latter parts of the linker script direct specific sections into specific regions, this can also be done at an object file level. From the compiler side you can direction variables into sections using the attribute directive. I'd dig up some examples but the forum is broken.

You might want to look a Keil's Scatter Files, these perform a similar function, and might be better documented.

There is probably a 'man page' for the GNU linker, but usually looking at multiple examples and adapting them

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

View solution in original post

2 REPLIES 2
Posted on January 18, 2018 at 03:58

The regions aren't contiguous, and you can't DMA from the CCMRAM, so combining them isn't an option.

On the STM32F429I-DISCO, you have SDRAM, you should use that for the frame buffer. You'd need to initialize the SDRAM before the startup code can use it can copy data there.

Latter parts of the linker script direct specific sections into specific regions, this can also be done at an object file level. From the compiler side you can direction variables into sections using the attribute directive. I'd dig up some examples but the forum is broken.

You might want to look a Keil's Scatter Files, these perform a similar function, and might be better documented.

There is probably a 'man page' for the GNU linker, but usually looking at multiple examples and adapting them

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 18, 2018 at 04:11

This is a replacement for the SPL's system_stm32f4xx.c file which I modified to initialized the SDRAM of the STM32F429I-DISCO board via SystemInit(), I did this back in Jan-2014 so probably needs to be reworked into more current examples.

https://docs.google.com/file/d/0B7OY5pub_GfISU9vOTlZa3ItMDQ/edit

 

I had some GNU/GCC builds too, will need to dig those out, and bring up to date.

The linker script would need to describe the 0xD0000000 8MB region used by the SDRAM, and the heap allocator changed so as not to use the stack as an upper limit for the heap. You'd want to keep the stack in the SRAM or CCMRAM due to the slowness of the SDRAM in relative terms.

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