2025-02-17 04:54 AM - last edited on 2025-02-17 04:57 AM by SofLit
I want to create and application on a STM32H745XI-DISCO. I am not using M7 core only M4.
Reference manual says that upto 864kB of SRAM and 2MB of flash are available.
I will receive the application sw via Can. My bootloader will save it RAM and after checking CRC etc., It will write this to internal flash. App code is around 300 kB. So 256kB of flash and 512 kB of RAM would be sufficient. After writing to flash sw will jump to application.
The application sw will receive data which is arund 730kB via can and it will save it to flash.
Here is a part of ST generated linker for bootloader;
/* Entry Point */
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = 0x10048000; /* previously = 0x10048000, end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x200; /* previously = 0x200, required amount of heap */
_Min_Stack_Size = 0x400; /* previously = 0x400,required amount of stack */
/* Specify the memory areas */
MEMORY
{
BOOTLOADER_FLASH (rx) : ORIGIN = 0x08100000, LENGTH = 256K
BOOTLOADER_RAM (xrw) : ORIGIN = 0x10000000, LENGTH = 288K /* previously = 288K */
}
/* Entry Point */
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = 0x10048000; /* previously = 0x10048000, end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x200; /* previously = 0x200, required amount of heap */
_Min_Stack_Size = 0x400; /* previously = 0x400,required amount of stack */
/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08140000, LENGTH = 512K /* can be extended up to 768K */
RAM (xrw) : ORIGIN = 0x10000000, LENGTH = 288K /* previously = 288K */
}
I want to have as much as possible ram here and a1Mb extra flash section to save data.2025-02-17 05:08 AM - edited 2025-02-17 05:11 AM
Hello,
That's normal. SRAM1 to SRAM3 are contiguous and can form a SRAM block of 128KB+128KB+32KB = 288KB. This is the maximum you can get with that block.
You can use AXI-SRAM in D1 domain with 512KB (0x2400 0000). It's accessible by the Cortex-M4.
Hope that answers your question.
2025-02-17 06:01 AM - last edited on 2025-02-17 06:34 AM by SofLit
Does the linkers below are correct then?
For application linker
/*
******************************************************************************
** Application Linker Script
**
** Flash: 512KB for code + 1MB for data storage
** RAM: 864KB (combined into one section)
******************************************************************************
*/
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = 0x24080000; /* End of AXI SRAM */
/* Heap and Stack sizes */
_Min_Heap_Size = 0x200; /* 512 Bytes Heap */
_Min_Stack_Size = 0x400; /* 1KB Stack */
/* Memory Areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08140000, LENGTH = 512K /* Application Code */
DATA_STORAGE (rwx) : ORIGIN = 0x08000000, LENGTH = 1M /* 1MB Continuous Flash Storage */
RAM (xrw) : ORIGIN = 0x24000000, LENGTH = 864K /* Combined RAM */
}
/* Sections */
SECTIONS
{
/* ISR Vector Table */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector))
. = ALIGN(4);
} >FLASH
/* Program Code and Read-Only Data */
.text :
{
. = ALIGN(4);
*(.text) /* Code */
*(.text*) /* Additional Code */
*(.glue_7) /* Glue ARM to Thumb */
*(.glue_7t) /* Glue Thumb to ARM */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_etext = .; /* End of Code */
} >FLASH
/* Read-Only Constants */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* Constants, Strings */
*(.rodata*)
. = ALIGN(4);
} >FLASH
/* Data Storage Section */
.storage (NOLOAD) :
{
. = ALIGN(4);
*(.storage) /* CAN Data, Logs, etc. */
. = ALIGN(4);
} >DATA_STORAGE
/* Exception Handling */
.ARM.extab (READONLY) :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} >FLASH
.ARM (READONLY) :
{
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >FLASH
/* Initialization Arrays */
.preinit_array (READONLY) :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH
.init_array (READONLY) :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH
.fini_array (READONLY) :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH
/* Initialized Data Section (Copy from Flash to RAM) */
_sidata = LOADADDR(.data);
.data :
{
. = ALIGN(4);
_sdata = .; /* Start of Data */
*(.data) /* Initialized Variables */
*(.data*)
. = ALIGN(4);
_edata = .; /* End of Data */
} >RAM AT> FLASH
/* Uninitialized Data Section */
. = ALIGN(4);
.bss :
{
_sbss = .; /* Start of BSS */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* End of BSS */
__bss_end__ = _ebss;
} >RAM
/* Heap and Stack Section */
._user_heap_stack :
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
} >RAM
/* Remove Unused Library Code */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
.ARM.attributes 0 : { *(.ARM.attributes) }
}
/*
******************************************************************************
**
** File : LinkerScript.ld
**
**
** Abstract : Linker script for STM32H7 series
** 1024Kbytes FLASH and 288Kbytes RAM
**
** 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) 2019 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 = 0x24080000; /* previously = 0x10048000, end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x400; /* previously = 0x200, required amount of heap */
_Min_Stack_Size = 0x800; /* previously = 0x400,required amount of stack */
/* Specify the memory areas */
MEMORY
{
BOOTLOADER_FLASH (rx) : ORIGIN = 0x08100000, LENGTH = 256K
BOOTLOADER_RAM (xrw) : ORIGIN = 0x24000000, LENGTH = 512K /* previously = 288K */
}
/* Define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >BOOTLOADER_FLASH
/* The program code and other data goes into FLASH */
.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 */
} >BOOTLOADER_FLASH
/* Constant data goes into FLASH */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >BOOTLOADER_FLASH
.ARM.extab (READONLY) : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} >BOOTLOADER_FLASH
.ARM (READONLY) : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
{
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >BOOTLOADER_FLASH
.preinit_array (READONLY) : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >BOOTLOADER_FLASH
.init_array (READONLY) : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >BOOTLOADER_FLASH
.fini_array (READONLY) : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} >BOOTLOADER_FLASH
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >BOOTLOADER_RAM AT> BOOTLOADER_FLASH
/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
_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;
} >BOOTLOADER_RAM
/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
} >BOOTLOADER_RAM
/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
.ARM.attributes 0 : { *(.ARM.attributes) }
}
2025-02-17 06:33 AM - edited 2025-02-17 06:35 AM
Hello,
First, please use </> button to share a code or linker script. See this link.
Second, I'm not expert of linker files. But as I said previously you need to select the AXI-SRAM (512K).
To me this is OK:
MEMORY
{
BOOTLOADER_FLASH (rx) : ORIGIN = 0x08100000, LENGTH = 256K
BOOTLOADER_RAM (xrw) : ORIGIN = 0x24000000, LENGTH = 512K /* previously = 288K */
}
You need to test it.
@baycanakcay wrote:
or do I need to explicitly define all ram sections in application linker?
You don't need to define unused RAM in the linker files.
2025-02-17 06:37 AM
Thanks SofLit!
I will test.
Best regards.