cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103RB - Heap and Stack Collision

michaelsauer9
Associate II
Posted on October 21, 2014 at 11:29

Hi,

i tried on my F103RB to create 4 Arrays with 512 entries and 3 byte wide.

Should be calculated as 6144 byte. So i tried it to create but i only got Heap and Stack collision. Is there a possibility to move this arrays to the flash?

I tried it with some section creating in linker script and defined the arrays with __ATTRIBUTE__ but i cannot figure it out.

Here are the definitions of the arrays and the struct.

#define  WS2812_LED_MAX_ANZ 512

WS2812_RGB_t WS2812_LED_BUF_CH1[WS2812_LED_MAX_ANZ];

WS2812_RGB_t WS2812_LED_BUF_CH2[WS2812_LED_MAX_ANZ];

WS2812_RGB_t WS2812_LED_BUF_CH3[WS2812_LED_MAX_ANZ];

WS2812_RGB_t WS2812_LED_BUF_CH4[WS2812_LED_MAX_ANZ];

typedef struct

{

uint8_t red;    // 0...255 (als PWM-Wert)

uint8_t green;  // 0...255  (als PWM-Wert)

uint8_t blue;   // 0...255 (als PWM-Wert)

} WS2812_RGB_t;

/opt/arm/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/bin/ld: MagicLightController.elf section `.bss' will not fit in region `RAM'

/opt/arm/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/bin/ld: region `RAM' overflowed by 12932 bytes

And here is the Linker Script im using. Without my section defines.

Its in attached file

3 REPLIES 3
frankmeyer9
Associate II
Posted on October 21, 2014 at 11:39

Is there a possibility to move this arrays to the flash?

A declaration as

const

usually does fine, independant of the underlying toolchain. But you need to initializ eall required items, then.

For example :

WS2812_RGB_t WS2812_LED_BUF_CH1[WS2812_LED_MAX_ANZ] = {{R1,G1,B1},{...}, ... };

michaelsauer9
Associate II
Posted on October 21, 2014 at 11:51

Ok, but const defines a constant and the array i fergot to describe is a array with fixed size but dynamic entries. So it wont work with const i think. But if i move this array to flash and the flash is not so often writeable as the ram. Humm i got too few RAM i think :(

frankmeyer9
Associate II
Posted on October 21, 2014 at 12:41

Ok, but const defines a constant and the array i fergot to describe is a array with fixed size but dynamic entries. So it wont work with const i think.

It wouldn't work then, for sure. But that wasn't obvious from your initial post.

Humm i got too few RAM i think :(

Switching to a MCU with more RAM is an option.

Have you checked the memory layout of your arrays ?

Since each struct occupies 3 bytes, I expect the compiler to word-align it, wasting 1/4 of it's RAM size. Something like gcc's ''

__attribute__(packed)

'' might help then.