cancel
Showing results for 
Search instead for 
Did you mean: 

How to use RAM_D1 with CubeMX and STM32CubeIDE?

fb
Associate III

I've implemented a hello world project, by just using the default settings with CubeMX for the NUCLEO-H723ZG board, then disabling ethernet and USB-to-go, and then adding a yellow LED blink code. Full project and generated code, for STM32CubeIDE:

http://www.frank-buss.de/tmp/cubemx-test.zip

I then created an array:

uint8_t buffer[100000];

I can see in the "Build Analyzer" at bottom right that I still have 320 kB RAM_D1:

0693W000008xxUeQAI.pngBut when I increase the buffer like this:

uint8_t buffer[200000];

Then I get this compile error:

c:\st\stm32cubeide_1.6.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924\tools\arm-none-eabi\bin\ld.exe: test.elf section `.bss' will not fit in region `RAM'
c:\st\stm32cubeide_1.6.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924\tools\arm-none-eabi\bin\ld.exe: region `RAM' overflowed by 70656 bytes

So how can I use the free RAM_D1. I've read about creating linker files etc., but would be nice if I could just configure all this stuff with some mouse clicks in CubeMX. And wouldn't CubeMX overwrite a changed linker file anyway?

1 ACCEPTED SOLUTION

Accepted Solutions

This didn't work. But RAM_D1 was already defined in the linker file, but no section. So I added this to the STM32H723ZGTX_FLASH.ld file at the end inside the SECTIONS block:

  .ram_d1 :
	{
		. = ALIGN(8);
	} >RAM_D1

Now I can use it like this, even with 200 kB:

__attribute__((section(".ram_d1"))) uint8_t buf[200000];

And looks like CubeMX doesn't overwrite the linker file, or at least it keeps the sections, so no problem when I generate the code again.

Analyzer view (different project, but same change for RAM_D1) :

0693W000008xxnRQAQ.png

View solution in original post

3 REPLIES 3
Curtis B.
Senior

Hi,

you need to edit your linker file. You can add following section for example:

  .my_region:
{
. = ABSOLUTE(here you need to enter the base adress of RAM1);
*(.my_region*);
} >RAM_D1

RAM_D1 must be specified in the MEMORY {} area of the linker script.

In you code you define your array:

__attribute__((section(".my_section"))) uint8_t buffer[100000];

This didn't work. But RAM_D1 was already defined in the linker file, but no section. So I added this to the STM32H723ZGTX_FLASH.ld file at the end inside the SECTIONS block:

  .ram_d1 :
	{
		. = ALIGN(8);
	} >RAM_D1

Now I can use it like this, even with 200 kB:

__attribute__((section(".ram_d1"))) uint8_t buf[200000];

And looks like CubeMX doesn't overwrite the linker file, or at least it keeps the sections, so no problem when I generate the code again.

Analyzer view (different project, but same change for RAM_D1) :

0693W000008xxnRQAQ.png

Just take a note that, unless you modify a startup code, the variables in that section will not be initialized to any specific values.