Board not running with external heap (Linker script)
Hello,
I'm trying the following:
I have a Stm32 chip with an additional 512KB external RAM. I would like to use the internal RAM for stack and the external RAM for heap. If I fit everything into the internal RAM it works fine, if I fit everything into the external RAM it works fine, but when I try to split the functionality between the two parts it does not work. I'm pretty sure my hardware is ok (I'm moving from different compiler to GCC ARM Embedded).
One of the things from other forums; I tried modifying _sbrk to not check for overlaps but that didn't work out.
Anyone has a suggestion? Thanks.
This the linker script I used in the non-working case (Actually all I did was defining + moving the heap to the external RAM):
/* Linker script to configure memory regions. */
MEMORY
{
EXTERNALRAM (rwx) : ORIGIN = 0x68000000, LENGTH = 512k
FLASH (rx) : ORIGIN = 0x08006000, LENGTH = 488k
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 64k
option_bytes_rom (rx) : ORIGIN = 0x1FFFF800, LENGTH = 16
}
/* Library configurations */
GROUP(libgcc.a libc.a libm.a libnosys.a)
/* Linker script to place sections and symbol values. Should be used together
* with other linker script that defines memory regions FLASH and RAM.
* It references following symbols, which must be defined in code:
* Reset_Handler : Entry of reset handler
*
* It defines following symbols, which code can use without definition:
* __exidx_start
* __exidx_end
* __copy_
* __copy_table_end__
* __zero_
* __zero_table_end__
* __etext
* __data_start__
* __preinit_
* __preinit_array_end
* __init_array_start
* __init_array_end
* __fini_array_start
* __fini_array_end
* __data_end__
* __bss_start__
* __bss_end__
* __end__
* end
* __HeapLimit
* __StackLimit
* __StackTop
* __stack
* __Vectors_End
* __Vectors_Size
*/
ENTRY(Reset_
SECTIONS
{
.text :
{
KEEP(*(.vectors))
__Vectors_End = .;
__Vectors_Size = __Vectors_End - __Vectors;
__end__ = .;
*(.text*)
KEEP(*(.init))
KEEP(*(.fini))
/* .ctors */
*crtbegin.
*crtbegin?
*(EXCLUDE_
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.
*crtbegin?
*(EXCLUDE_
*(SORT(
*(.dtors)
*(.rodata*)
KEEP(
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.
} > FLASH
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.
} > FLASH
__exidx_end = .;
/* To copy multiple ROM to RAM sections,
* uncomment .copy.table section and,
* define __STARTUP_
.copy.table : ALIGN (4)
{
. = ALIGN(4);
__copy_
LONG (__etext)
LONG (__data_start__)
LONG (__data_end__ - __data_start__)
LONG (__etext2)
LONG (__data2_start__)
LONG (__data2_end__ - __data2_start__)
__copy_
} > FLASH
*/
/* To clear multiple BSS sections,
* uncomment .zero.table section and,
* define __STARTUP_
.zero.table : ALIGN (4)
{
. = ALIGN(4);
__zero_
LONG (__bss_start__)
LONG (__bss_end__ - __bss_start__)
LONG (__bss2_start__)
LONG (__bss2_end__ - __bss2_start__)
__zero_
} > FLASH
*/
__etext = .;
.data : AT (__etext)
{
__data_start__ = .;
*(vtable)
*(.data*)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_
KEEP(
PROVIDE_HIDDEN (__preinit_
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(
KEEP(
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(
KEEP(
PROVIDE_HIDDEN (__fini_array_end = .);
KEEP(*(.jcr*))
. = ALIGN(4);
/* All data end */
__data_end__ = .;
} > RAM
.bss : ALIGN (8)
{
. = ALIGN(4);
__bss_start__ = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
__bss_end__ = .;
} > RAM
.heap (COPY): ALIGN (8)
{
__HeapBase = .;
__end__ = .;
end = __end__;
KEEP(*(.heap*))
__HeapLimit = .;
} > EXTERNALRAM
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY): ALIGN (8)
{
KEEP(*(.stack*)) /* changed MG 30.05.14 */
} > RAM
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
__StackLimit = ORIGIN(RAM);
PROVIDE(__stack = __StackTop);
}
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Brob
- Solved:
- Last query:
- Last reply: