Skip to content

Commit c1226ff

Browse files
author
Cruz Monrreal
authored
Merge pull request #8916 from jeromecoutant/PR_F439
STM32F429/STM32F439 alignment
2 parents 671c061 + a8c87c0 commit c1226ff

File tree

20 files changed

+152
-152
lines changed

20 files changed

+152
-152
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Permissive Binary License
2+
3+
Version 1.0, September 2015
4+
5+
Redistribution. Redistribution and use in binary form, without
6+
modification, are permitted provided that the following conditions are
7+
met:
8+
9+
1) Redistributions must reproduce the above copyright notice and the
10+
following disclaimer in the documentation and/or other materials
11+
provided with the distribution.
12+
13+
2) Unless to the extent explicitly permitted by law, no reverse
14+
engineering, decompilation, or disassembly of this software is
15+
permitted.
16+
17+
3) Redistribution as part of a software development kit must include the
18+
accompanying file named "DEPENDENCIES" and any dependencies listed in
19+
that file.
20+
21+
4) Neither the name of the copyright holder nor the names of its
22+
contributors may be used to endorse or promote products derived from
23+
this software without specific prior written permission.
24+
25+
Limited patent license. The copyright holders (and contributors) grant a
26+
worldwide, non-exclusive, no-charge, royalty-free patent license to
27+
make, have made, use, offer to sell, sell, import, and otherwise
28+
transfer this software, where such license applies only to those patent
29+
claims licensable by the copyright holders (and contributors) that are
30+
necessarily infringed by this software. This patent license shall not
31+
apply to any combinations that include this software. No hardware is
32+
licensed hereunder.
33+
34+
If you institute patent litigation against any entity (including a
35+
cross-claim or counterclaim in a lawsuit) alleging that the software
36+
itself infringes your patent(s), then your rights granted under this
37+
license shall terminate as of the date such litigation is filed.
38+
39+
DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
40+
CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
41+
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
42+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
43+
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
45+
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
47+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
48+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
49+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "bootloader_NUCLEO_F439ZI",
3+
"target_overrides": {
4+
"*": {
5+
"target.app_offset": "0x10400",
6+
"target.header_offset": "0x10000",
7+
"target.bootloader_img": "mbed-bootloader-nucleo_f439zi-block_device-sotp-v3_4_0.bin"
8+
}
9+
}
10+
}

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F429xI/TARGET_DISCO_F429ZI/system_clock.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
**/
3131

3232
#include "stm32f4xx.h"
33-
33+
#include "nvic_addr.h"
3434
#include "mbed_error.h"
3535

3636
// clock source is selected with CLOCK_SOURCE in json config
@@ -56,6 +56,10 @@ uint8_t SetSysClock_PLL_HSI(void);
5656
*/
5757
void SystemInit(void)
5858
{
59+
/* FPU settings ------------------------------------------------------------*/
60+
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
61+
SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); /* set CP10 and CP11 Full Access */
62+
#endif
5963
/* Reset the RCC clock configuration to the default reset state ------------*/
6064
/* Set HSION bit */
6165
RCC->CR |= (uint32_t)0x00000001;
@@ -79,6 +83,13 @@ void SystemInit(void)
7983
SystemInit_ExtMemCtl();
8084
#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
8185

86+
/* Configure the Vector Table location add offset address ------------------*/
87+
#ifdef VECT_TAB_SRAM
88+
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
89+
#else
90+
SCB->VTOR = NVIC_FLASH_VECTOR_ADDRESS; /* Vector Table Relocation in Internal FLASH */
91+
#endif
92+
8293
}
8394

8495
/**

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F429xI/TARGET_NUCLEO_F429ZI/system_clock.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
**/
3131

3232
#include "stm32f4xx.h"
33-
33+
#include "nvic_addr.h"
3434
#include "mbed_error.h"
3535

3636
// clock source is selected with CLOCK_SOURCE in json config
@@ -56,6 +56,10 @@ uint8_t SetSysClock_PLL_HSI(void);
5656
*/
5757
void SystemInit(void)
5858
{
59+
/* FPU settings ------------------------------------------------------------*/
60+
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
61+
SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); /* set CP10 and CP11 Full Access */
62+
#endif
5963
/* Reset the RCC clock configuration to the default reset state ------------*/
6064
/* Set HSION bit */
6165
RCC->CR |= (uint32_t)0x00000001;
@@ -79,6 +83,13 @@ void SystemInit(void)
7983
SystemInit_ExtMemCtl();
8084
#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
8185

86+
/* Configure the Vector Table location add offset address ------------------*/
87+
#ifdef VECT_TAB_SRAM
88+
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
89+
#else
90+
SCB->VTOR = NVIC_FLASH_VECTOR_ADDRESS; /* Vector Table Relocation in Internal FLASH */
91+
#endif
92+
8293
}
8394

8495
/**

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F429xI/device/TOOLCHAIN_ARM_STD/startup_stm32f429xx.S

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,9 @@ __Vectors_Size EQU __Vectors_End - __Vectors
168168
; Reset handler
169169
Reset_Handler PROC
170170
EXPORT Reset_Handler [WEAK]
171-
IMPORT SystemInitPre
172-
IMPORT HAL_InitPre
173171
IMPORT SystemInit
174172
IMPORT __main
175173

176-
LDR R0, =SystemInitPre
177-
BLX R0
178-
LDR R0, =HAL_InitPre
179-
BLX R0
180174
LDR R0, =SystemInit
181175
BLX R0
182176
LDR R0, =__main

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F429xI/device/TOOLCHAIN_ARM_STD/stm32f429xx.sct

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#define MBED_RAM0_START (MBED_CRASH_REPORT_RAM_START + MBED_CRASH_REPORT_RAM_SIZE)
4646
#define MBED_RAM0_SIZE (MBED_RAM_SIZE - MBED_VECTTABLE_RAM_SIZE - MBED_CRASH_REPORT_RAM_SIZE)
4747

48-
; 2 MB FLASH (0x200000) + 192 KB SRAM (0x30000)
48+
; 2 MB FLASH (0x200000) + 256 KB SRAM (0x30000 + 0x10000)
4949
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
5050

5151
ER_IROM1 MBED_APP_START MBED_APP_SIZE { ; load address = execution address
@@ -61,6 +61,9 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
6161
RW_IRAM1 (MBED_RAM0_START) (MBED_RAM0_SIZE) { ; RW data
6262
.ANY (+RW +ZI)
6363
}
64-
64+
65+
RW_IRAM2 (0x10000000) (0x10000) { ; RW data
66+
.ANY (+RW +ZI)
67+
}
6568
}
6669

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F429xI/device/TOOLCHAIN_GCC_ARM/STM32F429xI.ld

Lines changed: 27 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
M_VECTOR_RAM_SIZE = 0x400;
2-
3-
/* With the RTOS in use, this does not affect the main stack size. The size of
4-
* the stack where main runs is determined via the RTOS. */
5-
STACK_SIZE = 0x400;
6-
7-
HEAP_SIZE = 0x6000;
8-
91
#if !defined(MBED_APP_START)
102
#define MBED_APP_START 0x08000000
113
#endif
@@ -16,13 +8,13 @@ HEAP_SIZE = 0x6000;
168

179
M_CRASH_DATA_RAM_SIZE = 0x100;
1810

19-
/* Specify the memory areas */
11+
/* Linker script to configure memory regions. */
12+
/* 0x1AC resevered for vectors; 8-byte aligned = 0x1B0 (0x1AC + 0x4)*/
2013
MEMORY
21-
{
22-
VECTORS (rx) : ORIGIN = MBED_APP_START, LENGTH = 0x400
23-
FLASH (rx) : ORIGIN = MBED_APP_START + 0x400, LENGTH = MBED_APP_SIZE - 0x400
24-
CCM (rwx) : ORIGIN = 0x10000000, LENGTH = 64K
25-
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 192k
14+
{
15+
FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE
16+
CCM (rwx) : ORIGIN = 0x10000000, LENGTH = 64K
17+
RAM (rwx) : ORIGIN = 0x200001B0, LENGTH = 192k - (0x1AC+0x4)
2618
}
2719

2820
/* Linker script to place sections and symbol values. Should be used together
@@ -56,18 +48,10 @@ ENTRY(Reset_Handler)
5648

5749
SECTIONS
5850
{
59-
.isr_vector :
60-
{
61-
__vector_table = .;
62-
KEEP(*(.isr_vector))
63-
. = ALIGN(8);
64-
} > VECTORS
65-
6651
.text :
6752
{
68-
53+
KEEP(*(.isr_vector))
6954
*(.text*)
70-
7155
KEEP(*(.init))
7256
KEEP(*(.fini))
7357

@@ -96,7 +80,6 @@ SECTIONS
9680
} > FLASH
9781

9882
__exidx_start = .;
99-
10083
.ARM.exidx :
10184
{
10285
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
@@ -105,17 +88,6 @@ SECTIONS
10588

10689
__etext = .;
10790
_sidata = .;
108-
109-
.interrupts_ram :
110-
{
111-
. = ALIGN(8);
112-
__VECTOR_RAM__ = .;
113-
__interrupts_ram_start__ = .; /* Create a global symbol at data start */
114-
*(.m_interrupts_ram) /* This is a user defined section */
115-
. += M_VECTOR_RAM_SIZE;
116-
. = ALIGN(8);
117-
__interrupts_ram_end__ = .; /* Define a global symbol at data end */
118-
} > RAM
11991

12092
.crash_data_ram :
12193
{
@@ -127,12 +99,10 @@ SECTIONS
12799
. += M_CRASH_DATA_RAM_SIZE;
128100
. = ALIGN(8);
129101
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
130-
} > RAM
102+
} > RAM
131103

132-
.data :
104+
.data : AT (__etext)
133105
{
134-
PROVIDE( __etext = LOADADDR(.data) );
135-
136106
__data_start__ = .;
137107
_sdata = .;
138108
*(vtable)
@@ -165,23 +135,9 @@ SECTIONS
165135
__data_end__ = .;
166136
_edata = .;
167137

168-
} > RAM AT > FLASH
169-
170-
171-
/* Uninitialized data section
172-
* This region is not initialized by the C/C++ library and can be used to
173-
* store state across soft reboots. */
174-
.uninitialized (NOLOAD):
175-
{
176-
. = ALIGN(32);
177-
__uninitialized_start = .;
178-
*(.uninitialized)
179-
KEEP(*(.keep.uninitialized))
180-
. = ALIGN(32);
181-
__uninitialized_end = .;
182138
} > RAM
183139

184-
.bss (NOLOAD):
140+
.bss :
185141
{
186142
. = ALIGN(8);
187143
__bss_start__ = .;
@@ -193,18 +149,29 @@ SECTIONS
193149
_ebss = .;
194150
} > RAM
195151

196-
.heap (NOLOAD):
152+
.heap (COPY):
197153
{
198154
__end__ = .;
199155
end = __end__;
200-
. += HEAP_SIZE;
156+
*(.heap*)
201157
__HeapLimit = .;
202158
} > RAM
203159

204-
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
205-
__stack = __StackTop;
206-
__StackLimit = __StackTop - STACK_SIZE;
160+
/* .stack_dummy section doesn't contains any symbols. It is only
161+
* used for linker to calculate size of stack sections, and assign
162+
* values to stack symbols later */
163+
.stack_dummy (COPY):
164+
{
165+
*(.stack*)
166+
} > RAM
207167

208-
ASSERT(__StackLimit >= __HeapLimit, "Region RAM overflowed with stack and heap")
168+
/* Set stack top to end of RAM, and stack limit move down by
169+
* size of stack_dummy section */
170+
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
171+
_estack = __StackTop;
172+
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
173+
PROVIDE(__stack = __StackTop);
209174

175+
/* Check if data + heap + stack exceeds RAM limit */
176+
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
210177
}

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F429xI/device/TOOLCHAIN_GCC_ARM/startup_stm32f429xx.S

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ defined in linker script */
7474
.section .text.Reset_Handler
7575
.weak Reset_Handler
7676
.type Reset_Handler, %function
77-
Reset_Handler:
78-
ldr sp, =__stack /* set stack pointer */
79-
80-
/* Copy the data segment initializers from flash to SRAM */
77+
Reset_Handler:
78+
ldr sp, =_estack /* set stack pointer */
79+
80+
/* Copy the data segment initializers from flash to SRAM */
8181
movs r1, #0
8282
b LoopCopyDataInit
8383

@@ -106,8 +106,6 @@ LoopFillZerobss:
106106
bcc FillZerobss
107107

108108
/* Call the clock system intitialization function.*/
109-
bl SystemInitPre
110-
bl HAL_InitPre
111109
bl SystemInit
112110
/* Call static constructors */
113111
//bl __libc_init_array
@@ -142,10 +140,10 @@ Infinite_Loop:
142140
*******************************************************************************/
143141
.section .isr_vector,"a",%progbits
144142
.type g_pfnVectors, %object
145-
.size g_pfnVectors, .-g_pfnVectors
146-
147-
g_pfnVectors:
148-
.word __stack
143+
.size g_pfnVectors, .-g_pfnVectors
144+
145+
g_pfnVectors:
146+
.word _estack
149147
.word Reset_Handler
150148

151149
.word NMI_Handler
@@ -212,7 +210,7 @@ g_pfnVectors:
212210
.word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */
213211
.word TIM8_CC_IRQHandler /* TIM8 Capture Compare */
214212
.word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */
215-
.word FMC_IRQHandler /* FMC */
213+
.word FMC_IRQHandler /* FMC */
216214
.word SDIO_IRQHandler /* SDIO */
217215
.word TIM5_IRQHandler /* TIM5 */
218216
.word SPI3_IRQHandler /* SPI3 */
@@ -252,8 +250,8 @@ g_pfnVectors:
252250
.word SPI5_IRQHandler /* SPI5 */
253251
.word SPI6_IRQHandler /* SPI6 */
254252
.word SAI1_IRQHandler /* SAI1 */
255-
.word LTDC_IRQHandler /* LTDC_IRQHandler */
256-
.word LTDC_ER_IRQHandler /* LTDC_ER_IRQHandler */
253+
.word LTDC_IRQHandler /* LTDC */
254+
.word LTDC_ER_IRQHandler /* LTDC error */
257255
.word DMA2D_IRQHandler /* DMA2D */
258256

259257
/*******************************************************************************

0 commit comments

Comments
 (0)