-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[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
base: master
Are you sure you want to change the base?
Conversation
📌 Code Review Assignment🏷️ Tag: bsp_k230Path: Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2025-06-17 00:32 UTC)
📝 Review Instructions
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for a soft-FPU option for the k230 board by updating compiler flag settings in the SConstruct file and introducing new FPU configuration options in the Kconfig file.
- Updated the SConstruct to adjust compiler flags when the soft-FPU option is enabled.
- Modified the Kconfig to rename a board configuration and add a choice for FPU precision (software vs. double-precision).
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
bsp/k230/SConstruct | Added soft-FPU conditional logic that updates compile flags. |
bsp/k230/Kconfig | Updated board configuration naming and introduced a new choice block for FPU options. |
Comments suppressed due to low confidence (1)
bsp/k230/Kconfig:42
- [nitpick] Consider adding inline comments in the choice block to explain the differences and implications of selecting the software FPU versus double-precision options, to help users make an informed decision.
choice BSP_RISCV_USING_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') | ||
|
There was a problem hiding this comment.
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.
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.
请问这个所谓兼容是指将工具链切换到 |
我尝试应用该补丁后,menuconfig 换成 ”FPU precision (Software floating-point)“ ,工具链换成 ”riscv64-linux-musleabi_for_x86_64-pc-linux-gnu_latest“, 编译报错: scons: Reading SConscript files ...
scons: Entering directory `/home/u/ws/canaan/rt-thread/components/lwp/vdso/user/arch/risc-v'
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
riscv64-linux-musleabi-gcc -o vdso_sys.os -c -mcmodel=medany -march=rv64imafdcv -mabi=lp64d -Wall -Wno-cpp -std=gnu99 -fdiagnostics-color=always -fPIC -O2 -I . -I /home/u/ws/canaan/rt-thread/components/lwp/vdso/user/arch/risc-v/../../.. -fPIC vdso_sys.c
riscv64-linux-musleabi-gcc -o /home/u/ws/canaan/rt-thread/components/lwp/vdso/user/build/libvdso.so -mcmodel=medany -march=rv64imafdcv -mabi=lp64d -Bsymbolic -Wl,--gc-sections -T /home/u/ws/canaan/rt-thread/components/lwp/vdso/user/arch/risc-v/vdso.lds -shared vdso_sys.os
/home/u/ws/test-rtt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/bin/../lib/gcc/riscv64-linux-musleabi/12.2.0/../../../../riscv64-linux-musleabi/bin/ld: vdso_sys.os: can't link double-float modules with soft-float modules
/home/u/ws/test-rtt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/bin/../lib/gcc/riscv64-linux-musleabi/12.2.0/../../../../riscv64-linux-musleabi/bin/ld: failed to merge target specific data of file vdso_sys.os
collect2: error: ld returned 1 exit status
scons: *** [/home/u/ws/canaan/rt-thread/components/lwp/vdso/user/build/libvdso.so] Error 1
scons: building terminated because of errors.
CalledProcessError: Command '['scons', '-C', '/home/u/ws/canaan/rt-thread/components/lwp/vdso/user/arch/risc-v']' returned non-zero exit status 2.:
File "/home/u/ws/canaan/rt-thread/bsp/k230/SConstruct", line 61:
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu = False)
File "/home/u/ws/canaan/rt-thread/bsp/k230/../../tools/building.py", line 408:
objs.extend(SConscript(Rtt_Root + '/components/SConscript',
File "/usr/lib/python3/dist-packages/SCons/Script/SConscript.py", line 661:
return method(*args, **kw)
File "/usr/lib/python3/dist-packages/SCons/Script/SConscript.py", line 598:
return _SConscript(self.fs, *files, **subst_kw)
File "/usr/lib/python3/dist-packages/SCons/Script/SConscript.py", line 287:
exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
File "/home/u/ws/canaan/rt-thread/components/SConscript", line 15:
objs = objs + SConscript(os.path.join(item, 'SConscript'))
File "/usr/lib/python3/dist-packages/SCons/Script/SConscript.py", line 661:
return method(*args, **kw)
File "/usr/lib/python3/dist-packages/SCons/Script/SConscript.py", line 598:
return _SConscript(self.fs, *files, **subst_kw)
File "/usr/lib/python3/dist-packages/SCons/Script/SConscript.py", line 287:
exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
File "/home/u/ws/canaan/rt-thread/components/lwp/SConscript", line 57:
group = group + SConscript(os.path.join('vdso', 'SConscript'))
File "/usr/lib/python3/dist-packages/SCons/Script/SConscript.py", line 661:
return method(*args, **kw)
File "/usr/lib/python3/dist-packages/SCons/Script/SConscript.py", line 598:
return _SConscript(self.fs, *files, **subst_kw)
File "/usr/lib/python3/dist-packages/SCons/Script/SConscript.py", line 287:
exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
File "/home/u/ws/canaan/rt-thread/components/lwp/vdso/SConscript", line 41:
result = subprocess.run(command, env=process_env, check=True)
File "/usr/lib/python3.10/subprocess.py", line 526:
raise CalledProcessError(retcode, process.args, 看上去编译选项并没有修改成功。简单跟踪了一下代码,感觉 |
唔,是vdso那边有些问题,会默认绑定rtconfig.py中的配置,而不认动态修改的。所以目前按soft-fpu方式使用,需要关闭vdso才行。 |
你是准备继续修改这个问题,还是说打算让用户自己配置解决? 如果是配置,是否可以在 enable soft-fpu 时联动解决,否则如果要用户自己手动配置,则还要改 readme |
这个问题是否有回复? |
是的,当使用soft-fpu时,就对应上面的这个工具链(riscv64-linux-musleabi-)。这个也是目前smart build中用的工具链。 |
这个暂时需要用户手动配置下。后续在vdso那边,想办法修复下。 |
还有办法在 kconfig 中确保当我们选择 BSP_RISCV_FPU_D 时自动强制 disable RT_USING_VDSO?我没有找到好的办法。 如果没有办法确保配置自动 disable,请在这个 PR 中补充 README 文件说明需要人工操作。等后续 vdso 那边修复了再删除。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
见上面的评论,如果不能自动配置实现,需要更新 readme
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
当前内核是使用双精度浮点,V指令集扩展方式编译。加入Soft-FPU的选项,以兼容到类似qemu-riscv64的方式。
你的解决方案是什么 (what is your solution)
在Kconfig中加入对Soft-FPU的选项,同时在SConstruct文件中对Soft-FPU情况下,调整编译参数为
-march=rv64imafdc -mabi=lp64
。请提供验证的bsp和config (provide the config and bsp)
]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0
代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up