Add support for using SRAM2 separate from SRAM1.

m17
Rob Riggs 2018-07-29 12:43:52 -05:00
rodzic 89a8cfbcbe
commit 5d38c4a1ad
3 zmienionych plików z 190 dodań i 168 usunięć

1
.gitignore vendored
Wyświetl plik

@ -34,3 +34,4 @@
# STM32CubeMX garbage files # STM32CubeMX garbage files
*.launch *.launch
.settings/ .settings/
*.s

Wyświetl plik

@ -1,168 +1,172 @@
/* /* Entry Point */
***************************************************************************** ENTRY(Reset_Handler)
**
/* Highest address of the user mode stack */
** File : stm32_flash.ld _estack = 0x2000C000; /* end of RAM */
** /* Generate a link error if heap and stack don't fit into RAM */
** Abstract : Linker script for STM32L432KC Device with _Min_Heap_Size = 0x4000; /* required amount of heap */
** 256KByte FLASH, 64KByte RAM _Min_Stack_Size = 0x800; /* required amount of stack */
**
** Set heap size, stack size and stack location according /* Specify the memory areas */
** to application requirements. MEMORY
** {
** Set memory bank area and size if external memory is used. RAM1 (xrw) : ORIGIN = 0x20000000, LENGTH = 48K
** RAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 16K
** Target : STMicroelectronics STM32 FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 256K
** }
** Environment : Atollic TrueSTUDIO(R)
** /* Define output sections */
** Distribution: The file is distributed as is, without any warranty SECTIONS
** of any kind. {
** /* The startup code goes first into FLASH */
** (c)Copyright Atollic AB. .isr_vector :
** You may use this file as-is or modify it according to the needs of your {
** project. This file may only be built (assembled or compiled and linked) . = ALIGN(4);
** using the Atollic TrueSTUDIO(R) product. The use of this file together KEEP(*(.isr_vector)) /* Startup code */
** with other tools than Atollic TrueSTUDIO(R) is not permitted. . = ALIGN(4);
** } >FLASH
*****************************************************************************
*/ /* The program code and other data goes into FLASH */
.text :
/* Entry Point */ {
ENTRY(Reset_Handler) . = ALIGN(4);
*(.text) /* .text sections (code) */
/* Highest address of the user mode stack */ *(.text*) /* .text* sections (code) */
_estack = 0x20010000; /* end of RAM */ *(.glue_7) /* glue arm to thumb code */
/* Generate a link error if heap and stack don't fit into RAM */ *(.glue_7t) /* glue thumb to arm code */
_Min_Heap_Size = 0x200; /* required amount of heap */ *(.eh_frame)
_Min_Stack_Size = 0x400; /* required amount of stack */
KEEP (*(.init))
/* Specify the memory areas */ KEEP (*(.fini))
MEMORY
{ . = ALIGN(4);
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K _etext = .; /* define a global symbols at end of code */
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 256K } >FLASH
}
/* Constant data goes into FLASH */
/* Define output sections */ .rodata :
SECTIONS {
{ . = ALIGN(4);
/* The startup code goes first into FLASH */ *(.rodata) /* .rodata sections (constants, strings, etc.) */
.isr_vector : *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
{ . = ALIGN(4);
. = ALIGN(4); } >FLASH
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4); .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
} >FLASH .ARM : {
__exidx_start = .;
/* The program code and other data goes into FLASH */ *(.ARM.exidx*)
.text : __exidx_end = .;
{ } >FLASH
. = ALIGN(4);
*(.text) /* .text sections (code) */ .preinit_array :
*(.text*) /* .text* sections (code) */ {
*(.glue_7) /* glue arm to thumb code */ PROVIDE_HIDDEN (__preinit_array_start = .);
*(.glue_7t) /* glue thumb to arm code */ KEEP (*(.preinit_array*))
*(.eh_frame) PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH
KEEP (*(.init)) .init_array :
KEEP (*(.fini)) {
PROVIDE_HIDDEN (__init_array_start = .);
. = ALIGN(4); KEEP (*(SORT(.init_array.*)))
_etext = .; /* define a global symbols at end of code */ KEEP (*(.init_array*))
} >FLASH PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH
/* Constant data goes into FLASH */ .fini_array :
.rodata : {
{ PROVIDE_HIDDEN (__fini_array_start = .);
. = ALIGN(4); KEEP (*(SORT(.fini_array.*)))
*(.rodata) /* .rodata sections (constants, strings, etc.) */ KEEP (*(.fini_array*))
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */ PROVIDE_HIDDEN (__fini_array_end = .);
. = ALIGN(4); } >FLASH
} >FLASH
/* used by the startup to initialize data */
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH _sidata = LOADADDR(.data);
.ARM : {
__exidx_start = .; /* Initialized data sections goes into RAM, load LMA copy after code */
*(.ARM.exidx*) .data :
__exidx_end = .; {
} >FLASH . = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
.preinit_array : *(.data) /* .data sections */
{ *(.data*) /* .data* sections */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*)) . = ALIGN(4);
PROVIDE_HIDDEN (__preinit_array_end = .); _edata = .; /* define a global symbol at data end */
} >FLASH } >RAM1 AT> FLASH
.init_array :
{ _sibss2 = LOADADDR(.bss2);
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*))) /* RAM2 section
KEEP (*(.init_array*)) *
PROVIDE_HIDDEN (__init_array_end = .); * IMPORTANT NOTE!
} >FLASH * If initialized variables will be placed in this section,
.fini_array : * the startup code needs to be modified to copy the init-values.
{ */
PROVIDE_HIDDEN (__fini_array_start = .); .bss2 :
KEEP (*(SORT(.fini_array.*))) {
KEEP (*(.fini_array*)) . = ALIGN(4);
PROVIDE_HIDDEN (__fini_array_end = .); _sbss2 = .; /* create a global symbol at ram2 start */
} >FLASH *(.bss2)
*(.bss2*)
/* used by the startup to initialize data */
_sidata = LOADADDR(.data); . = ALIGN(4);
_ebss2 = .; /* create a global symbol at ram2 end */
/* Initialized data sections goes into RAM, load LMA copy after code */ } >RAM2 AT> FLASH
.data :
{ _sibss3 = LOADADDR(.bss3);
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */ .bss3 :
*(.data) /* .data sections */ {
*(.data*) /* .data* sections */ . = ALIGN(4);
_sbss3 = .; /* create a global symbol at ram3 start */
. = ALIGN(4); *(.bss3)
_edata = .; /* define a global symbol at data end */ *(.bss3*)
} >RAM AT> FLASH
. = ALIGN(4);
_ebss3 = .; /* create a global symbol at ram3 end */
/* Uninitialized data section */ } >RAM2 AT> FLASH
. = ALIGN(4);
.bss : /* Uninitialized data section */
{ . = ALIGN(4);
/* This is used by the startup in order to initialize the .bss secion */ .bss :
_sbss = .; /* define a global symbol at bss start */ {
__bss_start__ = _sbss; /* This is used by the startup in order to initialize the .bss secion */
*(.bss) _sbss = .; /* define a global symbol at bss start */
*(.bss*) __bss_start__ = _sbss;
*(COMMON) *(.bss)
*(.bss*)
. = ALIGN(4); *(COMMON)
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss; . = ALIGN(4);
} >RAM _ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
/* User_heap_stack section, used to check that there is enough RAM left */ } >RAM1
._user_heap_stack :
{ /* User_heap_stack section, used to check that there is enough RAM left */
. = ALIGN(4); ._user_heap_stack :
PROVIDE ( end = . ); {
PROVIDE ( _end = . ); . = ALIGN(4);
. = . + _Min_Heap_Size; PROVIDE ( end = . );
. = . + _Min_Stack_Size; PROVIDE ( _end = . );
. = ALIGN(4); . = . + _Min_Heap_Size;
} >RAM . = . + _Min_Stack_Size;
. = ALIGN(4);
} >RAM1
/* Remove information from the standard libraries */ _Heap_Begin = _end;
/DISCARD/ : _Heap_Limit = _estack - _Min_Stack_Size;
{
libc.a ( * )
libm.a ( * ) /* Remove information from the standard libraries */
libgcc.a ( * ) /DISCARD/ :
} {
libc.a ( * )
.ARM.attributes 0 : { *(.ARM.attributes) } libm.a ( * )
} libgcc.a ( * )
}
.ARM.attributes 0 : { *(.ARM.attributes) }
}

Wyświetl plik

@ -2,6 +2,8 @@
****************************************************************************** ******************************************************************************
* @file startup_stm32l432xx.s * @file startup_stm32l432xx.s
* @author MCD Application Team * @author MCD Application Team
* @version V1.3.1
* @date 21-April-2017
* @brief STM32L432xx devices vector table for GCC toolchain. * @brief STM32L432xx devices vector table for GCC toolchain.
* This module performs: * This module performs:
* - Set the initial SP * - Set the initial SP
@ -94,6 +96,21 @@ LoopCopyDataInit:
adds r2, r0, r1 adds r2, r0, r1
cmp r2, r3 cmp r2, r3
bcc CopyDataInit bcc CopyDataInit
/* BEGIN BSS2 init code */
movs r1, #0
b LoopCopyDataInit1
CopyDataInit1:
ldr r3, =_sibss2
ldr r3, [r3, r1]
str r3, [r0, r1]
adds r1, r1, #4
LoopCopyDataInit1:
ldr r0, =_sbss2
ldr r3, =_ebss2
adds r2, r0, r1
cmp r2, r3
bcc CopyDataInit1
/* END BSS2 init code */
ldr r2, =_sbss ldr r2, =_sbss
b LoopFillZerobss b LoopFillZerobss
/* Zero fill the bss segment. */ /* Zero fill the bss segment. */