Skip to content

Commit dcd17ed

Browse files
committed
[xuantie] 添加E907 BSP
1 parent 1fafa3f commit dcd17ed

File tree

18 files changed

+2696
-0
lines changed

18 files changed

+2696
-0
lines changed

bsp/xuantie/smartl/e907/.config

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

bsp/xuantie/smartl/e907/Kconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
mainmenu "RT-Thread Configuration"
2+
3+
BSP_DIR := .
4+
5+
RTT_DIR := ../../../..
6+
7+
PKGS_DIR := packages
8+
9+
config XUANTIAN_XIAOHUI_E907
10+
bool
11+
select ARCH_RISCV32
12+
select RT_USING_COMPONENTS_INIT
13+
select RT_USING_USER_MAIN
14+
default y
15+
16+
source "$(RTT_DIR)/Kconfig"
17+
osource "$PKGS_DIR/Kconfig"
18+
rsource "board/Kconfig"

bsp/xuantie/smartl/e907/README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# XuanTie - E907 Series
2+
3+
## 一 简介
4+
5+
### 1. 内核
6+
7+
E907 是一款基于 RISC-V 指令集的高性能嵌入式微处理处理器,是玄铁 RISC-V MCU 产品线中的最高性能处理器。E907 主要面向语音、MPU、导航、WiFi 等应用领域。
8+
9+
### 2.特点
10+
11+
E907 处理器体系结构的主要特点如下:
12+
13+
• 32 位 RISC 处理器;
14+
15+
• 支持 RISC-V RV32IMA[F][D]C[P] 指令集;
16+
17+
• 支持 RISC-V 32/16 位混编指令集;
18+
19+
• 支持 RISC-V 机器模式和用户模式;
20+
21+
• 32 个 32 位整型通用寄存器,32 个 32 位/64 位浮点通用寄存器;
22+
23+
• 整型 5 级/浮点 7 级,单发射,顺序执行流水线;
24+
25+
• 支持 AXI4.0 主设备接口以及 AHB5.0 外设接口;
26+
27+
• 指令 Cache,两路组相连结构,2KB-32KB 可配置;
28+
29+
• 数据 Cache,两路组相连结构,2KB-32KB 可配置;
30+
31+
• 支持非对齐内存访问;
32+
33+
• 双周期硬件乘法器,基 4 硬件除法器;
34+
35+
• 可选配 BHT 和 BTB;
36+
37+
• 支持玄铁扩展增强指令集;
38+
39+
• 支持玄铁 MCU 特性扩展技术,包括中断处理加速技术、MCU 扩展特性;
40+
41+
• 兼容 RISC-V CLIC 中断标准,支持中断嵌套,外部中断源数量最高可配置 240 个;
42+
43+
• 兼容 RISC-V PMP 内存保护标准,0/4/8/12/16 区域可配置;
44+
45+
• 支持可配的性能监测单元;
46+
47+
• 支持 RISC-V Debug 协议标准;
48+
49+
• 频率 >1.0GHz@T28 HPCPlus,9T SVT(worst case),Coremark > 3.8 coremark/MHz,Dhrystone
50+
51+
\> 2.0 DMIPS/MHz。
52+
53+
### 3.BSP支持情况
54+
55+
- 当前BSP支持下述内核:
56+
57+
```asciiarmor
58+
e907 e907f e907fd e907p e907fp e907fdp
59+
```
60+
61+
- 当前BSP默认设置的内核是e907fd,该架构支持[F] [D]扩展,可以通过menuconfig工具使能[F]扩展或者[F] [D] 扩展。
62+
63+
- 当使用其他内核架构时需要修改,rtconfig.py文件中的`MCPU`字段。
64+
65+
### 4.运行QEMU
66+
67+
- BSP根目录下存在`qemu.bat`脚本,生成可执行文件后可点击该脚本直接启动QEMU.
68+
69+
## 二 工具
70+
71+
- 编译器: https://www.xrvm.cn/community/download?id=4433353576298909696
72+
- 模拟器: https://www.xrvm.cn/community/download?id=4397435198627713024
73+
74+
注:若上述链接中的编译器与模拟器不能使用,可以使用下述CDK中的编译器与模拟器
75+
76+
- SDK:https://www.xrvm.cn/community/download?id=4397799570420076544
77+
78+
## 三 调试方法
79+
80+
**下述调试方法以E906举例,本BSP操作方式一致**,搭建完成RT-Thread开发环境,在BSP根目录使用env工具在当前目录打开env。
81+
82+
![](figures/1.env.png)
83+
84+
使用前执行一次**menuconfig**命令,更新rtconfig.h配置,然后在当前目录执行**scons -j12**命令编译生成可可执行文件。
85+
86+
<img src="figures/2.scons.png" alt="env">
87+
88+
生成可执行文件,可以直接在命令行启动qemu或者配置vscode脚本借助vscode强大的插件进行图形化调试,qemu的相关命令可以查看玄铁qemu的[用户手册](https://www.xrvm.cn/community/download?id=4397435198627713024),下述是启动qemu的命令,在powershell或命令行可直接执行下述命令,注意qemu需要导出至环境变量或者使用绝对路径。
89+
90+
```shell
91+
qemu-system-riscv64 -machine smartl -nographic -kernel rtthread.elf -cpu e906
92+
```
93+
94+
下述是使用vscode调试的展示。
95+
96+
<img src="figures/3.vscode.png" alt="env" />
97+
98+
一起为RISC-V加油!

bsp/xuantie/smartl/e907/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/xuantie/smartl/e907/SConstruct

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import os
2+
import sys
3+
import rtconfig
4+
from SCons.Script import *
5+
from termcolor import colored
6+
7+
if os.getenv('RTT_ROOT'):
8+
RTT_ROOT = os.getenv('RTT_ROOT')
9+
else:
10+
RTT_ROOT = os.path.normpath(os.getcwd() + '/../../../..')
11+
12+
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
13+
14+
try:
15+
from building import *
16+
except:
17+
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
18+
print(RTT_ROOT)
19+
exit(-1)
20+
21+
TARGET = 'rtthread.' + rtconfig.TARGET_EXT
22+
23+
print(colored('RT-Thread root directory: %s' % RTT_ROOT, 'green'))
24+
print(colored('Building path: %s' % os.path.abspath('.'), 'green'))
25+
print(colored('Building target: %s' % TARGET, 'green'))
26+
27+
DefaultEnvironment(tools=[])
28+
env = Environment(tools = ['mingw'],
29+
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
30+
CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS,
31+
AR = rtconfig.AR, ARFLAGS = '-rc',
32+
CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
33+
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
34+
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
35+
36+
Export('RTT_ROOT')
37+
Export('rtconfig')
38+
39+
SDK_ROOT = os.path.abspath('./')
40+
print(colored('SDK_ROOT: %s' % SDK_ROOT, 'green'))
41+
42+
if os.path.exists(SDK_ROOT + '/libraries'):
43+
libraries_path_prefix = SDK_ROOT + '../libraries'
44+
else:
45+
libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/../libraries'
46+
47+
print(colored('libraries_path_prefix: %s' % libraries_path_prefix, 'green'))
48+
SDK_LIB = libraries_path_prefix
49+
Export('SDK_LIB')
50+
51+
# prepare building environment
52+
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
53+
54+
bsp_vdir = 'build'
55+
library_vdir = 'build/libraries'
56+
57+
# common include drivers
58+
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'SConscript'), variant_dir=library_vdir, duplicate=0))
59+
60+
# make a building
61+
DoBuilding(TARGET, objs)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from building import *
2+
import os
3+
4+
cwd = GetCurrentDir()
5+
CPPPATH = [cwd]
6+
src = ['main.c']
7+
8+
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
9+
10+
Return('group')
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
* 2025-04-21 Wangshun first version
9+
*/
10+
11+
#include <rtthread.h>
12+
#include <rtdevice.h>
13+
#include "pre_main.h"
14+
15+
int main(void)
16+
{
17+
rt_kprintf("Hello RT-Thread!\r\n");
18+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
menu "Hardware Drivers Config"
2+
3+
config SOC_XUANTIE
4+
bool
5+
select SOC_XUANTIE_SERIES_E906
6+
select RT_USING_COMPONENTS_INIT
7+
select RT_USING_USER_MAIN
8+
default y
9+
10+
11+
menu "On-chip Peripheral Drivers"
12+
13+
menuconfig BSP_USING_UART
14+
bool "Enable UART"
15+
select RT_USING_SERIAL
16+
default n
17+
18+
if BSP_USING_UART
19+
config BSP_USING_UART0
20+
bool "Enable UART0"
21+
default n
22+
endif
23+
24+
menuconfig ENABLE_FPU
25+
bool "Enable FPU"
26+
select ARCH_RISCV_FPU
27+
default n
28+
29+
if ENABLE_FPU
30+
choice
31+
prompt "FPU Configuration"
32+
default ARCH_RISCV_FPU_S
33+
34+
config ARCH_RISCV_FPU_S
35+
bool "Enable [F] Extension"
36+
37+
config ARCH_RISCV_FPU_D
38+
bool "Enable [F][D] Extension"
39+
endchoice
40+
endif
41+
endmenu
42+
43+
endmenu
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import os
2+
import rtconfig
3+
from building import *
4+
5+
Import('SDK_LIB')
6+
7+
cwd = GetCurrentDir()
8+
9+
# add general drivers
10+
src = ['board.c']
11+
12+
path = [cwd]
13+
14+
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path)
15+
Return('group')
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
* 2025-04-23 Wangshun first version
9+
*/
10+
11+
#include <board.h>
12+
#include <rthw.h>
13+
#include <rtthread.h>
14+
#include <drv_usart.h>
15+
16+
extern unsigned long __heap_start;
17+
extern unsigned long __heap_end;
18+
19+
/**
20+
* This function will initialize your board.
21+
*/
22+
void rt_hw_board_init()
23+
{
24+
rt_hw_interrupt_init();
25+
26+
#ifdef RT_USING_HEAP
27+
rt_system_heap_init((void *)&__heap_start, (void *)&__heap_end);
28+
#endif
29+
30+
#ifdef BSP_USING_UART
31+
rt_hw_usart_init();
32+
#endif
33+
34+
#ifdef RT_USING_CONSOLE
35+
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
36+
#endif
37+
38+
#ifdef RT_USING_COMPONENTS_INIT
39+
rt_components_board_init();
40+
#endif
41+
}

0 commit comments

Comments
 (0)