LPC1768 move BSS to USB_RAM

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

LPC1768 move BSS to USB_RAM

947 次查看
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.

标签 (1)
0 项奖励
回复
1 回复

943 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

This question is answered here:

https://community.nxp.com/t5/Other-NXP-Products/LPC1768-move-BSS-to-USB-RAM/m-p/1133599#M9194

 

Have a nice day,

Jun Zhang

0 项奖励
回复