Skip to content

Commit 6cb4c48

Browse files
committed
STM32N6xx: add support for running from external flash
1 parent db6b5d4 commit 6cb4c48

4 files changed

Lines changed: 436 additions & 2 deletions

File tree

LedBlink/STM32/Src/system_stm32n6xx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ SystemInit(void) {
234234
RCC->APB4ENR2 &= ~(0x00000010UL);
235235

236236
/* XSPI2 & XSPIM reset */
237-
RCC->AHB5RSTSR = RCC_AHB5RSTSR_XSPIMRSTS | RCC_AHB5RSTSR_XSPI2RSTS;
238-
RCC->AHB5RSTCR = RCC_AHB5RSTCR_XSPIMRSTC | RCC_AHB5RSTCR_XSPI2RSTC;
237+
// RCC->AHB5RSTSR = RCC_AHB5RSTSR_XSPIMRSTS | RCC_AHB5RSTSR_XSPI2RSTS;
238+
// RCC->AHB5RSTCR = RCC_AHB5RSTCR_XSPIMRSTC | RCC_AHB5RSTCR_XSPI2RSTC;
239239

240240
#if defined(USER_TZ_SAU_SETUP)
241241
/* SAU/IDAU, FPU and Interrupts secure/non-secure allocation settings */

Linker/STM32N6xx_EXT_FLASH.ld

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
/*
2+
******************************************************************************
3+
**
4+
** @file : STM32N657XX_AXISRAM2_fsbl.ld
5+
**
6+
** @author : GPM Application Team
7+
**
8+
** @brief : Linker script for STM32N657XX Device from STM32N6 series
9+
** 512 KBytes RAM
10+
**
11+
** Set heap size, stack size and stack location according
12+
** to application requirements.
13+
**
14+
** Set memory bank area and size if external memory is used
15+
**
16+
** Target : STMicroelectronics STM32
17+
**
18+
** Distribution: The file is distributed as is, without any warranty
19+
** of any kind.
20+
**
21+
******************************************************************************
22+
** @attention
23+
**
24+
** Copyright (c) 2023 STMicroelectronics.
25+
** All rights reserved.
26+
**
27+
** This software is licensed under terms that can be found in the LICENSE file
28+
** in the root directory of this software component.
29+
** If no LICENSE file comes with this software, it is provided AS-IS.
30+
**
31+
******************************************************************************
32+
*/
33+
34+
/* Entry Point */
35+
ENTRY(Reset_Handler)
36+
37+
/* Highest address of the user mode stack */
38+
_estack = ORIGIN(AXISRAM1) + LENGTH(AXISRAM1); /* end of "RAM" Ram type memory */
39+
_sstack = _estack - _Min_Stack_Size;
40+
41+
_Min_Heap_Size = 0x200; /* required amount of heap */
42+
_Min_Stack_Size = 0x800; /* required amount of stack */
43+
44+
/* Memories definition */
45+
MEMORY
46+
{
47+
AXISRAM1 (xrw) : ORIGIN = 0x34000000, LENGTH = 1024K
48+
BL_FLAG_RAM (xrw) : ORIGIN = 0x34100000, LENGTH = 64 /* Bootloader flag in RAM */
49+
ROM (xrw) : ORIGIN = 0x70100400, LENGTH = 255K
50+
}
51+
52+
/* Sections */
53+
SECTIONS
54+
{
55+
.bootloader_flag_ram (NOLOAD):
56+
{
57+
. = ALIGN(4);
58+
KEEP(*(.bootloader_flag_ram))
59+
. = ALIGN(4);
60+
} >BL_FLAG_RAM
61+
62+
/* The startup code into "RAM" Ram type memory */
63+
.isr_vector :
64+
{
65+
. = ALIGN(4);
66+
KEEP(*(.isr_vector)) /* Startup code */
67+
. = ALIGN(4);
68+
} >ROM
69+
70+
/* The program code and other data into "RAM" Ram type memory */
71+
.text :
72+
{
73+
. = ALIGN(4);
74+
*(.text) /* .text sections (code) */
75+
*(.text*) /* .text* sections (code) */
76+
*(.glue_7) /* glue arm to thumb code */
77+
*(.glue_7t) /* glue thumb to arm code */
78+
*(.eh_frame)
79+
*(.RamFunc) /* .RamFunc sections */
80+
*(.RamFunc*) /* .RamFunc* sections */
81+
82+
KEEP (*(.init))
83+
KEEP (*(.fini))
84+
85+
. = ALIGN(4);
86+
_etext = .; /* define a global symbols at end of code */
87+
} >ROM
88+
89+
/* Constant data into "RAM" Ram type memory */
90+
.rodata :
91+
{
92+
. = ALIGN(4);
93+
*(.rodata) /* .rodata sections (constants, strings, etc.) */
94+
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
95+
. = ALIGN(4);
96+
} >ROM
97+
98+
.ARM.extab (READONLY) : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
99+
{
100+
. = ALIGN(4);
101+
*(.ARM.extab* .gnu.linkonce.armextab.*)
102+
. = ALIGN(4);
103+
} >ROM
104+
105+
.ARM (READONLY) : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
106+
{
107+
. = ALIGN(4);
108+
__exidx_start = .;
109+
*(.ARM.exidx*)
110+
__exidx_end = .;
111+
. = ALIGN(4);
112+
} >ROM
113+
114+
.preinit_array (READONLY) : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
115+
{
116+
. = ALIGN(4);
117+
PROVIDE_HIDDEN (__preinit_array_start = .);
118+
KEEP (*(.preinit_array*))
119+
PROVIDE_HIDDEN (__preinit_array_end = .);
120+
. = ALIGN(4);
121+
} >ROM
122+
123+
.init_array (READONLY) : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
124+
{
125+
. = ALIGN(4);
126+
PROVIDE_HIDDEN (__init_array_start = .);
127+
KEEP (*(SORT(.init_array.*)))
128+
KEEP (*(.init_array*))
129+
PROVIDE_HIDDEN (__init_array_end = .);
130+
. = ALIGN(4);
131+
} >ROM
132+
133+
.fini_array (READONLY) : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
134+
{
135+
. = ALIGN(4);
136+
PROVIDE_HIDDEN (__fini_array_start = .);
137+
KEEP (*(SORT(.fini_array.*)))
138+
KEEP (*(.fini_array*))
139+
PROVIDE_HIDDEN (__fini_array_end = .);
140+
. = ALIGN(4);
141+
} >ROM
142+
143+
/* Used by the startup to initialize data */
144+
_sidata = LOADADDR(.data);
145+
146+
/* Initialized data sections into "RAM" Ram type memory */
147+
.data :
148+
{
149+
. = ALIGN(4);
150+
_sdata = .; /* create a global symbol at data start */
151+
*(.data) /* .data sections */
152+
*(.data*) /* .data* sections */
153+
154+
. = ALIGN(4);
155+
_edata = .; /* define a global symbol at data end */
156+
157+
} >AXISRAM1 AT> ROM
158+
159+
.noncacheable :
160+
{
161+
. = ALIGN(8);
162+
__snoncacheable = .;/* create symbol for start of section */
163+
KEEP(*(.noncacheable))
164+
. = ALIGN(8);
165+
__enoncacheable = .; /* create symbol for end of section */
166+
} > AXISRAM1
167+
168+
169+
.gnu.sgstubs :
170+
{
171+
. = ALIGN(4);
172+
*(.gnu.sgstubs*) /* Secure Gateway stubs */
173+
. = ALIGN(4);
174+
} >ROM
175+
/* Uninitialized data section into "RAM" Ram type memory */
176+
. = ALIGN(4);
177+
.bss :
178+
{
179+
/* This is used by the startup in order to initialize the .bss section */
180+
_sbss = .; /* define a global symbol at bss start */
181+
__bss_start__ = _sbss;
182+
*(.bss)
183+
*(.bss*)
184+
*(COMMON)
185+
186+
. = ALIGN(4);
187+
_ebss = .; /* define a global symbol at bss end */
188+
__bss_end__ = _ebss;
189+
} >AXISRAM1
190+
191+
/* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
192+
._user_heap_stack :
193+
{
194+
. = ALIGN(8);
195+
PROVIDE ( end = . );
196+
PROVIDE ( _end = . );
197+
. = . + _Min_Heap_Size;
198+
. = . + _Min_Stack_Size;
199+
. = ALIGN(8);
200+
} >AXISRAM1
201+
202+
/* Remove information from the compiler libraries */
203+
/DISCARD/ :
204+
{
205+
libc.a ( * )
206+
libm.a ( * )
207+
libgcc.a ( * )
208+
}
209+
210+
.ARM.attributes 0 : { *(.ARM.attributes) }
211+
}

0 commit comments

Comments
 (0)