Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7503

SDK • Help needed for Building RISC-V Compiler

$
0
0
I followed the guide in "Pico C SDK" document, Page 31, for building a GCC-14 toolchain for RISC-V. 10 hours of compilation later, 16GB of disk taken from me, I now have something which appears to be a GCC-14 RISC-V toolchain -

Code:

pi@Pi4B:/tmp $ riscv32-unknown-elf-gcc --versionriscv32-unknown-elf-gcc (gb0dd13efca6) 14.2.1 20240809Copyright (C) 2024 Free Software Foundation, Inc.This is free software; see the source for copying conditions.  There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Unfortunately, not quite -

Code:

pi@Pi4B:/tmp $ /usr/bin/riscv32-unknown-elf-gcc rv-test.criscv32-unknown-elf-gcc: fatal error: cannot execute 'cc1': posix_spawnp: No such file or directorycompilation terminated.
Same issue, unsurprisingly, when running 'cmake' to create the build files for an RP235X project.

I'll put my hands up to having followed the documented instructions to the letter, which ended up putting the built executables in '/opt/riscv/gcc14-rp2350-no-zcmp/bin' which isn't in my path so I copied them to '/usr/bin' which is and where all my other GCC compiler executables are.

That might be the issue, I don't know. I left the originals in place in case the copied executables contained hard links to where they think they are, were.

If anyone does know, knows what I need to do to fix things, I'd be very grateful because I really don't want to have to keep doing 10 hour builds to get it right.

Update : Seems there may be more files to copy than just the executables I have. I'll let you know if I get further.

Update : Seems I needed to copy at least 'cc1' -

Code:

from /opt/riscv/gcc14-rp2350-no-zcmp/libexec/gcc/riscv32-unknown-elf/14.2.1/cc1to   /usr/libexec/gcc/riscv32-unknown-elf/14.2.1/cc1
That got me further and I guess I can ignore this error as something like not having built 'libc' or something which might not matter for an RP235X build. At least we are beyond the 'cc1' error -

Code:

pi@Pi4B:/tmp $ riscv32-unknown-elf-gcc rv-test.cIn file included from /opt/riscv/gcc14-rp2350-no-zcmp/riscv32-unknown-elf/include/stdio.h:35,                 from rv-test.c:1:/opt/riscv/gcc14-rp2350-no-zcmp/riscv32-unknown-elf/include/sys/cdefs.h:47:10: fatal error: stddef.h: No such file or directory   47 | #include <stddef.h>      |          ^~~~~~~~~~compilation terminated.
The problem now seems more challenging -

Code:

pi@Pi4B:~/mypico/simplest-usb/build-rp235x-riscv $ cmake -DPICO_PLATFORM=rp2350-riscv -DPICO_BOARD=pico2 ..PICO_SDK_PATH is /home/pi/pico/pico-sdkTarget board (PICO_BOARD) is 'pico2'.Using board configuration from /home/pi/pico/pico-sdk/src/boards/include/boards/pico2.hPico Platform (PICO_PLATFORM) is 'rp2350-riscv'.-- The C compiler identification is unknown-- The CXX compiler identification is unknown-- The ASM compiler identification is GNU-- Found assembler: /usr/bin/riscv32-unknown-elf-gcc-- Detecting C compiler ABI info-- Detecting C compiler ABI info - failed-- Check for working C compiler: /usr/bin/riscv32-unknown-elf-gcc-- Check for working C compiler: /usr/bin/riscv32-unknown-elf-gcc - brokenCMake Error at /usr/share/cmake-3.25/Modules/CMakeTestCCompiler.cmake:70 (message):  The C compiler    "/usr/bin/riscv32-unknown-elf-gcc"  is not able to compile a simple test program.  It fails with the following output:    Change Dir: /home/pi/mypico/simplest-usb/build-rp235x-riscv/CMakeFiles/CMakeScratch/TryCompile-iYoCC7    Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_1cc6f/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_1cc6f.dir/build.make CMakeFiles/cmTC_1cc6f.dir/build    gmake[1]: Entering directory '/home/pi/mypico/simplest-usb/build-rp235x-riscv/CMakeFiles/CMakeScratch/TryCompile-iYoCC7'    Building C object CMakeFiles/cmTC_1cc6f.dir/testCCompiler.c.obj    /usr/bin/riscv32-unknown-elf-gcc   -march=rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb -mabi=ilp32  -o CMakeFiles/cmTC_1cc6f.dir/testCCompiler.c.obj -c /home/pi/mypico/simplest-usb/build-rp235x-riscv/CMakeFiles/CMakeScratch/TryCompile-iYoCC7/testCCompiler.c    Assembler messages:    Error: unknown architecture `rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb'    Error: unrecognized option -march=rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb    gmake[1]: *** [CMakeFiles/cmTC_1cc6f.dir/build.make:78: CMakeFiles/cmTC_1cc6f.dir/testCCompiler.c.obj] Error 1    gmake[1]: Leaving directory '/home/pi/mypico/simplest-usb/build-rp235x-riscv/CMakeFiles/CMakeScratch/TryCompile-iYoCC7'    gmake: *** [Makefile:127: cmTC_1cc6f/fast] Error 2
Specifically -

Code:

Error: unknown architecture `rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb'Error: unrecognized option -march=rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb
So, all that effort for nothing ? I've built a RISC-V compiler which doesn't understand the architecture which the Pico SDK is expecting to use ?

I built it as per the documentation, used the specified './configure' which includes, reformatted for readability -

Code:

--with-arch=               rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb--with-multilib-generator="rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb-ilp32--;                           rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb-ilp32--"
That last looks close to what 'cmake' is looking for when the first two don't but I don't know enough about this stuff to know if it is or isn't.

I'm need of help and guidance again.

Statistics: Posted by hippy — Wed Aug 14, 2024 12:18 pm — Replies 0 — Views 54



Viewing all articles
Browse latest Browse all 7503

Trending Articles