8 years, 7 months ago.

section `.bss' will not fit in region `RamLoc32'

The error comes up after exporting an application to LPCXPRESSO and attempting to build it.

error

Program.axf section `.bss' will not fit in region `RamLoc32'
region `RamLoc32' overflowed by 5188 bytes

So my program has too much uninitialized data? The mbed online compiler does just fine with lots of room left.

As it turns out, the main culprit is LWIP. It is creating a 16362 byte buffer. I tried decreasing the buffer. It compiled but ended up causing the mbed (lpc1768) to freeze. I noticed the compiled binary was large as well. It was twice the size I usually get from the online compiler.

I am not an lwip or lcp1768 expert, but I can read code. The buffer is being allocated in the mem.c file of LWIP.

lwip heap

define ETHMEM_SECTION __attribute((section("AHBSRAM0")))
u8_t ram_heap[MEM_SIZE_ALIGNED + (2*SIZEOF_STRUCT_MEM) + MEM_ALIGNMENT] ETHMEM_SECTION;

Given the error is for RamLoc32 and not RamAHB32 leads me to believe that all that jaz above is being ignored by the LPCXPRESSO compiler of choice or I am totally missing something here.

Any insight help is appreciated. Give me something to try.

Question relating to:

1 Answer

8 years, 7 months ago.

Hi,

Can you the linker script file below and rebuild your project again?

/media/uploads/MACRUM/lpc1768_2.ld

FYI

https://developer.mbed.org/questions/60894/Exporting-mbed-progam-to-LPCXpresso/

Accepted Answer

Okay, I got it to work!

I took your linker script and added NOLOAD directive to .bss_RAM2 and .bss_RAM3. Without this the binary would be the entire size of the memory map that was actually being used. Since .bss_RAM2 sits at 0x2007c000 and LWIP is using AHBSRAM0 presto, you have a 500mb+ resulting binary from objcopy.

Here is the updated linker script. Maybe someone else will find it useful and the MBED team will fix the export to LPCXpresso linker script for LPC1768.

/* mbed - LPC1768 linker script
 * Based linker script generated by Code Red Technologies Red Suite 4.1
 */
GROUP(libgcc.a libc.a libstdc++.a libm.a libcr_newlib_nohost.a crti.o crtn.o crtbegin.o crtend.o)

MEMORY
{
  /* Define each memory region */
  MFlash512 (rx) : ORIGIN = 0x0, LENGTH = 0x80000 /* 512k */
  RamLoc32 (rwx) : ORIGIN = 0x100000C8, LENGTH = 0x7F38 /* 32k */
  RamAHB_USB (rwx) : ORIGIN = 0x2007c000, LENGTH = 0x4000 /* 16k */
  RamAHB_Eth (rwx) : ORIGIN = 0x20080000, LENGTH = 0x4000 /* 16k */

}
  /* Define a symbol for the top of each memory region */
  __top_MFlash512 = 0x0 + 0x80000;
  __top_RamLoc32 = 0x10000000 + 0x8000;
  __top_RamAHB32 = 0x2007c000 + 0x8000;

ENTRY(ResetISR)

SECTIONS
{

    /* MAIN TEXT SECTION */ 
    .text : ALIGN(4)
    {
        FILL(0xff)
        KEEP(*(.isr_vector))
        
        /* Global Section Table */
        . = ALIGN(4) ;
        __section_table_start = .;
        __data_section_table = .;
        LONG(LOADADDR(.data));
        LONG(    ADDR(.data)) ;
        LONG(  SIZEOF(.data));
        LONG(LOADADDR(.data_RAM2));
        LONG(    ADDR(.data_RAM2)) ;
        LONG(  SIZEOF(.data_RAM2));
        __data_section_table_end = .;
        __bss_section_table = .;
        LONG(    ADDR(.bss));
        LONG(  SIZEOF(.bss));
        LONG(    ADDR(.bss_RAM2));
        LONG(  SIZEOF(.bss_RAM2));
        __bss_section_table_end = .;
        __section_table_end = . ;
        /* End of Global Section Table */
        

        *(.after_vectors*)
        
        *(.text*)
        *(.rodata .rodata.*)
        . = ALIGN(4);
        
        /* C++ constructors etc */
        . = ALIGN(4);
        KEEP(*(.init))
        
        . = ALIGN(4);
        __preinit_array_start = .;
        KEEP (*(.preinit_array))
        __preinit_array_end = .;
        
        . = ALIGN(4);
        __init_array_start = .;
        KEEP (*(SORT(.init_array.*)))
        KEEP (*(.init_array))
        __init_array_end = .;
        
        KEEP(*(.fini));
        
        . = ALIGN(0x4);
        KEEP (*crtbegin.o(.ctors))
        KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
        KEEP (*(SORT(.ctors.*)))
        KEEP (*crtend.o(.ctors))
        
        . = ALIGN(0x4);
        KEEP (*crtbegin.o(.dtors))
        KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
        KEEP (*(SORT(.dtors.*)))
        KEEP (*crtend.o(.dtors))
        /* End C++ */
    } > MFlash512

    /*
     * for exception handling/unwind - some Newlib functions (in common
     * with C++ and STDC++) use this.
     */
    .ARM.extab : ALIGN(4)
    {
        *(.ARM.extab* .gnu.linkonce.armextab.*)
    } > MFlash512
    __exidx_start = .;
    
    .ARM.exidx : ALIGN(4)
    {
        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
    } > MFlash512
    __exidx_end = .;
    
    _etext = .;
        
    
    .data_RAM2 : ALIGN(4)
    {
       FILL(0xff)
        *(.data.$RAM2*)
        *(.data.$RamAHB32*)
       . = ALIGN(4) ;
    } > RamAHB_USB AT>MFlash512
    
    /* MAIN DATA SECTION */

    .uninit_RESERVED(NOLOAD) : ALIGN(4)
    {
        KEEP(*(.bss.$RESERVED*))
    } > RamLoc32

    .data : ALIGN(4)
    {
        FILL(0xff)
        _data = .;
        *(vtable)
        *(.data*)
        . = ALIGN(4) ;
        _edata = .;
    } > RamLoc32 AT>MFlash512

    
    .bss_RAM2(NOLOAD) : ALIGN(4)
    {
        *(.bss.$RAM2*)
        *(.bss.$RamAHB32*)
        *(AHBSRAM0)
       . = ALIGN(4) ;
    } > RamAHB_USB

    .bss_RAM3(NOLOAD) : ALIGN(4)
    {
        *(AHBSRAM1)
       . = ALIGN(4) ;
    } > RamAHB_Eth

    /* MAIN BSS SECTION */
    .bss(NOLOAD) : ALIGN(4)
    {
        _bss = .;
        *(.bss*)
        *(COMMON)
        . = ALIGN(4) ;
        _ebss = .;
        PROVIDE(end = .);
        __end__ = .;
    } > RamLoc32
    
    PROVIDE(_pvHeapStart = .);
    PROVIDE(_vStackTop = __top_RamLoc32 - 0);
}
posted by Mickey Malone 23 Sep 2015

The original script file didn't have NOLOAD keyword for .bss sections. I have just updated the script file. Can you try to use this?

/media/uploads/MACRUM/lpc1768_3.ld

posted by Toyomasa Watarai 24 Sep 2015

That worked. I will update what I have posted.

Thanks Toyomasa!

posted by Mickey Malone 24 Sep 2015