Sysprogs forums › Forums › VisualGDB › STM32F4 linker script for use battery RAM
- This topic has 1 reply, 2 voices, and was last updated 7 years, 9 months ago by
support.
-
AuthorPosts
-
May 15, 2017 at 20:46 #11232
kucza
ParticipantI am trying to make a linker section for battery RAM. I have modyfied oryginal script added:
MEMORY
{
FLASH (RX) : ORIGIN = 0x08000000, LENGTH = 1M
SRAM (RWX) : ORIGIN = 0x20000000, LENGTH = 128K
CCMRAM (RWX) : ORIGIN = 0x10000000, LENGTH = 64K
BKPRAM (RWX) : ORIGIN = 0x40024000, LENGTH = 4K
}and in sections part:
.backup (NOLOAD) :
{
. = ALIGN(4);
*(.backup);
*(.backup*);
. = ALIGN(4);
} > BKPRAMIn main.cpp it looks like that:
struct config_t
{
uint8_t a;
uint16_t b;
uint32_t c;
};__attribute__((section(“.backup”))) config_t config;
and init for battery ram looks like that:
void initBackupRam(void)
{
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWR_EnableBkUpAccess();
__BKPSRAM_CLK_ENABLE();
}It does not work, probably I missed something in linker script. I need some adivice what is wrong.
/* Generated by LinkerScriptGenerator [http://visualgdb.com/tools/LinkerScriptGenerator] * Target: STM32F407VE * The file is provided under the BSD license. */ ENTRY(Reset_Handler) MEMORY { FLASH (RX) : ORIGIN = 0x08000000, LENGTH = 1M SRAM (RWX) : ORIGIN = 0x20000000, LENGTH = 128K CCMRAM (RWX) : ORIGIN = 0x10000000, LENGTH = 64K BKPRAM (RWX) : ORIGIN = 0x40024000, LENGTH = 4K } _estack = 0x20020000; SECTIONS { .isr_vector : { . = ALIGN(4); KEEP(*(.isr_vector)) . = ALIGN(4); } > FLASH .text : { . = ALIGN(4); _stext = .; *(.text) *(.text*) *(.rodata) *(.rodata*) *(.glue_7) *(.glue_7t) KEEP(*(.init)) KEEP(*(.fini)) . = ALIGN(4); _etext = .; } > FLASH .ARM.extab : { . = ALIGN(4); *(.ARM.extab) *(.gnu.linkonce.armextab.*) . = ALIGN(4); } > FLASH .exidx : { . = ALIGN(4); PROVIDE(__exidx_start = .); *(.ARM.exidx*) . = ALIGN(4); PROVIDE(__exidx_end = .); } > FLASH .ARM.attributes : { *(.ARM.attributes) } > FLASH .preinit_array : { PROVIDE(__preinit_array_start = .); KEEP(*(.preinit_array*)) PROVIDE(__preinit_array_end = .); } > FLASH .init_array : { PROVIDE(__init_array_start = .); KEEP(*(SORT(.init_array.*))) KEEP(*(.init_array*)) PROVIDE(__init_array_end = .); } > FLASH .fini_array : { PROVIDE(__fini_array_start = .); KEEP(*(.fini_array*)) KEEP(*(SORT(.fini_array.*))) PROVIDE(__fini_array_end = .); } > FLASH . = ALIGN(4); _sidata = .; .data : AT(_sidata) { . = ALIGN(4); _sdata = .; PROVIDE(__data_start__ = _sdata); *(.data) *(.data*) . = ALIGN(4); _edata = .; PROVIDE(__data_end__ = _edata); } > SRAM .bss : { . = ALIGN(4); _sbss = .; PROVIDE(__bss_start__ = _sbss); *(.bss) *(.bss*) *(COMMON) . = ALIGN(4); _ebss = .; PROVIDE(__bss_end__ = _ebss); } > SRAM .backup (NOLOAD) : { . = ALIGN(4); *(.backup); *(.backup*); . = ALIGN(4); } > BKPRAM PROVIDE(end = .); .heap (NOLOAD) : { . = ALIGN(4); PROVIDE(__heap_start__ = .); KEEP(*(.heap)) . = ALIGN(4); PROVIDE(__heap_end__ = .); } > SRAM .reserved_for_stack (NOLOAD) : { . = ALIGN(4); PROVIDE(__reserved_for_stack_start__ = .); KEEP(*(.reserved_for_stack)) . = ALIGN(4); PROVIDE(__reserved_for_stack_end__ = .); } > SRAM }
-
This topic was modified 7 years, 9 months ago by
kucza.
May 16, 2017 at 05:53 #11237support
KeymasterHi,
Please try referencing the “config” variable from your code so that the linker does not discard it as unused. Alternatively you can try using the KEEP() statement in the linker script file and attribute__((used)) in your code.
If it does not help, try enabling the map file generation via Linker Settings and check the map file to see where exactly the linker placed your variable.
-
This topic was modified 7 years, 9 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.