Skip to content

Commit

Permalink
[bsp] k230添加Vector配置
Browse files Browse the repository at this point in the history
  • Loading branch information
heyuanjie87 committed Oct 16, 2024
1 parent 49b6614 commit 9c31948
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
1 change: 1 addition & 0 deletions bsp/k230/.config
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ CONFIG_ARCH_MM_MMU=y
CONFIG_KERNEL_VADDR_START=0xFFFFFFC000220000
CONFIG_ARCH_RISCV=y
CONFIG_ARCH_RISCV_FPU=y
# CONFIG_ARCH_RISCV_VECTOR is not set
CONFIG_ARCH_RISCV_FPU_D=y
CONFIG_ARCH_RISCV64=y
CONFIG_ARCH_USING_NEW_CTX_SWITCH=y
Expand Down
6 changes: 5 additions & 1 deletion bsp/k230/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ config BOARD_fpgac908
select ARCH_REMAP_KERNEL if RT_USING_SMART
default y

config ARCH_RISCV_VECTOR
bool "Enable RISCV Vector"
default n

config __STACKSIZE__
int "stack size for interrupt"
default 4096

config C908_PLIC_PHY_ADDR
int "PLIC base address"
hex "PLIC base address"
default 0xF00000000

config BSP_ROOTFS_TYPE_CROMFS
Expand Down
20 changes: 20 additions & 0 deletions bsp/k230/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ source ~/.env/env.sh
pkgs --update
```

## 编译器

通用版(rv64imafdc-lp64):
https://download.rt-thread.org/download/rt-smart/toolchains/riscv64gc-linux-musleabi_for_x86_64-pc-linux-gnu_222725-8a397096c1.tar.bz2

V指令版(rv64imafdcv-lp64d):
https://download.rt-thread.org/rt-smart/riscv64/riscv64-unknown-linux-musl-rv64imafdcv-lp64d-20230608.tar.bz2


## 将根文件系统编译进内核

为了方便测试,这里将根文件系统制作成CROMFS格式转换成C代码编译进内核。
Expand Down Expand Up @@ -36,3 +45,14 @@ export RTT_EXEC_PATH=/mnt/e/tools/riscv64gc/bin # 你自己的编译器路径
scons -j8
```

### 自定义-march与-mabi参数

默认-march=rv64imafdc,-mabi=lp64。
如果你想修改他们可以在执行scons时传入参数,如:
```
export RTT_EXEC_PATH=~/.tools/gnu_gcc/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/bin
scons -j8 march=rv64imafdcv mabi=lp64d
```
备注:使用V扩展需要使用`scons --menuconfig`开启内核对它的支持
13 changes: 10 additions & 3 deletions bsp/k230/rtconfig.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from SCons.Script import ARGUMENTS

# toolchains options
ARCH ='risc-v'
Expand All @@ -20,7 +21,13 @@

EXEC_PATH = os.getenv('RTT_EXEC_PATH', EXEC_PATH)

BUILD = 'debug'
if ARGUMENTS.get('debug', 1):
BUILD = 'debug'
else:
BUILD = 'release'

MARCH = ARGUMENTS.get('march', 'rv64imafdc')
MABI = ARGUMENTS.get('mabi', 'lp64')

if PLATFORM == 'gcc':
# toolchains
Expand All @@ -36,15 +43,15 @@
OBJDUMP = PREFIX + 'objdump'
OBJCPY = PREFIX + 'objcopy'

DEVICE = ' -mcmodel=medany -march=rv64imafdc -mabi=lp64'
DEVICE = fr' -mcmodel=medany -march={MARCH} -mabi={MABI}'
CFLAGS = DEVICE + ' -Wno-cpp -fvar-tracking -ffreestanding -fno-common -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -D_POSIX_SOURCE '
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -D__ASSEMBLY__'
LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,_start -T link.lds' + ' -lsupc++ -lgcc -static'
CPATH = ''
LPATH = ''

if BUILD == 'debug':
CFLAGS += ' -O2 -g -gdwarf-2'
CFLAGS += ' -O0 -g -gdwarf-2'
AFLAGS += ' -g -gdwarf-2'
else:
CFLAGS += ' -O2 -g -gdwarf-2'
Expand Down

0 comments on commit 9c31948

Please sign in to comment.