diff --git a/bsp/k230/Kconfig b/bsp/k230/Kconfig index 93af5a32488..3ddee1c468c 100644 --- a/bsp/k230/Kconfig +++ b/bsp/k230/Kconfig @@ -10,14 +10,14 @@ source "$RTT_DIR/Kconfig" source "$PKGS_DIR/Kconfig" rsource "board/Kconfig" -config BOARD_fpgac908 +config BOARD_C908 bool select ARCH_RISCV64 select RT_USING_COMPONENTS_INIT select RT_USING_USER_MAIN select RT_USING_CACHE select ARCH_MM_MMU - select ARCH_RISCV_FPU_D + select ARCH_RISCV_FPU select ARCH_REMAP_KERNEL if RT_USING_SMART default y @@ -38,3 +38,17 @@ choice BSP_ROOTFS_TYPE select RT_USING_DFS_CROMFS select PKG_USING_ZLIB endchoice + +choice BSP_RISCV_USING_FPU + prompt "FPU precision" + default BSP_RISCV_FPU_D + + config BSP_RISCV_FPU_SOFT + bool "Software floating-point" + select ARCH_RISCV_FPU + + config BSP_RISCV_FPU_D + bool "Double-precision floating-point with Vector" + select ARCH_RISCV_FPU_D + select ARCH_RISCV_VECTOR +endchoice diff --git a/bsp/k230/SConstruct b/bsp/k230/SConstruct index fdb0d5eb872..d12a8ff8e1b 100644 --- a/bsp/k230/SConstruct +++ b/bsp/k230/SConstruct @@ -8,7 +8,6 @@ from rtconfig import RTT_ROOT import sys def generate_ldscript(input, output): - if not os.path.exists(input): print('Error: file', input, 'not found') return @@ -30,12 +29,20 @@ def generate_ldscript(input, output): print(output, 'is generated from', input) - sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] from building import * TARGET = 'rtthread.' + rtconfig.TARGET_EXT +# apply soft-FPU config +options = LocalOptions("rtconfig.h") +soft_fpu = GetLocalDepend(options, 'BSP_RISCV_FPU_SOFT') +if soft_fpu: + rtconfig.DEVICE = rtconfig.DEVICE.replace('-march=rv64imafdcv -mabi=lp64d', '-march=rv64imafdc -mabi=lp64') + rtconfig.CFLAGS = rtconfig.CFLAGS.replace('-march=rv64imafdcv -mabi=lp64d', '-march=rv64imafdc -mabi=lp64') + rtconfig.LFLAGS = rtconfig.LFLAGS.replace('-march=rv64imafdcv -mabi=lp64d', '-march=rv64imafdc -mabi=lp64') + rtconfig.AFLAGS = rtconfig.AFLAGS.replace('-march=rv64imafdcv -mabi=lp64d', '-march=rv64imafdc -mabi=lp64') + DefaultEnvironment(tools=[]) env = Environment(tools = ['mingw'], AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, diff --git a/components/lwp/vdso/user/arch/risc-v/SConstruct b/components/lwp/vdso/user/arch/risc-v/SConstruct index 6613239bf2b..4680384ca08 100644 --- a/components/lwp/vdso/user/arch/risc-v/SConstruct +++ b/components/lwp/vdso/user/arch/risc-v/SConstruct @@ -1,5 +1,6 @@ import os import sys +import subprocess arguments = sys.argv[2] vdso_usr = arguments @@ -7,7 +8,33 @@ vdso_path = os.path.join(vdso_usr, '..', '..', '..') EXEC_PATH = os.getenv('RTT_EXEC_PATH') or '/usr/bin' PREFIX = os.getenv('RTT_CC_PREFIX') or 'riscv64-none-elf-' -DEVICE = os.getenv('RTT_DEVICE') or ' -march=rv64imafdc -mabi=lp64' + +def get_riscv64_default_arch_abi(gcc_bin): + try: + result = subprocess.check_output( + [gcc_bin, '-Q', '--help=target'], + universal_newlines=True + ) + arch = None + abi = None + for line in result.splitlines(): + if '-march=' in line: + arch = line.strip().split()[1] + arch = arch.split('_')[0] # Get the base architecture, e.g., rv64imafdc + if '-mabi=' in line and 'option' not in line: + abi = line.strip().split()[1] + return arch, abi + except Exception as e: + print("Error getting arch/abi:", e) + return None, None + +# get the gcc path +CC_BIN = PREFIX + 'gcc' +arch, abi = get_riscv64_default_arch_abi(CC_BIN) +if arch and abi: + DEVICE = f' -march={arch} -mabi={abi} ' +else: + DEVICE = ' -march=rv64imafdc -mabi=lp64' # fallback CC = PREFIX + 'gcc' CPP = PREFIX + 'cpp'