cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G431CBU: section `.bss' will not fit in region `RAM'

ValterMatos
Associate II

 

Good morning.
Could anyone tell me about this error and how to resolve it.
C:/ST/STM32CubeIDE_1.19.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3 .rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: Oscillo_STM32G431CBU.elf section `.bss' will not fit in region `RAM'
C:/ST/STM32CubeIDE_1.19.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3 .rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: region `RAM' overflowed by 54928 bytes
I'm using IDE 1.19 to compile the code for a G431CBU
Grateful

Valter Matos

1 ACCEPTED SOLUTION

Accepted Solutions

So you have:

#define ILI9488_TFTWIDTH  	320
#define ILI9488_TFTHEIGHT 	480

and

/**
 * @brief Buffer storing 4-bit color values for each LCD pixel.
 * Each byte represents color information for two adjacent pixels, utilizing 4 bits per pixel
 */
static uint8_t image_buffer[ ILI9488_TFTWIDTH*ILI9488_TFTHEIGHT/2 ] = {0};

which becomes

static uint8_t image_buffer[ 320*480/2 ] = {0};

320*480/2 = 76800 bytes !

ie, 75K bytes

 

Which is exactly what @KnarfB said earlier - from the map file.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

View solution in original post

58 REPLIES 58
mƎALLEm
ST Employee

Hello,

region `RAM' overflowed by 54928 bytes

Maybe you declared a large table in the RAM..

Use const for the table declaration to relocated it into the flash if that table content keeps unchanged in your application 

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.
Andrew Neil
Super User

The key part of the message is:

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

It's telling you that your code uses more RAM than is available on the chip.

Specifically:

region `RAM' overflowed by 54928 bytes

It needs 54,928 more bytes.

The STM32G431CBU has 128K 32K bytes of RAM; your code is using 54K more than that - so about 182K 86K total.

You have 2 choices:

  1. Reduce the amount of RAM your code uses;
  2. Choose a different chip - with >182K RAM.

 

Correction: The chip has only 32K RAM - see post below by @KnarfB 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

It's a relatively small code, without many tables, and I still don't know how to optimize it.


@ValterMatos wrote:

without many tables, 


It's not about the number - it's about the total amount of RAM that they occupy...

 


@ValterMatos wrote:

I still don't know how to optimize it.


Nobody can help you without seeing the code!

How to insert source code

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

@ValterMatos wrote:

It's a relatively small code, without many tables, and I still don't know how to optimize it.


You can saturate the memory with one large table.

Check these tables' sizes..

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.

> It's a relatively small code, without many tables, and I still don't know how to optimize it.

Then you can probably share it here.
Because a 54928 bytes overflow is a lot - but you can "achieve" it with one single definition ...

Or the map file, it it's enabled and the toolchain created one.

It's a relatively small code for the G431, without large tables.
Perhaps the DMA usage is using too much RAM.
I haven't been able to figure out the cause yet.
I've attached the compressed file.

Thank you.

 

DMA doesn't consume RAM per se.
You just configure previously defined buffers as source or target addresses.

On a loosely related note, the recently displayed message "Virus scan in progress..." for attachments suggests no such scan had been in place before ...

Unfortunately, your project is stuck in the virus scan:

AndrewNeil_0-1765378161607.png

See: Attachments stuck on "virus scan in progress..."

 


@ValterMatos wrote:

It's a relatively small code


So just post the code, then?

See: How to insert source code

 

Does the build generate a Linker Listing (aka "map") file?

Does the CubeIDE Build Analyzer work?

https://forum.digikey.com/t/utilizing-the-build-analyzer-in-stm32cubeide/3882

https://www.st.com/resource/en/user_manual/um2609-stm32cubeide-user-guide-stmicroelectronics.pdf#page=125

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.