This post was flagged by the community and is temporarily hidden.
You are trying to use an x86 gcc to compile RISC-V code, which won’t work. It isn’t clear what is wrong. A RISC-V compiler should have been built before building riscv-pk, and should have been used for the riscv-pk build. Exactly how this works depends on exactly which version of freedom-u-sdk you have. The current version builds a compiler via buildroot, and then uses it for the riscv-pk build. Your work/riscv-pk/Makefile should have a line
CC := riscv64-sifive-linux-gnu-gcc
and this compiler should be present in work/buildroot_initramfs/host/bin/, and the Makefile should put that on your path before starting the riscv-pk build.
It looks like you tried to set CFLAGS for your build. Don’t do that, as that can’t possibly work. Some of the binaries are x86 binaries and some of the binaries are RISC-V binaries, and your CFLAGS setting won’t work for both. Ideally we would have different make variables for host and target binaries, but we don’t. So don’t try to set CFLAGS as it won’t work. Maybe this caused your build failure some how.
There are ISA and ABI makefile variables you can try using. However, these are not tested, not supported, and unlikely to do anything useful unless you are willing to spend a lot of time fixing them. Such fixes may require linux kernel, glibc, qemu, etc work.
But rv64gc/lp64d is the default anyways, so not clear why you are trying to set CFLAGS.
Thank you very much for your reply. I followed the steps given in Readme, and there was no mention of what to configure. And the RISC-V compiler in my environment has been compiled.
Checkout this repository. Then you will need to checkout all of the linked
git submodule update --recursive --init
This will take some time and require around 7GB of disk space. Some modules may
fail because certain dependencies don’t have the best git hosting. The only
solution is to wait and try again later (or ask someone for a copy of that
Once the submodules are initialized, run
make and the complete toolchain
and images will be built. The completed build tree will consume about 14G of disk
I just tried a build with a fresh checkout on a machine that’s never built it before. I get the same errors. I’m certainly not setting CFLAGS.
CFLAGS="-mabi=lp64d -march=rv64imafdc" make PATH=/home/bruce/riscv/install/bin:/home/bruce/tmp/riscv/install/bin:/home/bruce/tmp/riscv/install/bin:/home/bruce/riscv/install/bin:/home/bruce/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin -C /home/bruce/riscv/freedom-u-sdk/work/riscv-pk
make: Entering directory ‘/home/bruce/riscv/freedom-u-sdk/work/riscv-pk’
gcc -MMD -MP -Wall -Werror -D__NO_INLINE -mcmodel=medany -O2 -std=gnu99 -Wno-unused -Wno-attributes -fno-delete-null-pointer-checks -fno-PIE -mabi=lp64d -march=rv64imafdc -DBBL_PAYLOAD=“bbl_payload” -DBBL_LOGO_FILE=“bbl_logo_file” -I. -I/home/bruce/riscv/freedom-u-sdk/riscv-pk/pk -I/home/bruce/riscv/freedom-u-sdk/riscv-pk/bbl -I/home/bruce/riscv/freedom-u-sdk/riscv-pk/softfloat -I/home/bruce/riscv/freedom-u-sdk/riscv-pk/dummy_payload -I/home/bruce/riscv/freedom-u-sdk/riscv-pk/machine -I/home/bruce/riscv/freedom-u-sdk/riscv-pk/util -c /home/bruce/riscv/freedom-u-sdk/riscv-pk/pk/file.c
gcc: error: unrecognized argument in option ‘-mcmodel=medany’
gcc: note: valid arguments to ‘-mcmodel=’ are: 32 kernel large medium small; did you mean ‘medium’?
gcc: error: unrecognized argument in option ‘-mabi=lp64d’
gcc: note: valid arguments to ‘-mabi=’ are: ms sysv
I see some errors further back.
make: *** No rule to make target ‘/home/bruce/riscv/install/bin/riscv64-sifive-linux-gnu-gcc’, needed by ‘/home/bruce/riscv/freedom-u-sdk/work/linux/vmlinux’. Stop.
make: *** Waiting for unfinished jobs…
I’m doing this build in (as you can see) /home/bruce/riscv/freedom-u-sdk so maybe it’s getting confused by me having an environment variable from my .bashrc $RISCV=/home/bruce/riscv/install ?? That directory is also in my PATH.
I did “unset RISCV” and then make was able to complete successfully, and “make qemu” puts me at a RISC-V Linux login prompt and root/sifive gets me in.
Setting RISCV is something that some of the embedded packages support, but linux packages generally don’t support this. I don’t have RISCV set. Still, setting RISCV shouldn’t break the package this way. Someone want to submit a pull request or issue against the github freedom-u-sdk tree?