Placing data in external RAM - LPC4088 / MCUXpresso

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Placing data in external RAM - LPC4088 / MCUXpresso

2,544 Views
bmcdonnell_ionx
Contributor III

How do I put variables/data in external RAM? (Meaning off-chip, on-board, requiring initialization before use.) I'm using an Embedded Artists LPC4088 QuickStart Board in MCUXpresso IDE v10.0.2 [Build 411] [2017-07-11]. The board has an external 32 MB SDRAM chip.

I know the RAM works because I got the periph_memtest program working on it. That program uses the pointers to address the memory directly, though; it doesn't declare any variables to be located there.

I tried following the directions at Placing data into different RAM blocks - I added another memory area in the Memory Config Editor as pictured below, did 

#include <cr_section_macros.h> 

and declared some data there by

__NOINIT(RamExternal32M) uint32_t bigData[1000000];

but when I try to build it, the linker fails with

.../arm-none-eabi/bin/ld.exe: myproject.axf section `.noinit.$RamExternal32M' will not fit in region `RAM'

It's like it doesn't even see the macro.

(I chose __NOINIT because it needs to wait for the SDRAM initialization. 'Noinit' Memory Sections)

What am I doing wrong? What am I missing? Do I have to mess with the linker file(s)? If so, why? Why isn't what I've described sufficient?

mem_config_editor.png

Other references, for later use if I do have to modify linker files:

Labels (1)
0 Kudos
3 Replies

1,445 Views
lpcxpresso_supp
NXP Employee
NXP Employee

This should just work, so without seeing your actual code - plus the map file, it is hard to tell what might be going wrong for you.

For example, if I create a simple example placing an array into the Peripheral RAM on an LPC40xx part:

#include <cr_section_macros.h>
#include <stdio.h>

__NOINIT (RamPeriph32) char array[10];
char array2 [10];

int main(void) {
  array[0] = array2[0];
   :

Then look in the map file, I can see:

 :
.bss         0x0000000010000000       0x1fc
             0x0000000010000000                _bss = .
 *(.bss*)
 .bss.array2 0x0000000010000000       0xa    ./src/lpc4078.o
             0x0000000010000000               array2
 *fill*      0x000000001000000a       0x2 

 :
 : 
 
.noinit_RAM2 0x0000000020000000       0xc
 *(.noinit.$RAM2*)
 *(.noinit.$RamPeriph32*)
 .noinit.$RamPeriph32
             0x0000000020000000       0xa ./src/lpc4078.o
             0x0000000020000000            array
             0x000000002000000c            . = ALIGN (0x4)
 *fill*      0x000000002000000a       0x2 
 :

For more information on placement of data, please read the supplied MCUXpresso IDE v10.0.2 User Guide, chapter 12, "Memory Configuration and Linker Scripts" 

Regards,

MCUXpresso IDE Support

0 Kudos

1,445 Views
bmcdonnell_ionx
Contributor III

I tried again, with a shorter name for the memory section. It still doesn't work. I've attached my whole project, so you should be able to import and see. (I did a build before zipping, so it has the map file.)

The map file shows a section with the name was created, and the variable is placed in the named section, but it's not using the address range specified in the memory editor.

MAP file output includes:

.noinit.$RamExt32
                0x10000abc 0x3d0900 load address 0x0000e4a4
.noinit.$RamExt32
                0x10000abc 0x3d0900 ./main.o
                0x10000abc bigData
 

mem_config_editor2.png

0 Kudos

1,445 Views
lpcxpresso_supp
NXP Employee
NXP Employee

OK, simple answer. All of the IDE's mechanisms to assist with placing code and data (such as the NOINIT macro you are using) works in conjunction with the built-in managed linker script mechanism. Your project has this functionality turned off and you are providing a manually maintained linker script, as show below...

ManualLinkScript.jpg

Thus in order to place your item using the NOINIT macro, you would need to manually modify your linker script to place the section in the required location. You will actually also need to add the required memory to the linker script too.

I assume that, because this project looks like an export from the mbed world, you can't move from the manual linker script way of working. Then probably the simplest way to approach this would be to generate a new project for the LPC4088 using the new project wizard. Modify this using the memory configuration editor to add in the SDRAM.

Then build the new project and look at the linker script(s) generated, and copy the appropriate section into your manually maintained linker script. 

You might also want to take a look at section 12.12 "Disabling Managed Linker Scripts", of the MCUXpresso IDE v10.0.2 User Guide which gives a few more comments about manually maintained linker scripts - as well as a link to a useful article on writing them from scratch.

Regards,

MCUXpresso IDE Support

0 Kudos