Port-RISCV archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: build sophgo fsbl failed with cross-riscv64-none-elf-gcc



On Sat, Nov 16, 2024 at 05:46:07PM +0800, Rui-Xiang Guo wrote:
> Hi,
> I am trying to build https://github.com/sophgo/fsbl/tree/v4.1.6
> with cross-riscv64-none-elf-gcc-13.2.0nb1 but get the assembler error:
> 
> [...]gcc[...] -march=rv64imafdcvxthead [...] lib/cpu/riscv/cpu_helper.c -o build/cv180x/bl2/cpu_helper.o
> Assembler messages:
> Error: x ISA extension `xthead' must be set with the versions
> /tmp//ccx4Pltw.s:3: Error: x ISA extension `xthead' must be set with the versions
> lib/cpu/riscv/cpu_helper.c:13: Error: unrecognized opcode `icache.iall'
> lib/cpu/riscv/cpu_helper.c:14: Error: unrecognized opcode `sync.i'
> gmake: *** [Makefile:199: build/cv180x/bl2/cpu_helper.o] Error 1
> *** Error code 2
> 
> Does the cross-riscv64-none-elf-gcc package need to be pached or upgraded?

The problem is that icache.iall and sync.i are vendor-specific extensions,
and gcc has changed how it handles them in between versions; furthermore,
sophgo's build process downloads its own custom toolchain that uses gcc 10.2
(and probably a modified one at that). lib/cpu/riscv/cpu.mk specifies
-march=rv64imafdcvxthead - which isn't legal in later versions of gcc; it
should *probably* be -march=rv64imafdcvxtheadsync, but that's still not
enough to get gcc/gas to emit the instructions, and it still complains
about unknown (vendor-specific) CSRs later on (mxstatus, mcor, mhcr).

The generated code itself is pretty straightforward:
0000000000000000 <sync_cache>:
   0:   0100000b                icache.iall
   4:   01a0000b                sync.i
   8:   8082                    ret

as is the custom CSR stuff:
  cc:   7c019073                csrw    mxstatus,gp
  e4:   7c21b073                csrc    mcor,gp
  ec:   7c21a073                csrs    mcor,gp
  f4:   7c11a073                csrs    mhcr,gp
  fc:   7c21b073                csrc    mcor,gp
 104:   7c21a073                csrs    mcor,gp
 10c:   7c11a073                csrs    mhcr,gp

but I don't think it'll be an easy task to get the standard tools as-is
to build fsbl; I'd suggest asking sophgo/milk how to rebuild fsbl using
gcc 13, or asking around on the sophgo/milk forums what the patches to
their gcc are. (or if you want *real* giggles, ask sophgo/sophon for the
patches to their gcc)

tl;dr: they use their own modified gcc toolchain with incompatible 
options and instructions and CSRs that aren't even present in mainline
gcc



Home | Main Index | Thread Index | Old Index