How to put global variables into sdram?

250 views
Skip to first unread message

cyl...@gmail.com

unread,
Sep 10, 2020, 12:43:28 AM9/10/20
to NuttX
Hi:
I'm running nuttx on a stm32h747 board, the FMC is working ok. I tried to apply a big global array with size 8M, compile failed:

arm-none-eabi-ld: /home/aaa/nuttxspace/nuttx/nuttx section `.bss' will not fit in region `sram'
arm-none-eabi-ld: region `sram' overflowed by 7891132 bytes
Makefile:184: recipe for target 'nuttx' failed
make[1]: *** [nuttx] Error 1

I think my sdram is successfully added to heap, when malloc a 8M area works fine. 

If I put .bss into sdram (in file flash.ld), exception occurs when running.

MEMORY
{
  ...
  sdram (rwx) : ORIGIN = 0xc0000000, LENGTH =32768K
}

    .bss :
    {
...
    } > sdram


Is there any example for this? Thanks!

patacongo

unread,
Sep 10, 2020, 12:56:41 AM9/10/20
to NuttX
One possibility is that you are using SDRAM before the SDRAM controller has been initialized.  From what you describe, .data and .bss both reside in SDRAM.. and probably also the stack. The stack is used very early in initialization and .bss and ..data are initialized very early, all before the the board initialization function is called.

What I have done in other architectures is:

1. Move the initial stack (only) back into internal SRAM, keeping .bss and .data in SDRAM, and
2. Add another board initialization function just to initialize SDRAM (see, for example, arch/arm/src/armv7-a/arm-head.S).

A much simpler thing to do is:

1. Restore .bss and .data to internal SRAM.
2. Make sure that SDRAM is added to the stack, and then
3. Allocate your 8Mb array dynamically using malloc().

Good luck!

Also, most of the technical discussion these days occurs on the Apache NuttX mail list of d...@nuttx.apache.org.  You can subscribe to the list by sending an email to dev-su...@nuttx.apache.org.  Subscribing to github repository notifications can also be interesting.  That is where I do most of my ranting these days.

The are a lot of people familiar with STM32 F7 there who might have other thoughts.
Reply all
Reply to author
Forward
0 new messages