Skip to content

Commit dc5412d

Browse files
committed
添加 rdk s100 bsp
1 parent ae5b5ed commit dc5412d

43 files changed

Lines changed: 10615 additions & 0 deletions

Some content is hidden

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

bsp/rdk/s100/.config

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

bsp/rdk/s100/Kconfig

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
mainmenu "RT-Thread Configuration"
2+
3+
BSP_DIR := .
4+
5+
# you can change the RTT_ROOT default "rt-thread"
6+
# example : default "F:/git_repositories/rt-thread"
7+
8+
PKGS_DIR := packages
9+
10+
ENV_DIR := /
11+
12+
config SOC_S100
13+
bool
14+
select RT_USING_COMPONENTS_INIT
15+
select RT_USING_USER_MAIN
16+
default y
17+
18+
menu "S100 BSP Options"
19+
20+
config RT_USING_FPU
21+
bool "Enable Cortex-R52 VFP/FPU support"
22+
default y
23+
help
24+
Enable hardware floating-point support for the S100 BSP.
25+
26+
When enabled, the BSP builds with hard-float ABI and enables
27+
the VFP context save/restore path.
28+
29+
When disabled, the BSP switches to a soft-float build so O2 can
30+
remain enabled without generating VFP instructions.
31+
32+
endmenu
33+
34+
source "$(RTT_DIR)/Kconfig"
35+
osource "$PKGS_DIR/Kconfig"
36+
# rsource "$(BSP_DIR)/board/Kconfig"
37+
source "$(BSP_DIR)/drivers/Kconfig"

bsp/rdk/s100/README.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# S100 BSP 编译与加载运行说明
2+
3+
本文说明 `bsp/s100` 这个 RT-Thread BSP 如何在主机侧编译,以及如何在 RDK S100 板端加载并运行。
4+
5+
说明分两部分:
6+
7+
- 本地 BSP 实际构建方式:以当前仓库中的 `SConstruct``rtconfig.py``link.lds` 为准
8+
- 板端启动流程:参考 D-Robotics 官方文档“[MCU快速入门指南](https://d-robotics.github.io/rdk_doc/rdk_s/Advanced_development/mcu_development/S100/basic_information/)
9+
10+
## 1. 背景说明
11+
12+
官方文档说明了 S100 的 MCU 启动链路:
13+
14+
- MCU0 负责启动 Acore、MCU1 和电源管理
15+
- MCU1 由 Acore 通过 `remoteproc` 框架间接控制
16+
- 启动时由 Acore 在 `sysfs` 下给 `remoteproc_mcu0` 写入固件名并触发 `start`
17+
18+
参考:
19+
20+
- 官方文档第 “MCU1启动/关闭流程” 章节:`remoteproc_mcu0``firmware``state`
21+
- 本地链接脚本 [link.lds](./link.lds) 也包含 `.resource_table` 段,说明这个镜像是按 remoteproc 风格组织的 MCU1 ELF
22+
23+
## 2. 主机编译环境
24+
25+
### 2.1 推荐系统
26+
27+
官方文档建议主机使用 Ubuntu 22.04。
28+
29+
### 2.2 依赖安装
30+
31+
官方文档给出的依赖如下:
32+
33+
```bash
34+
sudo apt-get install -y build-essential make cmake libpcre3 libpcre3-dev bc bison \
35+
flex python3-numpy mtd-utils zlib1g-dev debootstrap \
36+
libdata-hexdumper-perl libncurses5-dev zip qemu-user-static \
37+
curl repo git liblz4-tool apt-cacher-ng libssl-dev checkpolicy autoconf \
38+
android-sdk-libsparse-utils mtools parted dosfstools udev rsync python3-pip scons
39+
pip install "scons>=4.0.0"
40+
pip install ecdsa
41+
pip install tqdm
42+
```
43+
44+
### 2.3 交叉工具链
45+
46+
当前 BSP 的工具链配置在 [rtconfig.py](./rtconfig.py)
47+
48+
- 架构:`cortex-r52`
49+
- 工具链前缀:`arm-none-eabi-`
50+
- 默认工具链路径:`/opt/toolchain/gcc-arm-none-eabi-10.3-2021.10/bin`
51+
52+
如果你的工具链不在这个目录,可以通过环境变量覆盖:
53+
54+
```bash
55+
export RTT_EXEC_PATH=/your/toolchain/bin
56+
```
57+
58+
## 3. BSP 编译方法
59+
60+
### 3.1 进入目录
61+
62+
```bash
63+
cd <repo>/bsp/s100
64+
```
65+
66+
### 3.2 执行编译
67+
68+
直接运行:
69+
70+
```bash
71+
scons -j$(nproc)
72+
```
73+
74+
如果你想先清理后重编:
75+
76+
```bash
77+
scons -c
78+
scons -j$(nproc)
79+
```
80+
81+
### 3.3 构建入口
82+
83+
本 BSP 的构建入口是:
84+
85+
- [SConstruct](./SConstruct)
86+
- [rtconfig.py](./rtconfig.py)
87+
88+
构建特征:
89+
90+
- 目标文件名:`rtthread.elf`
91+
- 后处理会自动生成:`rtthread.bin`
92+
93+
## 4. 板端加载运行
94+
95+
### 4.1 固件放置
96+
97+
根据官方 remoteproc 启动流程,MCU1 固件需要放到板端 `/lib/firmware/`
98+
99+
根据官方 RDK S100 硬件说明,板上有两个有线网口:
100+
101+
- `U43 / eth0`:通用以太网口,IP 需要通过外部 DHCP 获取,或由用户手动配置静态地址
102+
- `U45 / eth1`:固定静态 IP 网口,默认地址为 `192.168.127.10`
103+
104+
如果开发主机直接接在 `U45 / eth1`,可以优先使用固定 IP 方式传文件,这样不需要先查询板端地址。由于当前 BSP 输出文件名是 `rtthread.elf`,可以直接推送这个文件:
105+
106+
```bash
107+
scp rtthread.elf root@192.168.127.10:/lib/firmware/
108+
```
109+
110+
如果你接的是 `U43 / eth0`,则需要先确认板端实际 IP,然后再执行:
111+
112+
```bash
113+
scp rtthread.elf root@<board_ip>:/lib/firmware/
114+
```
115+
116+
### 4.2 启动 MCU1
117+
118+
参考官方文档中的 `remoteproc_mcu0` 启动步骤,板端执行:
119+
120+
如果固件名是 `rtthread.elf`
121+
122+
```bash
123+
cd /sys/class/remoteproc/remoteproc_mcu0
124+
echo rtthread.elf > firmware
125+
echo start > state
126+
```
127+
128+
### 4.3 停止 MCU1
129+
130+
> 由于该功能还不完善,此处需要重启设备来完成
131+
132+
## 5. 一套完整示例
133+
134+
主机侧:
135+
136+
```bash
137+
cd <repo>/bsp/s100
138+
scons -j$(nproc)
139+
scp rtthread.elf root@192.168.127.10:/lib/firmware/
140+
```
141+
142+
板端:
143+
144+
```bash
145+
cd /sys/class/remoteproc/remoteproc_mcu0
146+
echo rtthread.elf > firmware
147+
echo start > state
148+
```
149+
150+
停止:
151+
152+
```bash
153+
reboot
154+
```

bsp/rdk/s100/SConscript

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# for module compiling
2+
import os
3+
from building import *
4+
5+
cwd = GetCurrentDir()
6+
group = []
7+
list = os.listdir(cwd)
8+
9+
for d in list:
10+
path = os.path.join(cwd, d)
11+
if os.path.isfile(os.path.join(path, 'SConscript')):
12+
group = group + SConscript(os.path.join(d, 'SConscript'))
13+
14+
Return('group')

bsp/rdk/s100/SConstruct

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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.join(os.getcwd(), '..', '..', '..')
9+
10+
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
11+
from building import *
12+
13+
TARGET = 'rtthread.' + rtconfig.TARGET_EXT
14+
15+
DefaultEnvironment(tools=[])
16+
env = Environment(tools = ['mingw'],
17+
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
18+
CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS,
19+
CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
20+
AR = rtconfig.AR, ARFLAGS = '-rc',
21+
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
22+
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
23+
env['ASCOM'] = env['ASPPCOM']
24+
25+
Export('RTT_ROOT')
26+
Export('rtconfig')
27+
28+
# prepare building environment
29+
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=True)
30+
31+
# make a building
32+
DoBuilding(TARGET, objs)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from building import *
2+
3+
cwd = GetCurrentDir()
4+
src = Glob('*.c')
5+
CPPPATH = [cwd]
6+
7+
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
8+
9+
Return('group')

bsp/rdk/s100/applications/main.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2006-2026, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2026-04-20 rcitach first version
9+
*/
10+
#include <rtthread.h>
11+
12+
int main(void)
13+
{
14+
rt_kprintf("Hi, RT-Thread!\n");
15+
return 0;
16+
}

bsp/rdk/s100/board/SConscript

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import os
2+
from building import *
3+
4+
objs = []
5+
cwd = GetCurrentDir()
6+
CPPPATH = [cwd]
7+
src = Glob('*.c')
8+
9+
objs = DefineGroup('board', src, depend = [''], CPPPATH = CPPPATH)
10+
Return('objs')

bsp/rdk/s100/board/board.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2006-2026, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2026-04-20 rcitach first version
9+
*/
10+
11+
#include <rtthread.h>
12+
#include "board.h"
13+
14+
15+
void rt_hw_board_init(void)
16+
{
17+
/* initialize interrupt */
18+
rt_hw_interrupt_init();
19+
20+
#ifdef RT_USING_HEAP
21+
rt_system_heap_init(HEAP_BEGIN, HEAP_END);
22+
#endif
23+
24+
#ifdef RT_USING_COMPONENTS_INIT
25+
rt_components_board_init();
26+
#endif
27+
28+
#ifdef RT_USING_CONSOLE
29+
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
30+
#endif
31+
}

0 commit comments

Comments
 (0)