Skip to content

Commit be5ceca

Browse files
committed
feat(bsp/gd32): 增加GDF0RG芯片BSP
1 parent 85b656b commit be5ceca

32 files changed

Lines changed: 19241 additions & 0 deletions

bsp/gd32/arm/gd32405rg/.config

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

bsp/gd32/arm/gd32405rg/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
compile_commands*
2+
*.uvguix.*
3+
EventRecorderStub.*

bsp/gd32/arm/gd32405rg/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"

bsp/gd32/arm/gd32405rg/README.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# GD32405RG BSP说明
2+
3+
## 简介
4+
5+
GD32405RG是-兆易创新推出的一款GD32F4XX系列的MCU,最高主频高达168M。参考GD32F407V-START开发板BSP
6+
7+
开发板外观如下图所示(仅芯片,没有开发板图片,下图为GD32407V-START开发板):
8+
9+
![board](figures/board.jpg)
10+
11+
该开发板常用 **板载资源** 如下:
12+
13+
- GD32405RGT6,主频 168MHz,1024KB FLASH ,128KB RAM + 64KB TCMRAM (其他F4 BSP的RAM存在问题,实际的RAM布局应该像我这样)
14+
![memrey map](README_assets/image.png)
15+
16+
- 常用接口:USB 接口
17+
18+
- 调试接口:DAP-LINK
19+
20+
## 外设支持
21+
22+
本 BSP 目前对外设的支持情况如下:
23+
24+
| **片上外设** | **支持情况** | **备注** |
25+
| :----------- | :----------: | :------------------------------ |
26+
| GPIO | 支持 | PA0, PA1... ---> PIN: 0, 1...81 |
27+
| UART | 支持 | UART0 - UART5 |
28+
| I2C | 支持 | I2C1 |
29+
| SPI | 支持 | SPI0 -  SPI2 |
30+
| SPI FLASH | 支持 | |
31+
| ADC | 支持 | ADC0 - ADC2 |
32+
| **扩展模块** | **支持情况** | **备注** |
33+
| 暂无 | 暂不支持 | 暂不支持 |
34+
35+
## 使用说明
36+
37+
使用说明分为如下两个章节:
38+
39+
- 快速上手
40+
41+
本章节是为刚接触 RT-Thread 的新手准备的使用说明,遵循简单的步骤即可将 RT-Thread 操作系统运行在该开发板上,看到实验效果 。
42+
43+
- 进阶使用
44+
45+
本章节是为需要在 RT-Thread 操作系统上使用更多开发板资源的开发者准备的。通过使用 ENV 工具对 BSP 进行配置,可以开启更多板载资源,实现更多高级功能。
46+
47+
### 快速上手
48+
49+
本 BSP 为开发者提供 MDK5 工程,并且支持 GCC 开发环境,也可使用RT-Thread Studio开发,IAR/MDK4未做修改,如果您使用IAR/MDK4需要做一些简单修改。下面以 MDK5 开发环境为例,介绍如何将系统运行起来。
50+
51+
#### 硬件连接
52+
53+
使用数据线连接开发板到 PC,使用USB转TTL模块连接PA2(MCU TX)和PA3(MCU RX),打开电源开关。
54+
55+
#### 编译下载
56+
57+
双击 project.uvprojx 文件,打开 MDK5 工程,编译并下载程序到开发板。
58+
59+
> 工程默认配置使用 DAP-Link 仿真器下载程序,在通过 DAP-Link 连接开发板的基础上,点击下载按钮即可下载程序到开发板
60+
61+
#### 运行结果
62+
63+
下载程序成功之后,系统会自动运行,LED 闪烁。
64+
65+
连接开发板对应串口到 PC , 在终端工具里打开相应的串口(115200-8-1-N),复位设备后,可以看到 RT-Thread 的输出信息:
66+
67+
```bash
68+
\ | /
69+
- RT - Thread Operating System
70+
/ | \ 4.0.4 build Jan 9 2021
71+
2006 - 2021 Copyright by rt-thread team
72+
msh >
73+
```
74+
75+
### 进阶使用
76+
77+
此 BSP 默认只开启了 GPIO 和 串口0的功能,如果需使用高级功能,需要利用 ENV 工具对BSP 进行配置,步骤如下:
78+
79+
1. 在 bsp 下打开 env 工具。
80+
81+
2. 输入`menuconfig`命令配置工程,配置好之后保存退出。
82+
83+
3. 输入`pkgs --update`命令更新软件包。
84+
85+
4. 输入`scons --target=mdk5` 命令重新生成工程,或者使用Scons构建
86+
87+
## 注意事项
88+
89+
1. 该BSP使用的外部高速时钟为8MHz,PLL倍频到200MHz,请根据实际情况进行时钟配置。
90+
board/SConscript中,请根据实际情况修改HXTAL_VALUE:
91+
```python
92+
CPPDEFINES = ['GD32F405', 'HXTAL_VALUE=8000000U']
93+
```
94+
board/board.c中,根据实际情况修改`system_clock_8M_200M`实现:
95+
```c
96+
void rt_hw_board_init()
97+
{
98+
/* config system clock HSE 8M to 200M */
99+
system_clock_8M_200M();
100+
101+
```
102+
103+
## 联系人信息
104+
105+
维护人:
106+
107+
- [ShiHongchao](https://gitee.com/shi-hongchao), 邮箱:<hongchao.shi@foxmail.com> 或者 <shi.hc@outlook.com>
94.5 KB
Loading
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* UVISION generated file: DO NOT EDIT!
3+
* Generated by: uVision version 5.42.0.0
4+
*
5+
* Project: 'template'
6+
* Target: 'rt-thread'
7+
*/
8+
9+
#ifndef RTE_COMPONENTS_H
10+
#define RTE_COMPONENTS_H
11+
12+
13+
/*
14+
* Define the Device Header File:
15+
*/
16+
#define CMSIS_device_header "gd32f4xx.h"
17+
18+
19+
20+
#endif /* RTE_COMPONENTS_H */

bsp/gd32/arm/gd32405rg/SConscript

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')

bsp/gd32/arm/gd32405rg/SConstruct

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 with specific build directory
71+
drivers_objs = SConscript(os.path.join(libraries_path_prefix, 'gd32_drivers', 'SConscript'),
72+
variant_dir='build/libraries/gd32_drivers',
73+
duplicate=0)
74+
objs.extend(drivers_objs)
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: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2006-2022, 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+
*/
10+
11+
#include <stdio.h>
12+
#include <rtthread.h>
13+
#include <rtdevice.h>
14+
#include <board.h>
15+
16+
/* defined the LED2 pin: PB5 */
17+
#define LED2_PIN GET_PIN(B, 5)
18+
19+
int main(void)
20+
{
21+
int count = 1;
22+
23+
/* set LED2 pin mode to output */
24+
rt_pin_mode(LED2_PIN, PIN_MODE_OUTPUT);
25+
26+
while (count++)
27+
{
28+
rt_pin_write(LED2_PIN, PIN_HIGH);
29+
rt_thread_mdelay(500);
30+
rt_pin_write(LED2_PIN, PIN_LOW);
31+
rt_thread_mdelay(500);
32+
}
33+
34+
return RT_EOK;
35+
}

0 commit comments

Comments
 (0)