Anyone succeeds to build kernel on VF2?


When I tried to build kernel from source(JH7110_VisionFive2_devel branch) on my VF2 (using stock Debian image), it failed with the following errors:

$ make ARCH=riscv -j4
  CC      arch/riscv/kernel/asm-offsets.s                                                                         
  CALL    scripts/                                                                                
  CALL    scripts/atomic/                                                                         
  LDS     arch/riscv/kernel/vdso/                                                                         
  AS      arch/riscv/kernel/vdso/rt_sigreturn.o                                                                   
  CC      arch/riscv/kernel/vdso/vgettimeofday.o                                                                  
./arch/riscv/include/asm/vdso/gettimeofday.h: Assembler messages:                                                 
./arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unrecognized opcode `csrr a5,0xc01', extension `zicsr' req
./arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unrecognized opcode `csrr a5,0xc01', extension `zicsr' req
make[1]: *** [scripts/ arch/riscv/kernel/vdso/vgettimeofday.o] Error 1
make: *** [arch/riscv/Makefile:114: vdso_prepare] Error 2 

Maybe it’s due to something related to binutils?

@darkgeek this is set of tools is painless to use. I’m grateful it exists. Check it out. You can build the kernel easily with this using either docker or podman.

1 Like

hello @darkgeek,

when you build directly on VF2 then you dont need the parameter ‘ARCH=riscv’
here an fix for you issue:

riscv-march-$(CONFIG_RISCV_ISA_C)       := $(riscv-march-y)c
# Newer binutils versions default to ISA spec version 20191213 which moves some
# instructions from the I extension to the Zicsr and Zifencei extensions.
+ toolchain-need-zicsr-zifencei := $(call cc-option-yn, -march=$(riscv-march-y)_zicsr_zifencei)
+ riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei

It worked, thanks!

Same goes for u-boot, btw. I patched:

index 0b80eb8d86..7814d02bbd 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -24,7 +24,7 @@ ifeq ($(CONFIG_CMODEL_MEDANY),y)
        CMODEL = medany

-ARCH_FLAGS = -march=$(ARCH_BASE)$(ARCH_A)$(ARCH_C) -mabi=$(ABI) \
+ARCH_FLAGS = -march=$(ARCH_BASE)$(ARCH_A)$(ARCH_C)_zicsr_zifencei -mabi=$(ABI) \


How long does it take to self-compile?

I had slightly over 35 minutes running on nvme. I used ‘make -j8’ to involve all cpus.

One can make the compilation (much?) faster if one actually configures the kernel to build not every possible driver as it is done right now.

Hmm, just to (very unscientifically) compare the speed with my regular work station (i7-7700T CPU @ 2.90GHz), compiling yet another default configured kernel takes about 5 minutes. This matches my impression, that the VF2 is about 6 times slower, as soon as one starts to measure its raw perfomance.

When running VF2 with a nvme, the speed difference is not really noticeable in most tasks, though, imo. It all feels pretty normal and snappy. Not so, when running on mmc.

1 Like