Skip to content

Commit 39be009

Browse files
authored
Merge pull request #1680 from LynnL4/port-stm32u5xx
Port stm32u5xx
2 parents e79325a + 4238467 commit 39be009

File tree

13 files changed

+1063
-0
lines changed

13 files changed

+1063
-0
lines changed

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,9 @@
149149
[submodule "hw/mcu/raspberry_pi/Pico-PIO-USB"]
150150
path = hw/mcu/raspberry_pi/Pico-PIO-USB
151151
url = https://github.com/sekigon-gonnoc/Pico-PIO-USB.git
152+
[submodule "/home/ubuntu/tinyusb/hw/mcu/st/cmsis_device_u5"]
153+
path = /home/ubuntu/tinyusb/hw/mcu/st/cmsis_device_u5
154+
url = https://github.com/STMicroelectronics/cmsis_device_u5
155+
[submodule "/home/ubuntu/tinyusb/hw/mcu/st/stm32u5xx_hal_driver"]
156+
path = /home/ubuntu/tinyusb/hw/mcu/st/stm32u5xx_hal_driver
157+
url = https://github.com/STMicroelectronics/stm32u5xx_hal_driver

hw/bsp/board_mcu.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@
9898
#elif CFG_TUSB_MCU == OPT_MCU_STM32WB
9999
#include "stm32wbxx.h"
100100

101+
#elif CFG_TUSB_MCU == OPT_MCU_STM32U5
102+
#include "stm32u5xx.h"
103+
101104
#elif CFG_TUSB_MCU == OPT_MCU_CXD56
102105
// no header needed
103106

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
/*
2+
******************************************************************************
3+
**
4+
** File : LinkerScript.ld
5+
**
6+
** Author : STM32CubeIDE
7+
**
8+
** Abstract : Linker script for STM32U575xI Device from STM32U5 series
9+
** 2048Kbytes FLASH
10+
** 784Kbytes RAM
11+
**
12+
** Set heap size, stack size and stack location according
13+
** to application requirements.
14+
**
15+
** Set memory bank area and size if external memory is used.
16+
**
17+
** Target : STMicroelectronics STM32
18+
**
19+
** Distribution: The file is distributed as is without any warranty
20+
** of any kind.
21+
**
22+
*****************************************************************************
23+
** @attention
24+
**
25+
** Copyright (c) 2022 STMicroelectronics.
26+
** All rights reserved.
27+
**
28+
** This software is licensed under terms that can be found in the LICENSE file
29+
** in the root directory of this software component.
30+
** If no LICENSE file comes with this software, it is provided AS-IS.
31+
**
32+
*****************************************************************************
33+
*/
34+
35+
/* Entry Point */
36+
ENTRY(Reset_Handler)
37+
38+
/* Highest address of the user mode stack */
39+
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
40+
41+
_Min_Heap_Size = 0x200 ; /* required amount of heap */
42+
_Min_Stack_Size = 0x400 ; /* required amount of stack */
43+
44+
/* Memories definition */
45+
MEMORY
46+
{
47+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 768K
48+
SRAM4 (xrw) : ORIGIN = 0x28000000, LENGTH = 16K
49+
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K
50+
}
51+
52+
/* Sections */
53+
SECTIONS
54+
{
55+
/* The startup code into "FLASH" Rom type memory */
56+
.isr_vector :
57+
{
58+
KEEP(*(.isr_vector)) /* Startup code */
59+
} >FLASH
60+
61+
/* The program code and other data into "FLASH" Rom type memory */
62+
.text :
63+
{
64+
*(.text) /* .text sections (code) */
65+
*(.text*) /* .text* sections (code) */
66+
*(.glue_7) /* glue arm to thumb code */
67+
*(.glue_7t) /* glue thumb to arm code */
68+
*(.eh_frame)
69+
70+
KEEP (*(.init))
71+
KEEP (*(.fini))
72+
73+
_etext = .; /* define a global symbols at end of code */
74+
} >FLASH
75+
76+
/* Constant data into "FLASH" Rom type memory */
77+
.rodata :
78+
{
79+
*(.rodata) /* .rodata sections (constants, strings, etc.) */
80+
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
81+
} >FLASH
82+
83+
.ARM.extab :
84+
{
85+
*(.ARM.extab* .gnu.linkonce.armextab.*)
86+
} >FLASH
87+
88+
.ARM :
89+
{
90+
__exidx_start = .;
91+
*(.ARM.exidx*)
92+
__exidx_end = .;
93+
} >FLASH
94+
95+
.preinit_array :
96+
{
97+
PROVIDE_HIDDEN (__preinit_array_start = .);
98+
KEEP (*(.preinit_array*))
99+
PROVIDE_HIDDEN (__preinit_array_end = .);
100+
} >FLASH
101+
102+
.init_array :
103+
{
104+
PROVIDE_HIDDEN (__init_array_start = .);
105+
KEEP (*(SORT(.init_array.*)))
106+
KEEP (*(.init_array*))
107+
PROVIDE_HIDDEN (__init_array_end = .);
108+
} >FLASH
109+
110+
.fini_array :
111+
{
112+
PROVIDE_HIDDEN (__fini_array_start = .);
113+
KEEP (*(SORT(.fini_array.*)))
114+
KEEP (*(.fini_array*))
115+
PROVIDE_HIDDEN (__fini_array_end = .);
116+
} >FLASH
117+
118+
/* Used by the startup to initialize data */
119+
_sidata = LOADADDR(.data);
120+
121+
/* Initialized data sections into "RAM" Ram type memory */
122+
.data :
123+
{
124+
_sdata = .; /* create a global symbol at data start */
125+
*(.data) /* .data sections */
126+
*(.data*) /* .data* sections */
127+
*(.RamFunc) /* .RamFunc sections */
128+
*(.RamFunc*) /* .RamFunc* sections */
129+
130+
_edata = .; /* define a global symbol at data end */
131+
} >RAM AT> FLASH
132+
133+
/* Uninitialized data section into "RAM" Ram type memory */
134+
.bss :
135+
{
136+
/* This is used by the startup in order to initialize the .bss section */
137+
_sbss = .; /* define a global symbol at bss start */
138+
__bss_start__ = _sbss;
139+
*(.bss)
140+
*(.bss*)
141+
*(COMMON)
142+
143+
_ebss = .; /* define a global symbol at bss end */
144+
__bss_end__ = _ebss;
145+
} >RAM
146+
147+
/* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
148+
._user_heap_stack :
149+
{
150+
. = ALIGN(8);
151+
PROVIDE ( end = . );
152+
PROVIDE ( _end = . );
153+
. = . + _Min_Heap_Size;
154+
. = . + _Min_Stack_Size;
155+
. = ALIGN(8);
156+
} >RAM
157+
158+
/* Remove information from the compiler libraries */
159+
/DISCARD/ :
160+
{
161+
libc.a ( * )
162+
libm.a ( * )
163+
libgcc.a ( * )
164+
}
165+
166+
.ARM.attributes 0 : { *(.ARM.attributes) }
167+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2022, Hongtai Liu <[email protected]>
5+
* Ha Thach (tinyusb.org)
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*
25+
* This file is part of the TinyUSB stack.
26+
*/
27+
28+
#ifndef BOARD_H_
29+
#define BOARD_H_
30+
31+
#ifdef __cplusplus
32+
extern "C"
33+
{
34+
#endif
35+
36+
// LED GREEN
37+
#define LED_PORT GPIOB
38+
#define LED_PIN GPIO_PIN_7
39+
#define LED_STATE_ON 1
40+
41+
// // LED
42+
#define BUTTON_PORT GPIOC
43+
#define BUTTON_PIN GPIO_PIN_13
44+
#define BUTTON_STATE_ACTIVE 1
45+
46+
// UART Enable for STLink VCOM
47+
#define UART_DEV USART1
48+
#define UART_CLK_EN __HAL_RCC_USART1_CLK_ENABLE
49+
#define UART_GPIO_PORT GPIOA
50+
#define UART_GPIO_AF GPIO_AF7_USART1
51+
#define UART_TX_PIN GPIO_PIN_9
52+
#define UART_RX_PIN GPIO_PIN_10
53+
54+
//--------------------------------------------------------------------+
55+
// RCC Clock
56+
//--------------------------------------------------------------------+
57+
58+
static inline void board_clock_init(void)
59+
{
60+
61+
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
62+
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
63+
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
64+
65+
/* Enable Power Clock*/
66+
__HAL_RCC_PWR_CLK_ENABLE();
67+
68+
/** Configure the main internal regulator output voltage
69+
*/
70+
HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);
71+
72+
/** Initializes the CPU, AHB and APB busses clocks
73+
*/
74+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_HSI;
75+
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
76+
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
77+
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
78+
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
79+
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
80+
RCC_OscInitStruct.PLL.PLLMBOOST = RCC_PLLMBOOST_DIV1;
81+
RCC_OscInitStruct.PLL.PLLM = 1;
82+
RCC_OscInitStruct.PLL.PLLN = 10;
83+
RCC_OscInitStruct.PLL.PLLP = 2;
84+
RCC_OscInitStruct.PLL.PLLQ = 2;
85+
RCC_OscInitStruct.PLL.PLLR = 1;
86+
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLLVCIRANGE_1;
87+
RCC_OscInitStruct.PLL.PLLFRACN = 0;
88+
HAL_RCC_OscConfig(&RCC_OscInitStruct);
89+
90+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_CLK48;
91+
PeriphClkInit.IclkClockSelection = RCC_CLK48CLKSOURCE_HSI48;
92+
93+
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit);
94+
95+
/** Initializes the CPU, AHB and APB busses clocks
96+
*/
97+
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_PCLK3;
98+
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
99+
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
100+
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
101+
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
102+
RCC_ClkInitStruct.APB3CLKDivider = RCC_HCLK_DIV1;
103+
104+
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);
105+
}
106+
107+
108+
#ifdef __cplusplus
109+
}
110+
#endif
111+
112+
#endif /* BOARD_H_ */
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CFLAGS += \
2+
-DSTM32U575xx \
3+
4+
# All source paths should be relative to the top level.
5+
LD_FILE = $(BOARD_PATH)/STM32U575AIIXQ_FLASH.ld
6+
7+
SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32u575xx.s
8+
9+
# For flash-jlink target
10+
JLINK_DEVICE = stm32u575

0 commit comments

Comments
 (0)