Skip to content

Commit 5036816

Browse files
committed
add qemu-riscv-virt64 bsp
add qemu-riscv-virt64 bsp
1 parent 9a4e270 commit 5036816

37 files changed

+3918
-0
lines changed

bsp/qemu-riscv-virt64/.config

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

bsp/qemu-riscv-virt64/Kconfig

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
mainmenu "RT-Thread Project Configuration"
2+
3+
config BSP_DIR
4+
string
5+
option env="BSP_ROOT"
6+
default "."
7+
8+
config RTT_DIR
9+
string
10+
option env="RTT_ROOT"
11+
default "../../"
12+
13+
config PKGS_DIR
14+
string
15+
option env="PKGS_ROOT"
16+
default "packages"
17+
18+
source "$RTT_DIR/Kconfig"
19+
source "$PKGS_DIR/Kconfig"
20+
21+
config BOARD_virt
22+
bool
23+
select ARCH_RISCV64
24+
select RT_USING_COMPONENTS_INIT
25+
select RT_USING_USER_MAIN
26+
default y
27+
28+
config RT_USING_USERSPACE
29+
bool
30+
default y
31+
32+
source "driver/Kconfig"
33+
34+
config __STACKSIZE__
35+
int "stack size for interrupt"
36+
default 4096

bsp/qemu-riscv-virt64/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+
objs = []
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+
objs = objs + SConscript(os.path.join(d, 'SConscript'))
13+
14+
Return('objs')

bsp/qemu-riscv-virt64/SConstruct

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import os
2+
import sys
3+
import rtconfig
4+
5+
from rtconfig import RTT_ROOT
6+
7+
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
8+
from building import *
9+
10+
TARGET = 'rtthread.' + rtconfig.TARGET_EXT
11+
12+
DefaultEnvironment(tools=[])
13+
env = Environment(tools = ['mingw'],
14+
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
15+
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
16+
CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
17+
AR = rtconfig.AR, ARFLAGS = '-rc',
18+
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
19+
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
20+
env['ASCOM'] = env['ASPPCOM']
21+
22+
Export('RTT_ROOT')
23+
Export('rtconfig')
24+
rtconfig.CPU='virt64'
25+
rtconfig.ARCH='risc-v'
26+
27+
# prepare building environment
28+
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu = False)
29+
30+
stack_size = 4096
31+
32+
stack_lds = open('link_stacksize.lds', 'w')
33+
if GetDepend('__STACKSIZE__'): stack_size = GetDepend('__STACKSIZE__')
34+
stack_lds.write('__STACKSIZE__ = %d;' % stack_size)
35+
stack_lds.close()
36+
37+
# make a building
38+
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')
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright (c) 2006-2018, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
*/
9+
10+
#include <rtthread.h>
11+
#include <rthw.h>
12+
#include <stdio.h>
13+
#include <string.h>
14+
15+
int main(void)
16+
{
17+
void rt_hw_uart_start_rx_thread();
18+
rt_hw_uart_start_rx_thread();
19+
printf("Hello RISC-V\n");
20+
21+
return 0;
22+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
3+
menu "General Purpose UARTs"
4+
5+
menuconfig BSP_USING_UART1
6+
bool "Enable UART1"
7+
default n
8+
if BSP_USING_UART1
9+
config BSP_UART1_TXD_PIN
10+
int "uart1 TXD pin number"
11+
default 20
12+
config BSP_UART1_RXD_PIN
13+
int "uart1 RXD pin number"
14+
default 21
15+
endif
16+
17+
endmenu
18+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# RT-Thread building script for component
2+
3+
from building import *
4+
5+
cwd = GetCurrentDir()
6+
src = Glob('*.c')
7+
CPPPATH = [cwd]
8+
9+
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
10+
11+
objs = [group]
12+
13+
list = os.listdir(cwd)
14+
15+
for item in list:
16+
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
17+
objs = objs + SConscript(os.path.join(item, 'SConscript'))
18+
19+
Return('objs')
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef _SBI_ASM_H
2+
#define _SBI_ASM_H
3+
4+
.macro SBI_CALL which
5+
li a7, \which
6+
ecall
7+
nop
8+
.endm
9+
10+
#endif /* _SBI_ASM_H */
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2019-2020, Xim
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
*/
7+
#ifndef _ASM_SBI_DEF_H
8+
#define _ASM_SBI_DEF_H
9+
10+
#define SBI_SET_TIMER 0
11+
#define SBI_CONSOLE_PUTCHAR 1
12+
#define SBI_CONSOLE_GETCHAR 2
13+
#define SBI_CLEAR_IPI 3
14+
#define SBI_SEND_IPI 4
15+
#define SBI_REMOTE_FENCE_I 5
16+
#define SBI_REMOTE_SFENCE_VMA 6
17+
#define SBI_REMOTE_SFENCE_VMA_ASID 7
18+
#define SBI_SHUTDOWN 8
19+
20+
#define SBI_CONSOLE_PUTSTR 9
21+
22+
#define SBI_SD_WRITE 10
23+
#define SBI_SD_READ 11
24+
#define SBI_NET_WRITE 12
25+
#define SBI_NET_READ 13
26+
27+
#endif /* _ASM_SBI_DEF_H */

0 commit comments

Comments
 (0)