Skip to content

Commit 84ebf38

Browse files
authored
add stm32g474-st-nucleo bsp (#5362)
* add stm32g474-st-nucleo bsp * format * format
1 parent 42abaf6 commit 84ebf38

37 files changed

+13148
-0
lines changed

bsp/stm32/stm32g474-st-nucleo/.config

Lines changed: 651 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
*.pyc
2+
*.map
3+
*.dblite
4+
*.elf
5+
*.bin
6+
*.hex
7+
*.axf
8+
*.exe
9+
*.pdb
10+
*.idb
11+
*.ilk
12+
*.old
13+
build
14+
Debug
15+
documentation/html
16+
packages/
17+
*~
18+
*.o
19+
*.obj
20+
*.out
21+
*.bak
22+
*.dep
23+
*.lib
24+
*.i
25+
*.d
26+
.DS_Stor*
27+
.config 3
28+
.config 4
29+
.config 5
30+
Midea-X1
31+
*.uimg
32+
GPATH
33+
GRTAGS
34+
GTAGS
35+
.vscode
36+
JLinkLog.txt
37+
JLinkSettings.ini
38+
DebugConfig/
39+
RTE/
40+
settings/
41+
*.uvguix*
42+
cconfig.h
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
mainmenu "RT-Thread Configuration"
2+
3+
config BSP_DIR
4+
string
5+
option env="BSP_ROOT"
6+
default "."
7+
8+
config RTT_DIR
9+
string
10+
option env="RTT_ROOT"
11+
default "../../.."
12+
13+
config PKGS_DIR
14+
string
15+
option env="PKGS_ROOT"
16+
default "packages"
17+
18+
source "$RTT_DIR/Kconfig"
19+
source "$PKGS_DIR/Kconfig"
20+
source "../libraries/Kconfig"
21+
source "board/Kconfig"
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# STM32G431-Nucleo BSP Introduction
2+
3+
[中文](README_zh.md)
4+
5+
## MCU: STM32G474RB @170MHz, 512KB FLASH, 128KB RAM
6+
7+
The STM32G474xB/xC/xE devices are based on the high-performance Arm® Cortex®-M4 32-bit RISC core. They operate at a frequency of up to 170 MHz. The Cortex-M4 core features a single-precision floating-point unit (FPU), which supports all the Arm single-precision data-processing instructions and all the data types. It also implements a full set of DSP (digital signal processing) instructions and a memory protection unit (MPU) which enhances the application’s security.
8+
These devices embed high-speed memories (up to 512 Kbytes of Flash memory, and 128 Kbytes of SRAM), a flexible external memory controller (FSMC) for static memories (for devices with packages of 100 pins and more), a Quad-SPI Flash memory interface, and an extensive range of enhanced I/Os and peripherals connected to two APB buses, two AHB buses and a 32-bit multi-AHB bus matrix.
9+
The devices also embed several protection mechanisms for embedded Flash memory and SRAM: readout protection, write protection, securable memory area and proprietary code readout protection.
10+
The devices embed peripherals allowing mathematical/arithmetic function acceleration (CORDIC for trigonometric functions and FMAC unit for filter functions).
11+
They offer five fast 12-bit ADCs (4 Msps), seven comparators, six operational amplifiers, seven DAC channels (3 external and 4 internal), an internal voltage reference buffer, a low-power RTC, two general-purpose 32-bit timers, three 16-bit PWM timers dedicated to motor control, seven general-purpose 16-bit timers, and one 16-bit low-power timer, and high resolution timer with 184 ps resolution.
12+
They also feature standard and advanced communication interfaces such as:
13+
\- Four I2Cs
14+
\- Four SPIs multiplexed with two half duplex I2Ss
15+
\- Three USARTs, two UARTs and one low-power UART.
16+
\- Three FDCANs
17+
\- One SAI
18+
\- USB device
19+
\- UCPD
20+
The devices operate in the -40 to +85 °C (+105 °C junction) and -40 to +125 °C (+130 °C junction) temperature ranges from a 1.71 to 3.6 V power supply. A comprehensive set of power-saving modes allows the design of low-power applications.
21+
Some independent power supplies are supported including an analog independent supply input for ADC, DAC, OPAMPs and comparators. A VBAT input allows backup of the RTC and the registers.
22+
The STM32G474xB/xC/xE family offers 9 packages from 48-pin to 128-pin.
23+
24+
#### KEY FEATURES
25+
26+
- Core: Arm® 32-bit Cortex®-M4 CPU with FPU, Adaptive real-time accelerator (ART Accelerator) allowing 0-wait-state execution from Flash memory, frequency up to 170 MHz with 213 DMIPS, MPU, DSP instructions
27+
- Operating conditions:
28+
- VDD, VDDA voltage range: 1.71 V to 3.6 V
29+
- Mathematical hardware accelerators
30+
- CORDIC for trigonometric functions acceleration
31+
- FMAC: filter mathematical accelerator
32+
- Memories
33+
- 512 Kbytes of Flash memory with ECC support, two banks read-while-write, proprietary code readout protection (PCROP), securable memory area, 1 Kbyte OTP
34+
- 96 Kbytes of SRAM, with hardware parity check implemented on the first 32 Kbytes
35+
- Routine booster: 32 Kbytes of SRAM on instruction and data bus, with hardware parity check (CCM SRAM)
36+
- External memory interface for static memories FSMC supporting SRAM, PSRAM, NOR and NAND memories
37+
- Quad-SPI memory interface
38+
- Reset and supply management
39+
- Power-on/power-down reset (POR/PDR/BOR)
40+
- Programmable voltage detector (PVD)
41+
- Low-power modes: sleep, stop, standby and shutdown
42+
- VBAT supply for RTC and backup registers
43+
- Clock management
44+
- 4 to 48 MHz crystal oscillator
45+
- 32 kHz oscillator with calibration
46+
- Internal 16 MHz RC with PLL option (± 1%)
47+
- Internal 32 kHz RC oscillator (± 5%)
48+
- Up to 107 fast I/Os
49+
- All mappable on external interrupt vectors
50+
- Several I/Os with 5 V tolerant capability
51+
- Interconnect matrix
52+
- 16-channel DMA controller
53+
- 5 x 12-bit ADCs 0.25 µs, up to 42 channels. Resolution up to 16-bit with hardware oversampling, 0 to 3.6 V conversion range
54+
- 7 x 12-bit DAC channels
55+
- 3 x buffered external channels 1 MSPS
56+
- 4 x unbuffered internal channels 15 MSPS
57+
- 7 x ultra-fast rail-to-rail analog comparators
58+
- 6 x operational amplifiers that can be used in PGA mode, all terminals accessible
59+
- Internal voltage reference buffer (VREFBUF) supporting three output voltages (2.048 V, 2.5 V, 2.9 V)
60+
- 17 timers:
61+
- HRTIM (Hi-Resolution and complex waveform builder): 6 x16-bit counters, 184 ps resolution, 12 PWM
62+
- 2 x 32-bit timer and 2 x 16-bit timers with up to four IC/OC/PWM or pulse counter and quadrature (incremental) encoder input
63+
- 3 x 16-bit 8-channel advanced motor control timers, with up to 8 x PWM channels, dead time generation and emergency stop
64+
- 1 x 16-bit timer with 2 x IC/OCs, one OCN/PWM, dead time generation and emergency stop
65+
- 2 x 16-bit timers with IC/OC/OCN/PWM, dead time generation and emergency stop
66+
- 2 x watchdog timers (independent, window)
67+
- 1 x SysTick timer: 24-bit downcounter
68+
- 2 x 16-bit basic timers
69+
- 1 x low-power timer
70+
- Calendar RTC with alarm, periodic wakeup from stop/standby
71+
- Communication interfaces
72+
- 3 x FDCAN controller supporting flexible data rate
73+
- 4 x I2C Fast mode plus (1 Mbit/s) with 20 mA current sink, SMBus/PMBus, wakeup from stop
74+
- 5 x USART/UARTs (ISO 7816 interface, LIN, IrDA, modem control)
75+
- 1 x LPUART
76+
- 4 x SPIs, 4 to 16 programmable bit frames, 2 x with multiplexed half duplex I2S interface
77+
- 1 x SAI (serial audio interface)
78+
- USB 2.0 full-speed interface with LPM and BCD support
79+
- IRTIM (infrared interface)
80+
- USB Type-C™ /USB power delivery controller (UCPD)
81+
- True random number generator (RNG)
82+
- CRC calculation unit, 96-bit unique ID
83+
- Development support: serial wire debug (SWD), JTAG, Embedded Trace Macrocell™
84+
85+
86+
87+
## Read more
88+
89+
| Documents | Description |
90+
| :----------------------------------------------------------: | :----------------------------------------------------------: |
91+
| [STM32_Nucleo-64_BSP_Introduction](../docs/STM32_Nucleo-64_BSP_Introduction.md) | How to run RT-Thread on STM32 Nucleo-64 boards (**Must-Read**) |
92+
| [STM32G474RE ST Official Website](https://www.st.com/en/microcontrollers-microprocessors/stm32g474re.html#documentation) | STM32G474RB datasheet and other resources |
93+
94+
95+
96+
## Maintained By
97+
98+
[mazhiyuan](https://github.com/cndabai), <[email protected]>
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# NUCLEO-G474RE 开发板 BSP 说明
2+
3+
## 简介
4+
5+
本文档为 NUCLEO-G474RE 开发板的 BSP (板级支持包) 说明。
6+
7+
主要内容如下:
8+
9+
- 开发板资源介绍
10+
- BSP 快速上手
11+
- 进阶使用方法
12+
13+
通过阅读快速上手章节开发者可以快速地上手该 BSP,将 RT-Thread 运行在开发板上。在进阶使用指南章节,将会介绍更多高级功能,帮助开发者利用 RT-Thread 驱动更多板载资源。
14+
15+
## 开发板介绍
16+
17+
NUCLEO-G474RE 是 ST 公司推出的一款针对 STM32G4 系列设计的 Cortex-M4 Nucleo-64 开发板。
18+
19+
开发板外观如下图所示:
20+
21+
![board](figures/board.jpg)
22+
23+
该开发板常用 **板载资源** 如下:
24+
25+
- MCU:STM32G431RB,主频 170MHz,128KB FLASH ,32KB RAM
26+
- 常用外设
27+
- LED:1个,LD2(黄色,PA5)
28+
- 常用接口:USB 转串口
29+
- 调试接口,标准 ST-LINK/SWD
30+
31+
开发板更多详细信息请参考【NUCLEO-G474RE】 [开发板介绍](https://www.st.com/zh/evaluation-tools/nucleo-g474re.html)
32+
33+
## 外设支持
34+
35+
本 BSP 目前对外设的支持情况如下:
36+
37+
| **板载外设** | **支持情况** | **备注** |
38+
| :----------------- | :----------: | :------------------------------------- |
39+
| USB 转串口 | 支持 | |
40+
| **片上外设** | **支持情况** | **备注** |
41+
| GPIO | 支持 | |
42+
| UART | 支持 | LPUART1 USART1/3 UART4 |
43+
44+
## 使用说明
45+
46+
使用说明分为如下两个章节:
47+
48+
- 快速上手
49+
50+
本章节是为刚接触 RT-Thread 的新手准备的使用说明,遵循简单的步骤即可将 RT-Thread 操作系统运行在该开发板上,看到实验效果 。
51+
52+
- 进阶使用
53+
54+
本章节是为需要在 RT-Thread 操作系统上使用更多开发板资源的开发者准备的。通过使用 ENV 工具对 BSP 进行配置,可以开启更多板载资源,实现更多高级功能。
55+
56+
57+
### 快速上手
58+
59+
本 BSP 为开发者提供 MDK5 和 IAR 工程,并且支持 GCC 开发环境。下面以 MDK5 开发环境为例,介绍如何将系统运行起来。
60+
61+
#### 硬件连接
62+
63+
使用数据线连接开发板到 PC,通过数据线对开发板供电,下载,调试。
64+
65+
#### 编译下载
66+
67+
双击 project.uvprojx 文件,打开 MDK5 工程,编译并下载程序到开发板。
68+
69+
> 工程默认配置使用 ST-LINK 仿真器下载程序,在通过 ST-LINK 连接开发板的基础上,点击下载按钮即可下载程序到开发板
70+
71+
#### 运行结果
72+
73+
下载程序成功之后,系统会自动运行,黄色的 LD2 以 500MS 周期闪烁。
74+
75+
连接开发板对应串口到 PC , 在终端工具里打开相应的串口(115200-8-1-N),复位设备后,可以看到 RT-Thread 的输出信息:
76+
77+
```bash
78+
\ | /
79+
- RT - Thread Operating System
80+
/ | \ 4.0.2 build Oct 5 2019
81+
2006 - 2019 Copyright by rt-thread team
82+
msh >
83+
```
84+
### 进阶使用
85+
86+
此 BSP 默认只开启了 GPIO 和 LPUART1 的功能,如果需使用更多高级功能,需要利用 ENV 工具对 BSP 进行配置,步骤如下:
87+
88+
1. 在 bsp 下打开 env 工具。
89+
90+
2. 输入`menuconfig`命令配置工程,配置好之后保存退出。
91+
92+
3. 输入`pkgs --update`命令更新软件包。
93+
94+
4. 输入`scons --target=mdk4/mdk5/iar` 命令重新生成工程。
95+
96+
本章节更多详细的介绍请参考 [STM32 系列 BSP 外设驱动使用教程](../docs/STM32系列BSP外设驱动使用教程.md)
97+
98+
## 注意事项
99+
100+
- 默认终端输出设备是 LPUART1
101+
102+
## 联系人信息
103+
104+
维护人:
105+
106+
- [mazhiyuan](https://github.com/cndabai), 邮箱:<[email protected]>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# for module compiling
2+
import os
3+
Import('RTT_ROOT')
4+
from building import *
5+
6+
cwd = GetCurrentDir()
7+
objs = []
8+
list = os.listdir(cwd)
9+
10+
for d in list:
11+
path = os.path.join(cwd, d)
12+
if os.path.isfile(os.path.join(path, 'SConscript')):
13+
objs = objs + SConscript(os.path.join(d, 'SConscript'))
14+
15+
Return('objs')
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import os
2+
import sys
3+
import rtconfig
4+
5+
if os.getenv('RTT_ROOT'):
6+
RTT_ROOT = os.getenv('RTT_ROOT')
7+
else:
8+
RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..')
9+
10+
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
11+
try:
12+
from building import *
13+
except:
14+
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
15+
print(RTT_ROOT)
16+
exit(-1)
17+
18+
TARGET = 'rt-thread.' + rtconfig.TARGET_EXT
19+
20+
DefaultEnvironment(tools=[])
21+
env = Environment(tools = ['mingw'],
22+
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
23+
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
24+
AR = rtconfig.AR, ARFLAGS = '-rc',
25+
CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
26+
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
27+
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
28+
29+
if rtconfig.PLATFORM == 'iar':
30+
env.Replace(CCCOM = ['$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
31+
env.Replace(ARFLAGS = [''])
32+
env.Replace(LINKCOM = env["LINKCOM"] + ' --map rt-thread.map')
33+
34+
Export('RTT_ROOT')
35+
Export('rtconfig')
36+
37+
SDK_ROOT = os.path.abspath('./')
38+
39+
if os.path.exists(SDK_ROOT + '/libraries'):
40+
libraries_path_prefix = SDK_ROOT + '/libraries'
41+
else:
42+
libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
43+
44+
SDK_LIB = libraries_path_prefix
45+
Export('SDK_LIB')
46+
47+
# prepare building environment
48+
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
49+
50+
stm32_library = 'STM32G4xx_HAL'
51+
rtconfig.BSP_LIBRARY_TYPE = stm32_library
52+
53+
# include libraries
54+
objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript')))
55+
56+
# include drivers
57+
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript')))
58+
59+
# make a building
60+
DoBuilding(TARGET, objs)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import rtconfig
2+
from building import *
3+
4+
cwd = GetCurrentDir()
5+
CPPPATH = [cwd, str(Dir('#'))]
6+
src = Split("""
7+
main.c
8+
""")
9+
10+
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
11+
12+
Return('group')
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2018-11-06 SummerGift first version
9+
*/
10+
11+
#include <rtthread.h>
12+
#include <rtdevice.h>
13+
#include <board.h>
14+
15+
/* defined the LED2 pin: PA5 */
16+
#define LED2_PIN GET_PIN(A, 5)
17+
18+
int main(void)
19+
{
20+
/* set LED2 pin mode to output */
21+
rt_pin_mode(LED2_PIN, PIN_MODE_OUTPUT);
22+
23+
while (1)
24+
{
25+
rt_pin_write(LED2_PIN, PIN_HIGH);
26+
rt_thread_mdelay(500);
27+
rt_pin_write(LED2_PIN, PIN_LOW);
28+
rt_thread_mdelay(500);
29+
}
30+
}

0 commit comments

Comments
 (0)