Skip to content

Commit c1e9403

Browse files
authored
[bsp/gd32] add gd32470i-eval bsp #10664
1 parent f44ce3a commit c1e9403

35 files changed

+16177
-0
lines changed

bsp/gd32/arm/gd32470i-eval/.config

Lines changed: 1445 additions & 0 deletions
Large diffs are not rendered by default.

bsp/gd32/arm/gd32470i-eval/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
mainmenu "RT-Thread Configuration"
2+
3+
BSP_DIR := .
4+
5+
RTT_DIR := ../../../..
6+
7+
PKGS_DIR := packages
8+
9+
source "$(RTT_DIR)/Kconfig"
10+
osource "$PKGS_DIR/Kconfig"
11+
rsource "../libraries/Kconfig"
12+
rsource "board/Kconfig"
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# GD32470I-EVAL评估板BSP说明
2+
3+
## 简介
4+
5+
GD32470I-EVAL评估板使用GD32F470IKH6作为主控制器。评估板使用Mini USB接口或者DC-005连接器提供5V电源。该评估板具有丰富的板载资源,提供包括扩展引脚在内的及SWD, Reset, Boot, User button key, LED, CAN, I2C, I2S, USART, RTC, LCD, SPI, ADC, DAC, EXMC, CTC, SDIO, DCI, ENET, USBFS, USBHS, GD-Link等外设资源,图片如下:
6+
7+
![board](figures/board.jpg)
8+
9+
> 更多关于开发板的资料可以查看GD32470I-EVAL-V1.0原理图。
10+
11+
该开发板常用 **板载资源** 如下:
12+
13+
- GD32F470IKH6,主频 240MHz,CPU内核:ARM Cortex-M4,3072KB FLASH ,512KB RAM
14+
- 常用外设
15+
16+
- 用户LED :3个,LED1(PE2),LED2(PE3),LED3(PF10)
17+
- 电源指示灯:一个红色LED
18+
- 按键:4个,K1-Reset(NRST),K2-Wakeup(PA0),K3-Tamper(PC13),K4-User key(PB14)
19+
- General TM * 10、Advanced TM * 2、Basic TM * 2
20+
- SysTick * 1
21+
- 看门狗 * 2
22+
- RTC * 1
23+
- USART * 4、UART * 4
24+
- I2C * 3、I2S * 2
25+
- SPI * 6
26+
- SDIO * 1
27+
- CAN * 2
28+
- USBFS+HS
29+
- 以太网 * 1
30+
- TFT-LCD
31+
- EXMC/SDRAM * 1
32+
- EXMC/NAND Flash * 1
33+
- ADC * 3
34+
- DAC * 2
35+
- DCI摄像头接口 * 1
36+
- 最多支持176GPIOs
37+
- 调试接口:GD-Link
38+
- 支持RGB接口和MCU屏幕接口
39+
- 一路SDIO-TF卡
40+
- SPI Flash:板载Flash
41+
- SDRAM:外扩SDRAM
42+
- 一路Mini USB
43+
- 调试接口引出了SWD和UART
44+
- 丰富的扩展引脚
45+
- 开发板更多信息请查看GD32470I-EVAL原理图
46+
47+
## 外设支持
48+
49+
| **片上外设** | **支持情况** | **备注** |
50+
|:------------|:------------:|:----------------------------------|
51+
| GPIO | 支持 | PA0, PA1... ---> PIN: 0, 1...175 |
52+
| UART | 支持 | UART0 - UART7 |
53+
| SPI | 支持 | 支持 SPI0 ~ SPI5,可配置多个总线 |
54+
| I2C | 支持 | 支持 I2C0 ~ I2C2 |
55+
56+
57+
## 使用说明
58+
59+
使用说明分为如下两个章节:
60+
61+
- 快速上手
62+
63+
本章节是为刚接触 RT-Thread 的新手准备的使用说明,遵循简单的步骤即可将 RT-Thread 操作系统运行在该开发板上,看到实验效果 。
64+
65+
- 进阶使用
66+
67+
本章节是为需要在 RT-Thread 操作系统上使用更多开发板资源的开发者准备的。通过使用 ENV 工具对 BSP 进行配置,可以开启更多板载资源,实现更多高级功能。
68+
69+
### 快速上手
70+
71+
本 BSP 为开发者提供 MDK5工程,支持 GCC 开发环境,也可使用RT-Thread Studio开发。下面以 MDK5 开发环境为例,介绍如何将系统运行起来。
72+
73+
#### 硬件连接
74+
75+
使用GD-Link调试器连接开发板到 PC,使用USB2TTL连接USART0,并给开发板供电(可使用Mini USB接口或DC-005连接器提供5V电源)。
76+
77+
#### 编译下载
78+
79+
双击 project.uvprojx 文件,打开 MDK5 工程,编译并下载程序到开发板。
80+
81+
> 工程默认配置使用 GD-Link 仿真器下载程序,在通过 GD-Link 连接开发板的基础上,点击下载按钮即可下载程序到开发板
82+
83+
#### 运行结果
84+
85+
下载程序成功之后,系统会自动运行,LED 闪烁。
86+
87+
连接开发板对应串口到 PC , 在终端工具里打开相应的串口(115200-8-1-N),复位设备后,可以看到 RT-Thread 的输出信息:
88+
89+
```bash
90+
\ | /
91+
- RT - Thread Operating System
92+
/ | \ 5.0.0 build Mar 3 2023 00:43:44
93+
2006 - 2022 Copyright by RT-Thread team
94+
msh />
95+
```
96+
97+
### 进阶使用
98+
99+
此 BSP 默认只开启了 GPIO 和 串口0的功能,如果需使用高级功能,需要利用 ENV 工具对BSP 进行配置,步骤如下:
100+
101+
1. 在 bsp 下打开 env 工具。
102+
103+
2. 输入`menuconfig`命令配置工程,配置好之后保存退出。
104+
105+
3. 输入`pkgs --update`命令更新软件包。
106+
107+
4. 输入`scons --target=mdk4/mdk5/iar` 命令重新生成工程。
108+
109+
## 注意事项
110+
111+
- 若需使用板载 SPI Flash,请在 `menuconfig` 中启用以下配置:
112+
113+
```
114+
RT-Thread Components --->
115+
Device Drivers --->
116+
[*] Enable SPI BUS support (RT_USING_SPI)
117+
[*] Enable SFUD for SPI Flash (RT_USING_SFUD)
118+
119+
Hardware Drivers Config --->
120+
On-chip Peripheral Drivers --->
121+
[*] Enable SPI BUS (BSP_USING_SPI)
122+
[*] Enable SPI5 BUS (BSP_USING_SPI5)
123+
```
124+
125+
- 若需使用SDRAM功能,请在 `menuconfig` 中启用EXMC配置
126+
- 若需使用DCI摄像头功能,请在 `menuconfig` 中启用相应的DCI配置
127+
- 若需使用LCD显示功能,请在 `menuconfig` 中启用LCD相关配置
128+
129+
130+
## 联系人信息
131+
132+
维护人:
133+
134+
- [godmial](https://github.com/godmial), 邮箱:<[email protected]>
135+
- [yuanzihao](https://github.com/zihao-yuan/), 邮箱:<[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: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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+
def bsp_pkg_check():
19+
import subprocess
20+
21+
check_paths = [
22+
os.path.join("packages", "gd32-arm-cmsis-latest"),
23+
os.path.join("packages", "gd32-arm-series-latest")
24+
]
25+
26+
need_update = not all(os.path.exists(p) for p in check_paths)
27+
28+
if need_update:
29+
print("\n===============================================================================")
30+
print("Dependency packages missing, please running 'pkgs --update'...")
31+
print("If no packages are fetched, run 'pkgs --upgrade' first, then 'pkgs --update'...")
32+
print("===============================================================================")
33+
exit(1)
34+
35+
RegisterPreBuildingAction(bsp_pkg_check)
36+
37+
TARGET = 'rtthread.' + rtconfig.TARGET_EXT
38+
39+
DefaultEnvironment(tools=[])
40+
env = Environment(tools = ['mingw'],
41+
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
42+
CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS,
43+
AR = rtconfig.AR, ARFLAGS = '-rc',
44+
CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
45+
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
46+
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
47+
48+
if rtconfig.PLATFORM in ['iccarm']:
49+
env.Replace(CCCOM = ['$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
50+
env.Replace(ARFLAGS = [''])
51+
env.Replace(LINKCOM = env["LINKCOM"] + ' --map rtthread.map')
52+
53+
Export('env')
54+
Export('RTT_ROOT')
55+
Export('rtconfig')
56+
57+
SDK_ROOT = os.path.abspath('./')
58+
59+
if os.path.exists(SDK_ROOT + '/libraries'):
60+
libraries_path_prefix = SDK_ROOT + '/libraries'
61+
else:
62+
libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
63+
64+
SDK_LIB = libraries_path_prefix
65+
Export('SDK_LIB')
66+
67+
# prepare building environment
68+
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
69+
70+
# include drivers
71+
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'gd32_drivers', 'SConscript')))
72+
73+
# include lcd and drivers
74+
objs.extend(SConscript(os.path.join(SDK_ROOT, 'board', 'ports', 'SConscript')))
75+
76+
# make a building
77+
DoBuilding(TARGET, objs)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from building import *
2+
import os
3+
4+
cwd = GetCurrentDir()
5+
src = Glob('*.c')
6+
CPPPATH = [cwd]
7+
8+
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
9+
10+
list = os.listdir(cwd)
11+
for item in list:
12+
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
13+
group = group + SConscript(os.path.join(item, 'SConscript'))
14+
15+
Return('group')
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2006-2025, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2021-08-20 BruceOu first implementation
9+
* 2025-08-20 WangShun change the LED pins
10+
*/
11+
12+
#include <stdio.h>
13+
#include <rtthread.h>
14+
#include <rtdevice.h>
15+
#include <board.h>
16+
17+
/* defined the LED1 pin: PF10 */
18+
#define LED1_PIN GET_PIN(F, 10)
19+
20+
int main(void)
21+
{
22+
int count = 1;
23+
24+
/* set LED1 pin mode to output */
25+
rt_pin_mode(LED1_PIN, PIN_MODE_OUTPUT);
26+
27+
while (count++)
28+
{
29+
rt_pin_write(LED1_PIN, PIN_HIGH);
30+
rt_thread_mdelay(500);
31+
rt_pin_write(LED1_PIN, PIN_LOW);
32+
rt_thread_mdelay(500);
33+
}
34+
35+
return RT_EOK;
36+
}
37+

0 commit comments

Comments
 (0)