2024-03-13 01:27 PM - edited 2024-03-13 01:29 PM
Hello all,
i am trying to make an offset for my application to have a start of flash for bootloader. So i set up an offset in linker file, so instead of 0x08000000 to 0x0804B000 and vector table offset during startup. But the problem is that i am unable to load the application into flash (as you can see in picture). When i add post build command i can see an interresting error (second picture) showing that there is an empty loadable segment in address that is nowhere mentioned in my code. This address is always the one, which was used previously and i cannot get over it. I have tried to clean project and remove whole "Debug" folder but the same error again. Also i have marked option "Discard unused sections" in build settings.
Is it an another bug in overbugged SW?
Error from loading:
Information about empty loadable segment:
Linker file definitions:
2024-03-13 01:45 PM
>>Is it an another bug in overbugged SW?
More probably an issue with the linker script failing to impart what you actually want to happen vs what you tell it to do..
Here is it complains about 0x20000000 likely due to where you're staging initialization data.
Would suggest using the linker symbol address for the vectors to drive the setting of SCB->VTOR, and not a compile time define.
2024-03-13 01:58 PM
This is my section in linker for RAM:
/*
******************************************************************************
**
** @file : LinkerScript.ld
**
** @author : Auto-generated by STM32CubeIDE
**
** @brief : Linker script for STM32L4R9ZGJx Device from STM32L4PLUS series
** 1024Kbytes FLASH
** 640Kbytes RAM
** 64Kbytes RAM2
** 384Kbytes RAM3
**
** Set heap size, stack size and stack location according
** to application requirements.
**
** Set memory bank area and size if external memory is used
**
** Target : STMicroelectronics STM32
**
** Distribution: The file is distributed as is, without any warranty
** of any kind.
**
******************************************************************************
** @attention
**
** Copyright (c) 2023 STMicroelectronics.
** All rights reserved.
**
** This software is licensed under terms that can be found in the LICENSE file
** in the root directory of this software component.
** If no LICENSE file comes with this software, it is provided AS-IS.
**
******************************************************************************
*/
/* Entry Point */
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
_Min_Heap_Size = 0x200; /* required amount of heap */
_Min_Stack_Size = 0x400; /* required amount of stack */
/* Memories definition */
MEMORY
{
RAM (xrw): ORIGIN = 0x20000000, LENGTH = 640K
/* RAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 64K */
/* RAM3 (xrw) : ORIGIN = 0x20040000, LENGTH = 384K */
SRAM_FB (xrw): ORIGIN = 0x60000000, LENGTH = 600k
SRAM_AS (xrw): ORIGIN = 0x60096000, LENGTH = 2M
/* FLASH_BOOTLOADER (rx) : ORIGIN = 0x08000000, LENGTH = 300k */
FLASH_APP (rx) : ORIGIN = 0x08000000, LENGTH = 720k /* 0x0804B000 */
DATA (rx) : ORIGIN = 0x080FF000, LENGTH = 4k
OSPI_FLASH (xrw): ORIGIN = 0x90000000, LENGTH = 64M
}
/* Sections */
SECTIONS
{
/* Location of user data */
.user_data_flash ( NOLOAD ):
{
. = ALIGN(4);
*(.user_data_flash)
. = ALIGN(4);
} >DATA
/* The startup code into "FLASH" Rom type memory */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH_APP
/* The program code and other data into "FLASH" Rom type memory */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH_APP
/* Constant data into "FLASH" Rom type memory */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >FLASH_APP
.ARM.extab : {
. = ALIGN(4);
*(.ARM.extab* .gnu.linkonce.armextab.*)
. = ALIGN(4);
} >FLASH_APP
.ARM : {
. = ALIGN(4);
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
. = ALIGN(4);
} >FLASH_APP
.preinit_array :
{
. = ALIGN(4);
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
} >FLASH_APP
.init_array :
{
. = ALIGN(4);
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
} >FLASH_APP
.fini_array :
{
. = ALIGN(4);
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
. = ALIGN(4);
} >FLASH_APP
/* Used by the startup to initialize data */
_sidata = LOADADDR(.data);
/* Initialized data sections into "RAM" Ram type memory */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
*(.RamFunc) /* .RamFunc sections */
*(.RamFunc*) /* .RamFunc* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM AT> FLASH_APP
ExtFlashSection :
{
*(ExtFlashSection ExtFlashSection.*)
*(FontFlashSection FontFlashSection.*)
*(TextFlashSection TextFlashSection.*)
*(.gnu.linkonce.r.*)
. = ALIGN(0x4);
} >OSPI_FLASH
/* Uninitialized data section into "RAM" Ram type memory */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss section */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM
/* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
._user_heap_stack :
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
} >RAM
/* Remove information from the compiler libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
.ARM.attributes 0 : { *(.ARM.attributes) }
TouchGFX_FrameBuffer (NOLOAD) : { *(TouchGFX_FrameBuffer) } >SRAM_FB
TouchGFX_AnimationBuffer (NOLOAD) : { *(TouchGFX_AnimationBuffer) } >SRAM_AS
}
How could linker symbol address lead to fail during flashing? I have problem with flashing itself not a running the app. This is output from STM32CubeProgrammer with standard base addr:
And this with offset:
BTW, the address is changing, sometimes it is previous address with empty loadable segment, but usually is this one:
The end block in message "erasing internal memory" is incorrect. So CubeIde is generating something incorrect.
2024-03-14 10:52 AM
So again nothing from whole ST?
2024-03-15 05:00 PM - edited 2024-03-15 05:02 PM
Nothing.
Try to roll back to state before this error started showing up. Then gradually forward.
Add (NOLOAD) for segments where the linker should not fill any data.