LPC1768 move BSS to USB_RAM

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

LPC1768 move BSS to USB_RAM

494 Views
ArdWar
Contributor I

Hi, I'm pretty new to understanding the low-level working of ARM uC. Right now I have a project that require fairly large amount of heap (~24K). The default LPC1768 linkerscript put the heap in the leftover space from 32K RAM, which for my case won't be enough.

I have an idea to move the .data and .bss sections to the unused 16K RAMs and use the whole 32K RAM as heap (minus the ISR vectors and IAP of course). This should work, right?

I've successfully move the .data section to USB_RAM. But when I move the .bss to USB_RAM, the code isn't working properly. Looks like as if the memory isn't even allocated.

Putting .data > USB_RAM, .bss > USB_RAM, .heap > RAM does not work:

 

    .data : AT(__etext)
    {
        __data_start__ = .;
        /* data stuff */
        __data_end__ = .;
    } > USB_RAM

    .bss :
    {
        __bss_start__ = .;
        *(.bss*)
        *(COMMON)
        __bss_end__ = .;
    } > USB_RAM

    .heap (NOLOAD):
    {
        __end__ = .;
        *(.heap*)
        . = ORIGIN(RAM) + LENGTH(RAM);
        __HeapLimit = .;
    } > RAM​

 

 But putting .data > USB_RAM, .bss > RAM, .heap > RAM works, or any other combinations that doesn't involve putting .bss > USB_RAM really.

Even looking at the map file when .bss > USB_RAM, I don't really see why the code doesn't work. The .bss is there where it expected to be:

 

...
                0x000000002007d984                PROVIDE (__init_array_end = .)
                0x000000002007d988                . = ALIGN (0x8)
 *fill*         0x000000002007d984        0x4 
                [!provide]                        PROVIDE (__fini_array_start = .)
 *(SORT_BY_NAME(.fini_array.*))
 *(.fini_array)
 .fini_array    0x000000002007d988        0x4 /opt/gcc-arm-none-eabi-9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/thumb/v7-m/nofp/crtbegin.o
                [!provide]                        PROVIDE (__fini_array_end = .)
                0x000000002007d990                . = ALIGN (0x8)
 *fill*         0x000000002007d98c        0x4 
                0x000000002007d990                __data_end__ = .

.igot.plt       0x000000002007d990        0x0 load address 0x00000000000109e4
 .igot.plt      0x000000002007d990        0x0 /opt/gcc-arm-none-eabi-9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/thumb/v7-m/nofp/crtbegin.o
.bss            0x000000002007d990     0x1028 load address 0x00000000000109e8
                0x000000002007d990                __bss_start__ = .
 *(.bss*)
 .bss           0x000000002007d990       0x1c /opt/gcc-arm-none-eabi-9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/thumb/v7-m/nofp/crtbegin.o
 .bss.d1        0x000000002007d9ac        0x8 BUILD/gw/gateway/main.o
                0x000000002007d9ac                d1
 .bss.d2        0x000000002007d9b4        0x8 BUILD/gw/gateway/main.o
                0x000000002007d9b4                d2
 .bss.pBus      0x000000002007d9bc        0x4 BUILD/gw/gateway/main.o
...

 

I'm using mbed 5.14 by the way.

0 Kudos
1 Reply

483 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi 

Please follow below to set global data placement in USB_RAM. thus the .bss and .data sections will be placed in USB_RAM

ZhangJennie_0-1599111483098.png

 

Have a nice day,

Jun Zhang

 

 

0 Kudos