Skip to content

[BSP][K230] Add soft-fpu option for k230 #10400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions bsp/k230/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
11 changes: 9 additions & 2 deletions bsp/k230/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')

Comment on lines +41 to +45
Copy link
Preview

Copilot AI Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The repeated use of replace() across multiple flags (DEVICE, CFLAGS, LFLAGS, AFLAGS) could be refactored into a helper function to improve maintainability and reduce duplication.

Suggested change
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')
def update_flag(flag_name, old_value, new_value):
setattr(rtconfig, flag_name, getattr(rtconfig, flag_name).replace(old_value, new_value))
update_flag('DEVICE', '-march=rv64imafdcv -mabi=lp64d', '-march=rv64imafdc -mabi=lp64')
update_flag('CFLAGS', '-march=rv64imafdcv -mabi=lp64d', '-march=rv64imafdc -mabi=lp64')
update_flag('LFLAGS', '-march=rv64imafdcv -mabi=lp64d', '-march=rv64imafdc -mabi=lp64')
update_flag('AFLAGS', '-march=rv64imafdcv -mabi=lp64d', '-march=rv64imafdc -mabi=lp64')

Copilot uses AI. Check for mistakes.

DefaultEnvironment(tools=[])
env = Environment(tools = ['mingw'],
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
Expand Down