Skip to content

Commit 6de4236

Browse files
committed
nucleo-f439zi support
1 parent a4cfd1c commit 6de4236

File tree

5 files changed

+812
-0
lines changed

5 files changed

+812
-0
lines changed

docs/reference/supported.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ F4
344344
- `STM32 F411ve Discovery <https://www.st.com/en/evaluation-tools/32f411ediscovery.html>`__
345345
- `STM32 F412zg Discovery <https://www.st.com/en/evaluation-tools/32f412gdiscovery.html>`__
346346
- `STM32 F412zg Nucleo <https://www.st.com/en/evaluation-tools/nucleo-f412zg.html>`__
347+
- `STM32 F439zg Nucleo <https://www.st.com/en/evaluation-tools/nucleo-f439zi.html>`__
347348

348349
F7
349350
^^
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
/*
2+
******************************************************************************
3+
**
4+
** @file : LinkerScript.ld
5+
**
6+
** @author : Auto-generated by STM32CubeIDE
7+
**
8+
** Abstract : Linker script for NUCLEO-F439ZI Board embedding STM32F439ZITx Device from stm32f4 series
9+
** 2048Kbytes FLASH
10+
** 64Kbytes CCMRAM
11+
** 192Kbytes RAM
12+
**
13+
** Set heap size, stack size and stack location according
14+
** to application requirements.
15+
**
16+
** Set memory bank area and size if external memory is used
17+
**
18+
** Target : STMicroelectronics STM32
19+
**
20+
** Distribution: The file is distributed as is, without any warranty
21+
** of any kind.
22+
**
23+
******************************************************************************
24+
** @attention
25+
**
26+
** Copyright (c) 2021 STMicroelectronics.
27+
** All rights reserved.
28+
**
29+
** This software is licensed under terms that can be found in the LICENSE file
30+
** in the root directory of this software component.
31+
** If no LICENSE file comes with this software, it is provided AS-IS.
32+
**
33+
******************************************************************************
34+
*/
35+
36+
/* Entry Point */
37+
ENTRY(Reset_Handler)
38+
39+
/* Highest address of the user mode stack */
40+
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
41+
42+
_Min_Heap_Size = 0x200; /* required amount of heap */
43+
_Min_Stack_Size = 0x400; /* required amount of stack */
44+
45+
/* Memories definition */
46+
MEMORY
47+
{
48+
CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K
49+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K
50+
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K
51+
}
52+
53+
/* Sections */
54+
SECTIONS
55+
{
56+
/* The startup code into "FLASH" Rom type memory */
57+
.isr_vector :
58+
{
59+
. = ALIGN(4);
60+
KEEP(*(.isr_vector)) /* Startup code */
61+
. = ALIGN(4);
62+
} >FLASH
63+
64+
/* The program code and other data into "FLASH" Rom type memory */
65+
.text :
66+
{
67+
. = ALIGN(4);
68+
*(.text) /* .text sections (code) */
69+
*(.text*) /* .text* sections (code) */
70+
*(.glue_7) /* glue arm to thumb code */
71+
*(.glue_7t) /* glue thumb to arm code */
72+
*(.eh_frame)
73+
74+
KEEP (*(.init))
75+
KEEP (*(.fini))
76+
77+
. = ALIGN(4);
78+
_etext = .; /* define a global symbols at end of code */
79+
} >FLASH
80+
81+
/* Constant data into "FLASH" Rom type memory */
82+
.rodata :
83+
{
84+
. = ALIGN(4);
85+
*(.rodata) /* .rodata sections (constants, strings, etc.) */
86+
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
87+
. = ALIGN(4);
88+
} >FLASH
89+
90+
.ARM.extab : {
91+
. = ALIGN(4);
92+
*(.ARM.extab* .gnu.linkonce.armextab.*)
93+
. = ALIGN(4);
94+
} >FLASH
95+
96+
.ARM : {
97+
. = ALIGN(4);
98+
__exidx_start = .;
99+
*(.ARM.exidx*)
100+
__exidx_end = .;
101+
. = ALIGN(4);
102+
} >FLASH
103+
104+
.preinit_array :
105+
{
106+
. = ALIGN(4);
107+
PROVIDE_HIDDEN (__preinit_array_start = .);
108+
KEEP (*(.preinit_array*))
109+
PROVIDE_HIDDEN (__preinit_array_end = .);
110+
. = ALIGN(4);
111+
} >FLASH
112+
113+
.init_array :
114+
{
115+
. = ALIGN(4);
116+
PROVIDE_HIDDEN (__init_array_start = .);
117+
KEEP (*(SORT(.init_array.*)))
118+
KEEP (*(.init_array*))
119+
PROVIDE_HIDDEN (__init_array_end = .);
120+
. = ALIGN(4);
121+
} >FLASH
122+
123+
.fini_array :
124+
{
125+
. = ALIGN(4);
126+
PROVIDE_HIDDEN (__fini_array_start = .);
127+
KEEP (*(SORT(.fini_array.*)))
128+
KEEP (*(.fini_array*))
129+
PROVIDE_HIDDEN (__fini_array_end = .);
130+
. = ALIGN(4);
131+
} >FLASH
132+
133+
/* Used by the startup to initialize data */
134+
_sidata = LOADADDR(.data);
135+
136+
/* Initialized data sections into "RAM" Ram type memory */
137+
.data :
138+
{
139+
. = ALIGN(4);
140+
_sdata = .; /* create a global symbol at data start */
141+
*(.data) /* .data sections */
142+
*(.data*) /* .data* sections */
143+
*(.RamFunc) /* .RamFunc sections */
144+
*(.RamFunc*) /* .RamFunc* sections */
145+
146+
. = ALIGN(4);
147+
_edata = .; /* define a global symbol at data end */
148+
149+
} >RAM AT> FLASH
150+
151+
_siccmram = LOADADDR(.ccmram);
152+
153+
/* CCM-RAM section
154+
*
155+
* IMPORTANT NOTE!
156+
* If initialized variables will be placed in this section,
157+
* the startup code needs to be modified to copy the init-values.
158+
*/
159+
.ccmram :
160+
{
161+
. = ALIGN(4);
162+
_sccmram = .; /* create a global symbol at ccmram start */
163+
*(.ccmram)
164+
*(.ccmram*)
165+
166+
. = ALIGN(4);
167+
_eccmram = .; /* create a global symbol at ccmram end */
168+
} >CCMRAM AT> FLASH
169+
170+
/* Uninitialized data section into "RAM" Ram type memory */
171+
. = ALIGN(4);
172+
.bss :
173+
{
174+
/* This is used by the startup in order to initialize the .bss section */
175+
_sbss = .; /* define a global symbol at bss start */
176+
__bss_start__ = _sbss;
177+
*(.bss)
178+
*(.bss*)
179+
*(COMMON)
180+
181+
. = ALIGN(4);
182+
_ebss = .; /* define a global symbol at bss end */
183+
__bss_end__ = _ebss;
184+
} >RAM
185+
186+
/* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
187+
._user_heap_stack :
188+
{
189+
. = ALIGN(8);
190+
PROVIDE ( end = . );
191+
PROVIDE ( _end = . );
192+
. = . + _Min_Heap_Size;
193+
. = . + _Min_Stack_Size;
194+
. = ALIGN(8);
195+
} >RAM
196+
197+
/* Remove information from the compiler libraries */
198+
/DISCARD/ :
199+
{
200+
libc.a ( * )
201+
libm.a ( * )
202+
libgcc.a ( * )
203+
}
204+
205+
.ARM.attributes 0 : { *(.ARM.attributes) }
206+
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2020, Ha Thach (tinyusb.org)
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*
24+
* This file is part of the TinyUSB stack.
25+
*/
26+
27+
#ifndef BOARD_H_
28+
#define BOARD_H_
29+
30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
34+
// LED
35+
#define LED_PORT GPIOB
36+
#define LED_PIN GPIO_PIN_14
37+
#define LED_STATE_ON 0
38+
39+
// Button
40+
#define BUTTON_PORT GPIOC
41+
#define BUTTON_PIN GPIO_PIN_13
42+
#define BUTTON_STATE_ACTIVE 1
43+
44+
// UART Enable for STLink VCOM
45+
#define UART_DEV USART3
46+
#define UART_GPIO_PORT GPIOD
47+
#define UART_GPIO_AF GPIO_AF7_USART3
48+
#define UART_TX_PIN GPIO_PIN_8
49+
#define UART_RX_PIN GPIO_PIN_9
50+
51+
//--------------------------------------------------------------------+
52+
// RCC Clock
53+
//--------------------------------------------------------------------+
54+
static inline void board_clock_init(void)
55+
{
56+
RCC_ClkInitTypeDef RCC_ClkInitStruct;
57+
RCC_OscInitTypeDef RCC_OscInitStruct;
58+
59+
/* Enable Power Control clock */
60+
__HAL_RCC_PWR_CLK_ENABLE();
61+
62+
/* The voltage scaling allows optimizing the power consumption when the
63+
* device is clocked below the maximum system frequency, to update the
64+
* voltage scaling value regarding system frequency refer to product
65+
* datasheet. */
66+
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
67+
68+
/* Enable HSE Oscillator and activate PLL with HSE as source */
69+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
70+
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
71+
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
72+
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
73+
RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000;
74+
RCC_OscInitStruct.PLL.PLLN = 336;
75+
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
76+
RCC_OscInitStruct.PLL.PLLQ = 7;
77+
HAL_RCC_OscConfig(&RCC_OscInitStruct);
78+
79+
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
80+
* clocks dividers */
81+
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK |
82+
RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
83+
84+
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
85+
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
86+
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
87+
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
88+
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
89+
90+
// Enable clocks for LED, Button, Uart
91+
__HAL_RCC_GPIOB_CLK_ENABLE();
92+
__HAL_RCC_GPIOC_CLK_ENABLE();
93+
__HAL_RCC_GPIOD_CLK_ENABLE();
94+
__HAL_RCC_USART3_CLK_ENABLE();
95+
}
96+
97+
static inline void board_vbus_sense_init(void)
98+
{
99+
// Enable VBUS sense (B device) via pin PA9
100+
USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS;
101+
USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBUSBSEN;
102+
}
103+
104+
#ifdef __cplusplus
105+
}
106+
#endif
107+
108+
#endif /* BOARD_H_ */
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CFLAGS += -DSTM32F439xx
2+
3+
LD_FILE = $(BOARD_PATH)/STM32F439ZITX_FLASH.ld
4+
5+
SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f439xx.s
6+
7+
# For flash-jlink target
8+
JLINK_DEVICE = stm32f439zi
9+
10+
# flash target using on-board stlink
11+
flash: flash-stlink

0 commit comments

Comments
 (0)