Skip to content

Commit 7353078

Browse files
committed
Add stm32f407 rt-spark
1 parent 573296b commit 7353078

File tree

646 files changed

+760156
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

646 files changed

+760156
-0
lines changed

machines/stm32f407-rt-spark/.config

Lines changed: 1365 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
mainmenu "RT-Thread Configuration"
2+
3+
BSP_DIR := .
4+
5+
RTT_DIR := ../../rt-thread
6+
7+
PKGS_DIR := packages
8+
9+
config SOC_STM32F407ZG
10+
bool
11+
select SOC_SERIES_STM32F4
12+
select RT_USING_COMPONENTS_INIT
13+
select RT_USING_USER_MAIN
14+
default y
15+
16+
config BOARD_STM32F407_SPARK
17+
bool
18+
default y
19+
20+
source "$(RTT_DIR)/Kconfig"
21+
osource "$PKGS_DIR/Kconfig"
22+
rsource "libraries/Kconfig"
23+
24+
if !RT_USING_NANO
25+
rsource "board/Kconfig"
26+
endif
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# STM32F407 星火一号开发板 BSP 说明
2+
3+
## 简介
4+
5+
本文档为 RT-Thread 开发团队为 STM32F407 星火1号开发板提供的 BSP (板级支持包) 说明。
6+
7+
主要内容如下:
8+
9+
- 开发板资源介绍
10+
- BSP 快速上手
11+
- 进阶使用方法
12+
13+
通过阅读快速上手章节开发者可以快速地上手该 BSP,将 RT-Thread 运行在开发板上。在进阶使用指南章节,将会介绍更多高级功能,帮助开发者利用 RT-Thread 驱动更多板载资源。
14+
15+
## 开发板介绍
16+
17+
星火号 STM32F407 是RT-THREAD推出的一款基于 ARM Cortex-M4 内核的开发板,最高主频为 168Mhz,该开发板具有丰富的板载资源,可以充分发挥 STM32F407 的芯片性能。
18+
19+
开发板外观如下图所示:
20+
21+
![board](figures/board.png)
22+
23+
该开发板常用 **板载资源** 如下:
24+
25+
- MCU:STM32F407ZGT6,主频 168MHz,1024KB FLASH ,192KB RAM
26+
- 外部 FLASH:W25Q128(SPI,16MB)
27+
- 常用外设
28+
- LED:2个,LED_R(红色,PF12),LED_B(绿色,PF11)
29+
- 按键,4个,KEY_UP(兼具唤醒功能,PIN:PC5),KEY_DOWN(PIN:PC1),KEY_LEFT(PIN:PC0),KEY_RIGHT(PIN:PC4)
30+
- 常用接口:USB 转串口、SD 卡接口、USB SLAVE、USB HOST
31+
- 调试接口,标准ST-LINK
32+
33+
开发板更多详细信息请参考官方文档 [STM32 星火一号开发板介绍](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/hw-board/spark-1/spark-1)
34+
35+
## 外设支持
36+
37+
本 BSP 目前对外设的支持情况如下:
38+
39+
| **板载外设** | **支持情况** | **备注** |
40+
| :------------ | :----------: | :-----------------------------------: |
41+
| USB 转串口(COM1) | 支持 | |
42+
| COM2 | 支持 | 和以太网、PWM 冲突,如需使用该外设,请使用 CubeMX 重新配置 UART2 管脚 |
43+
| COM3 | 支持 | |
44+
| **片上外设** | **支持情况** | **备注** |
45+
| UART | 支持 | UART1/2/3 |
46+
| SPI | 支持 | SPI1/2/3 |
47+
| ADC | 支持 | |
48+
| RTC | 支持 | 支持外部晶振和内部低速时钟 |
49+
| WDT | 支持 | |
50+
51+
52+
53+
## 使用说明
54+
55+
使用说明分为如下两个章节:
56+
57+
- 快速上手
58+
59+
本章节是为刚接触 RT-Thread 的新手准备的使用说明,遵循简单的步骤即可将 RT-Thread 操作系统运行在该开发板上,看到实验效果 。
60+
61+
- 进阶使用
62+
63+
本章节是为需要在 RT-Thread 操作系统上使用更多开发板资源的开发者准备的。通过使用 ENV 工具对 BSP 进行配置,可以开启更多板载资源,实现更多高级功能。
64+
65+
66+
### 快速上手
67+
68+
本 BSP 为开发者提供 MDK5 和 IAR 工程,并且支持 GCC 开发环境。下面以 MDK5 开发环境为例,介绍如何将系统运行起来。
69+
70+
#### 硬件连接
71+
72+
使用数据线连接开发板到 PC,打开电源开关。
73+
74+
#### 编译下载
75+
76+
双击 project.uvprojx 文件,打开 MDK5 工程,编译并下载程序到开发板。
77+
78+
> 工程默认配置使用 JLink 下载程序,在通过 JLink 连接开发板的基础上,点击下载按钮即可下载程序到开发板
79+
80+
#### 运行结果
81+
82+
下载程序成功之后,系统会自动运行,观察开发板上 LED 的运行效果,红色 LED 常亮、绿色 LED 会周期性闪烁。
83+
84+
连接开发板对应串口到 PC , 在终端工具里打开相应的串口(115200-8-1-N),复位设备后,可以看到 RT-Thread 的输出信息:
85+
86+
```bash
87+
88+
\ | /
89+
- RT - Thread Operating System
90+
/ | \ 5.0.1 build Jul 4 2023 07:49:10
91+
2006 - 2022 Copyright by RT-Thread team
92+
msh >
93+
```
94+
### 进阶使用
95+
96+
此 BSP 默认只开启了 GPIO 和 串口1 的功能,如果需使用 SD 卡、Flash 等更多高级功能,需要利用 ENV 工具对BSP 进行配置,步骤如下:
97+
98+
1. 在 bsp 下打开 env 工具。
99+
100+
2. 输入`menuconfig`命令配置工程,配置好之后保存退出。
101+
102+
3. 输入`pkgs --update`命令更新软件包。
103+
104+
4. 输入`scons --target=mdk5/iar` 命令重新生成工程。
105+
106+
本章节更多详细的介绍请参考 [STM32 系列 BSP 外设驱动使用教程](../docs/STM32系列BSP外设驱动使用教程.md)
107+
108+
## 注意事项
109+
110+
暂无
111+
112+
## 联系人信息
113+
114+
维护人:
115+
116+
- [Supperthomas](https://github.com/supperthomas)
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# STM32F407 RT-Thread Spark Board BSP Introduction
2+
3+
## Overview
4+
5+
This document is a description of the BSP (Board Support Package) provided by the RT-Thread development team for the STM32F407 RT-Thread Spark Board.
6+
7+
The main contents are as follows:
8+
9+
- Introduction of Development Board Resources
10+
- BSP Quick Start
11+
- Advanced Usage
12+
13+
By reading Quick Start Section, developers can quickly get started with the BSP and run RT-Thread on the board. In the Advanced Usage Section, more advanced features will be introduced to help developers utilize RT-Thread to drive more on-board resources.
14+
15+
## Spark-1 Introduction
16+
17+
The STM32F407 is a development board based on the ARM Cortex-M4 core from RT-THREAD, with a maximum main frequency of 168Mhz. The board has a wealth of on-board resources, which can fully utilize the performance of the STM32F407 chip.
18+
19+
The appearance of the board is shown in the figure below:
20+
21+
![board](figures/board.png)
22+
23+
The development board commonly used **on-board resources** as follows:
24+
25+
- MCU: STM32F407ZGT6, 168MHz, 1024KB FLASH, 192KB RAM.
26+
- External FLASH: W25Q128 (SPI, 16MB)
27+
- Common Peripherals
28+
- LEDs: 2, LED_R (red, PF12), LED_B (green, PF11)
29+
- Keys, 4, KEY_UP (both wake-up function, PIN: PC5), KEY_DOWN (PIN: PC1), KEY_LEFT (PIN: PC0), KEY_RIGHT (PIN: PC4)
30+
- Common interfaces: USB to serial port, SD card interface, USB SLAVE, USB HOST
31+
- Debugging interface, standard ST-LINK
32+
33+
For more details about the board, please refer to the official document [Introduction to STM32 Spark-1 Development Board](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/hw-board/spark-1/spark-1).
34+
35+
36+
## Peripheral Support
37+
38+
The BSP currently supports the following peripherals:
39+
| **Onboard peripherals** | **Support** | **note** |
40+
| :------------ | :----------: | :-----------------------------------: |
41+
| USB to Serial(COM1) | Support | |
42+
| COM2 | Support | Conflicts with Ethernet and PWM. Use CubeMX to reconfigure the UART2 pin if you want to use this peripheral. |
43+
| COM3 | Support | |
44+
| **On-chip peripherals** | **Supoort** | **Note** |
45+
| UART | Support | UART1/2/3 |
46+
| SPI | Support | SPI1/2/3 |
47+
| ADC | Support | |
48+
| RTC | Support | Support external crystal and internal low-speed clock |
49+
| WDT | Support | |
50+
51+
## Instructions for Use
52+
53+
The instructions for use are divided into two sections as follows:
54+
55+
- Quick Start
56+
57+
This section is intended for newcomers to RT-Thread. Follow the simple steps to get the RT-Thread operating system running on the board and see the results.
58+
59+
- Advanced Usage
60+
61+
This section is for developers who want to use more of the board's resources with the RT-Thread operating system. By using the ENV tool to configure the BSP, you can enable more on-board resources and realize more advanced functions.
62+
63+
### Quick Start
64+
65+
This BSP provides developers with MDK5 and IAR projects and supports GCC development environment. The following is an example of how to get the system up and running using the MDK5 development environment.
66+
67+
#### Hardware Connection
68+
69+
Connect the board to the PC with a cable and turn on the power switch.
70+
71+
#### Compile and Download
72+
73+
Double click the project.uvprojx file to open the MDK5 project, compile and download the program to the development board.
74+
75+
> The default configuration of the project is to use JLink to download the program. On the basis of connecting the development board via JLink, click the Download button to download the program to the development board.
76+
77+
#### Running Result
78+
79+
After successfully downloading the program, the system will run automatically. Observe the running effect of the LED on the development board, where the red LED is always on, the green LED will blink periodically.
80+
81+
Connect the corresponding serial port of the development board to PC, open the corresponding serial port (115200-8-1-N) in the terminal tool, and reset the device, you can see the output information of RT-Thread.
82+
83+
84+
85+
```bash
86+
87+
\ | /
88+
- RT - Thread Operating System
89+
/ | \ 5.0.1 build Jul 4 2023 07:49:10
90+
2006 - 2022 Copyright by RT-Thread team
91+
msh >
92+
```
93+
94+
### Advanced Usage
95+
96+
This BSP only enables GPIO and Serial1 by default. If you want to use more advanced functions such as SD card, Flash, etc., you need to configure the BSP by using ENV utility, the steps are as below:
97+
98+
1. Open the env utility under bsp.
99+
100+
2. Input `menuconfig` command to configure the project, save and exit after configuration.
101+
102+
3. Enter the `pkgs --update` command to update the package.
103+
104+
4. Enter the `scons --target=mdk5/iar` command to regenerate the project.
105+
106+
For a more detailed description of this chapter, please refer to [STM32 Series BSP Peripheral Driver Tutorial](... /docs/STM32 Series BSP Peripheral Driver Tutorial.md).
107+
108+
## Notes
109+
110+
Not available at this time
111+
112+
## Connection
113+
114+
Maintainer:
115+
116+
- [Supperthomas](https://github.com/supperthomas)
117+
118+
119+
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: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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() + '/../../rt-thread')
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, CFLAGS = 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 in ['iccarm']:
30+
env.Replace(CCCOM = ['$CC $CFLAGS $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 = 'STM32F4xx_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'), variant_dir='build/libraries/'+stm32_library, duplicate=0))
55+
# include drivers
56+
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript'),variant_dir='build/libraries/'+'HAL_Drivers', duplicate=0))
57+
58+
# make a building
59+
DoBuilding(TARGET, objs)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from building import *
2+
import os
3+
4+
cwd = GetCurrentDir()
5+
src = Glob('*.c')
6+
CPPPATH = [cwd]
7+
8+
if GetDepend(['PKG_USING_RTDUINO']) and not GetDepend(['RTDUINO_NO_SETUP_LOOP']):
9+
src += ['arduino_main.cpp']
10+
11+
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
12+
13+
list = os.listdir(cwd)
14+
for item in list:
15+
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
16+
group = group + SConscript(os.path.join(item, 'SConscript'))
17+
18+
Return('group')
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2006-2024, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2024-04-08 Li ZhenHong first version
9+
*/
10+
11+
#include <Arduino.h>
12+
13+
void setup(void)
14+
{
15+
/* put your setup code here, to run once: */
16+
Serial.begin();
17+
}
18+
19+
void loop(void)
20+
{
21+
/* put your main code here, to run repeatedly: */
22+
Serial.println("Hello Arduino!");
23+
delay(800);
24+
}

0 commit comments

Comments
 (0)