starfive-tech / VisionFive2

445 stars 79 forks source link

When compile u-boot with GCC 12.2.0 toolchain, arch/riscv/Makefile needs to be updated. #17

Open sharpbladepan opened 1 year ago

sharpbladepan commented 1 year ago

I got u-boot source code from here: https://github.com/starfive-tech/u-boot/releases/tag/VF2_v2.5.0

[u-boot-VF2_v2.5.0]$ riscv64-linux-gnu-gcc --version
riscv64-linux-gnu-gcc (GCC) 12.2.0

When I use this version of toolchain to compile u-boot, got compiling error:

arch/riscv/cpu/cpu.c: Assembler messages:
arch/riscv/cpu/cpu.c:96: Error: unrecognized opcode `csrs sstatus,a5', extension `zicsr' required
arch/riscv/cpu/cpu.c:97: Error: unrecognized opcode `csrw 0x003,0', extension `zicsr' required
make[1]: *** [scripts/Makefile.build:254: arch/riscv/cpu/cpu.o] Error 1
make: *** [Makefile:1817: arch/riscv/cpu] Error 2

After search a while, I fetched https://github.com/u-boot/u-boot/blob/master/arch/riscv/Makefile to replace the original file in u-boot_path/arch/riscv/

And then compile without error.

dtometzki commented 1 year ago

Hello together,

the same is when you try to build the SDK kernel 5.15.0 with newer binutils then you have to add the following lines to 'arch/riscv/Makefile' '# 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

Best regards Damian

MichaelZhuxx commented 1 year ago

we will consider upgrading the gcc version of SDK since U74 has B extension that we can take advantage of