Skip to content

Commit e5101df

Browse files
增加全志 V861 C907 板级支持
新增 bsp/allwinner/avaota-f2(UART/msh 最小 BSP),并在 bsp/README.md 登记。 按 review 删除 ACCEPTANCE.md,编译说明改为推荐 Env 2.x / sdk。 board.dtb 不再假设树里已有:board/SConscript 调用 board/gen_board_dtb.py 在构建时生成, builtin_fdt.o 显式依赖该产物,源变化会重新生成。生成需要 python3 + fdt 模块, README 写明了这一步;board/board.dtb 作为构建产物加入 .gitignore。
1 parent dc3da6d commit e5101df

34 files changed

Lines changed: 2222 additions & 0 deletions

‎bsp/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ This document is based on the RT-Thread mainline repository and categorizes the
817817
|----------|------|------|-----|-----|-----|-----|-----|-----|-------|-------|
818818
| [d1](allwinner/d1) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
819819
| [d1s](allwinner/d1s) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
820+
| [avaota-f2](allwinner/avaota-f2) | | ✅ | | | | | | | | |
820821

821822
#### 🟡 K210 (SMP)
822823

‎bsp/allwinner/avaota-f2/.gitignore‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
__pycache__/
2+
*.bin
3+
*.elf
4+
*.map
5+
build/
6+
.sconsign.dblite
7+
cconfig.h
8+
.vscode/
9+
rtconfig.pyc
10+
*.old
11+
board/board.dtb

‎bsp/allwinner/avaota-f2/Kconfig‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
mainmenu "RT-Thread Project 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+
12+
config BOARD_AVAOTA_F2_C907
13+
bool
14+
select ARCH_RISCV
15+
select ARCH_RISCV32
16+
select RT_USING_COMPONENTS_INIT
17+
select RT_USING_USER_MAIN
18+
default y
19+
20+
config __STACKSIZE__
21+
int "stack size for interrupt"
22+
default 8192

‎bsp/allwinner/avaota-f2/README.md‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Avaota F2 / V861 — C907
2+
3+
Allwinner V861(Avaota F2)C907 最小 BSP:UART 控制台 + msh。
4+
5+
## 硬件要点
6+
7+
| 项 | 值 |
8+
|----|----|
9+
| 装载 | `0x40000000`(2MB DRAM 窗口,见 `link.lds`) |
10+
| UART0 | `0x02500000`,115200 8N1;引脚 PH9/PH10(DT:`board/board.dtb`,构建时生成) |
11+
| 核 | C907,RV32 工具链配置(见 `rtconfig.py`) |
12+
13+
## 已在板子上验证
14+
15+
- RT-Thread banner + FinSH/`msh`
16+
- DT 解析 UART(`uart-from-fdt`)
17+
- 双核 SMP(可选配置;默认 `RT_CPUS_NR=2`)
18+
19+
MMC、异构 AMP、OpenAMP **不在本阶段声明为已支持**。源码中的 `drv_mmc.c` / `amp_mbox.h` 为后续工作保留,默认 `main` 不依赖它们。
20+
21+
## 编译
22+
23+
`board/builtin_fdt.S` 用 `.incbin` 内嵌 `board/board.dtb`。该 DTB 由 `board/gen_board_dtb.py` 在构建时自动生成(SCons 已接入,无需手工准备)。首次构建需要 `python3` 与 `fdt` 模块:
24+
25+
```sh
26+
pip3 install fdt
27+
```
28+
29+
推荐 [RT-Thread Env 2.x](https://github.com/RT-Thread/rt-thread/blob/master/documentation/env/env.md):用 `sdk` 安装/卸载工具链;本机已有工具链时,简单配置后 Env 可自动探测。
30+
31+
```text
32+
cd bsp/allwinner/avaota-f2
33+
scons -j8
34+
```
35+
36+
产物:`rtthread.bin`(已在 `.gitignore`);`board/board.dtb` 为构建产物,同样不入库。
37+
38+
## 烧录提示
39+
40+
板级常用 FEL 冷链(`init_dram` → payload @`0x40000000` → `c907_boot`)。具体工具与镜像以你的 SyterKit / xfel 流程为准。

‎bsp/allwinner/avaota-f2/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+
cwd = GetCurrentDir()
5+
objs = []
6+
for name in os.listdir(cwd):
7+
path = os.path.join(cwd, name)
8+
if os.path.isfile(os.path.join(path, 'SConscript')):
9+
objs = objs + SConscript(os.path.join(name, 'SConscript'))
10+
Return('objs')

‎bsp/allwinner/avaota-f2/SConstruct‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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.path.join(os.getcwd(), '..', '..', '..'))
9+
10+
sys.path.insert(0, 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+
objs = PrepareBuilding(env, RTT_ROOT)
29+
DoBuilding(TARGET, objs)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from building import *
2+
3+
cwd = GetCurrentDir()
4+
src = Glob('*.c')
5+
group = DefineGroup('Applications', src, depend = [''], CPPPATH = [cwd])
6+
Return('group')
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright (c) 2006-2026, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <rtthread.h>
8+
9+
int main(void)
10+
{
11+
rt_kprintf("Hello Avaota F2 C907\n");
12+
return 0;
13+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from building import *
2+
import os
3+
import sys
4+
5+
Import('env')
6+
7+
cwd = GetCurrentDir()
8+
src = Split('''
9+
board.c
10+
board_smp.c
11+
drv_rpmsg.c
12+
clint.c
13+
tick.c
14+
trap.c
15+
cpuport_smp.c
16+
startup_gcc.S
17+
''')
18+
19+
# board.dtb is generated by gen_board_dtb.py and embedded by builtin_fdt.S with
20+
# .incbin, which scons cannot scan. Build the object here so that it can depend
21+
# on the generated DTB: a clean tree generates the DTB before assembling, and
22+
# editing the generator rebuilds both.
23+
dtb = env.Command(os.path.join(cwd, 'board.dtb'),
24+
os.path.join(cwd, 'gen_board_dtb.py'),
25+
'"%s" $SOURCE' % sys.executable)
26+
fdt_obj = env.Object(os.path.join(cwd, 'builtin_fdt.S'))
27+
env.Depends(fdt_obj, dtb)
28+
29+
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = [cwd])
30+
group += fdt_obj
31+
32+
Return('group')
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/*
2+
* Copyright (c) 2006-2026, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Must match avaota-f2-e907/board/amp_mbox.h slot layout.
7+
*
8+
* C907 stores were invisible to E907 when only DE-off / call-all was used.
9+
* Clean the line by VA (c906+c908 encodings) after each store; invalidate
10+
* before each load. Avoid l2cache.iall (hangs).
11+
*/
12+
13+
#ifndef AMP_MBOX_H__
14+
#define AMP_MBOX_H__
15+
16+
#include <stdint.h>
17+
18+
#define AMP_SLOT_BASE 0x41000000U
19+
#define AMP_SLOT_C907 (AMP_SLOT_BASE + 0x00U)
20+
#define AMP_SLOT_C907_REPLY (AMP_SLOT_BASE + 0x04U)
21+
#define AMP_SLOT_E907 (AMP_SLOT_BASE + 0x20U)
22+
#define AMP_SLOT_E907_STEP (AMP_SLOT_BASE + 0x24U)
23+
#define AMP_SLOT_PING_REQ (AMP_SLOT_BASE + 0x40U)
24+
25+
#define AMP_E2C_SEQ (AMP_SLOT_BASE + 0x80U)
26+
#define AMP_E2C_DATA (AMP_SLOT_BASE + 0x84U)
27+
#define AMP_E2C_ACK (AMP_SLOT_BASE + 0x88U)
28+
#define AMP_C2E_SEQ (AMP_SLOT_BASE + 0x90U)
29+
#define AMP_C2E_DATA (AMP_SLOT_BASE + 0x94U)
30+
#define AMP_C2E_ACK (AMP_SLOT_BASE + 0x98U)
31+
#define AMP_MSGBOX_PROBE (AMP_SLOT_BASE + 0xA0U)
32+
33+
#define AMP_MAGIC_C907 0xC907A11CU
34+
#define AMP_MAGIC_E907 0xE907A11CU
35+
#define AMP_PING_REQ 0xA11C0001U
36+
37+
#define AMP_MXSTATUS 0x7c0U
38+
#define AMP_MXSTATUS_THEADISAEE (1UL << 22)
39+
40+
#define AMP_MSGBOX_BASE 0x03003000U
41+
#define AMP_MSGBOX_VER (AMP_MSGBOX_BASE + 0x10U)
42+
43+
static inline void amp_fence(void)
44+
{
45+
__asm__ volatile("fence ow, ow" ::: "memory");
46+
}
47+
48+
static inline void amp_enable_thead_isa(void)
49+
{
50+
unsigned long v;
51+
__asm__ volatile("csrr %0, %1" : "=r"(v) : "i"(AMP_MXSTATUS));
52+
v |= AMP_MXSTATUS_THEADISAEE;
53+
__asm__ volatile("csrw %0, %1" ::"i"(AMP_MXSTATUS), "r"(v) : "memory");
54+
}
55+
56+
static inline void amp_sync(void)
57+
{
58+
__asm__ volatile(".long 0x0180000b" ::: "memory"); /* sync */
59+
}
60+
61+
/* Clean D-cache line by VA: try c906 (rs2=x4) and c908 (rs2=x5) encodings. */
62+
static inline void amp_dcache_clean_va(uint32_t addr)
63+
{
64+
amp_enable_thead_isa();
65+
__asm__ volatile(".insn r 0x0b, 0, 1, x0, %0, x4" ::"r"(addr) : "memory");
66+
__asm__ volatile(".insn r 0x0b, 0, 1, x0, %0, x5" ::"r"(addr) : "memory");
67+
amp_sync();
68+
amp_fence();
69+
}
70+
71+
static inline void amp_dcache_inv_va(uint32_t addr)
72+
{
73+
amp_enable_thead_isa();
74+
__asm__ volatile(".insn r 0x0b, 0, 1, x0, %0, x6" ::"r"(addr) : "memory"); /* iva */
75+
__asm__ volatile(".insn r 0x0b, 0, 1, x0, %0, x5" ::"r"(addr) : "memory"); /* c906 may map differently */
76+
amp_sync();
77+
amp_fence();
78+
}
79+
80+
static inline void amp_coherent_begin(void)
81+
{
82+
amp_enable_thead_isa();
83+
__asm__ volatile(".long 0x0010000b" ::: "memory"); /* dcache.call */
84+
amp_sync();
85+
amp_fence();
86+
}
87+
88+
static inline uint32_t amp_read(uint32_t addr)
89+
{
90+
amp_dcache_inv_va(addr);
91+
return *(volatile uint32_t *)addr;
92+
}
93+
94+
static inline void amp_write(uint32_t addr, uint32_t value)
95+
{
96+
*(volatile uint32_t *)addr = value;
97+
amp_fence();
98+
amp_dcache_clean_va(addr);
99+
__asm__ volatile(".long 0x0010000b" ::: "memory"); /* dcache.call */
100+
amp_sync();
101+
amp_fence();
102+
}
103+
104+
#endif

0 commit comments

Comments
 (0)