Extension `zicsr' required

408 views
Skip to first unread message

Aditya Ranjan

unread,
Dec 20, 2023, 2:39:11 AM12/20/23
to RISC-V SW Dev
Have to build "https://buildbot.embecosm.com/job/riscv32-gcc-ubuntu2204-release/10/artifact/riscv32-embecosm-ubuntu2204-gcc13.2.0.tar.gz" and for this need to build riscv-pk "https://github.com/riscv-software-src/riscv-pk.git" and riscv-isa-sim(spike) "https://github.com/riscv-software-src/riscv-isa-sim.git"

After extracting the .tar.gz file and putting the prefix path to extracted bin started building riscv-pk and did configure "../configure --prefix=$RISCV --host=riscv32-unknown-elf --with-arch=rv32i".
make build got this error "riscv32-unknown-elf-gcc -MMD -MP -Wall -Werror -D__NO_INLINE__ -mcmodel=medany -O2 -std=gnu99 -Wno-unused -Wno-attributes -fno-delete-null-pointer-checks -fno-PIE  -march=rv32i -mabi=ilp32 -DBBL_LOGO_FILE=\"bbl_logo_file\" -DMEM_START=0x80000000 -fno-stack-protector -U_FORTIFY_SOURCE -DBBL_PAYLOAD=\"bbl_payload\" -I. -I../pk -I../bbl -I../softfloat -I../dummy_payload -I../machine -I../util -c ../pk/file.c riscv32-unknown-elf-gcc -MMD -MP -Wall -Werror -D__NO_INLINE__ -mcmodel=medany -O2 -std=gnu99 -Wno-unused -Wno-attributes -fno-delete-null-pointer-checks -fno-PIE  -march=rv32i -mabi=ilp32 -DBBL_LOGO_FILE=\"bbl_logo_file\" -DMEM_START=0x80000000 -fno-stack-protector -U_FORTIFY_SOURCE -DBBL_PAYLOAD=\"bbl_payload\" -I. -I../pk -I../bbl -I../softfloat -I../dummy_payload -I../machine -I../util -c ../pk/syscall.c ../pk/pk.h: Assembler messages: ../pk/pk.h:59: Error: unrecognized opcode `csrr a5,timeh', extension `zicsr' required ../pk/pk.h:60: Error: unrecognized opcode `csrr a3,time', extension `zicsr' required ../pk/pk.h:61: Error: unrecognized opcode `csrr a4,timeh', extension `zicsr' required ../pk/pk.h:75: Error: unrecognized opcode `csrr a5,cycleh', extension `zicsr' required ../pk/pk.h:76: Error: unrecognized opcode `csrr a1,cycle', extension `zicsr' required ../pk/pk.h:77: Error: unrecognized opcode `csrr a4,cycleh', extension `zicsr' required ../pk/pk.h:91: Error: unrecognized opcode `csrr a5,instreth', extension `zicsr' required ../pk/pk.h:92: Error: unrecognized opcode `csrr a1,instret', extension `zicsr' required ../pk/pk.h:93: Error: unrecognized opcode `csrr a4,instreth', extension `zicsr' required ../pk/pk.h:75: Error: unrecognized opcode `csrr a1,cycleh', extension `zicsr' required ../pk/pk.h:76: Error: unrecognized opcode `csrr a0,cycle', extension `zicsr' required ../pk/pk.h:77: Error: unrecognized opcode `csrr a5,cycleh', extension `zicsr' required ../pk/pk.h:75: Error: unrecognized opcode `csrr a1,cycleh', extension `zicsr' required ../pk/pk.h:76: Error: unrecognized opcode `csrr a0,cycle', extension `zicsr' required ../pk/pk.h:77: Error: unrecognized opcode `csrr a5,cycleh', extension `zicsr' required ../pk/pk.h:75: Error: unrecognized opcode `csrr s0,cycleh', extension `zicsr' required ../pk/pk.h:76: Error: unrecognized opcode `csrr s1,cycle', extension `zicsr' required ../pk/pk.h:77: Error: unrecognized opcode `csrr a5,cycleh', extension `zicsr' required ../pk/pk.h:75: Error: unrecognized opcode `csrr s0,cycleh', extension `zicsr' required ../pk/pk.h:76: Error: unrecognized opcode `csrr s1,cycle', extension `zicsr' required ../pk/pk.h:77: Error: unrecognized opcode `csrr a5,cycleh', extension `zicsr' required make: *** [Makefile:336: syscall.o] Error 1"

Any suggestion what can be done.

Thanks
Aditya

Tommy Murphy

unread,
Dec 20, 2023, 4:06:37 AM12/20/23
to Aditya Ranjan, RISC-V SW Dev
You need to build your toolchain with support for the `Zicsr` extension which was previously part of the base `I` integer ISA but was subsequently split out into a separate extension.

You should probably also explicitly specify the default ABI.

```
make distclean
rm -rf $RISCV
../configure --prefix=$RISCV --host=riscv32-unknown-elf --with-arch=rv32i_zicsr --with-abi=ilp32
make
```

See here and several other closed issues logged against the riscv-gnu-toolchain for discussion about this issue which crops up again and again...



Aditya Ranjan

unread,
Dec 20, 2023, 4:29:48 AM12/20/23
to RISC-V SW Dev, tommy_...@hotmail.com, Aditya Ranjan
if we don't want to build it for any "zicsr" ABI or arch

Tommy Murphy

unread,
Dec 20, 2023, 4:57:35 AM12/20/23
to Aditya Ranjan, RISC-V SW Dev, Aditya Ranjan
Then you need to ensure that the code that you're compiling doesn't use CSR read/write instructions. I would've thought that that was self-evident?

Tommy Murphy

unread,
Dec 20, 2023, 5:16:05 AM12/20/23
to Aditya Ranjan, RISC-V SW Dev, Aditya Ranjan
In particular, if you want to use the riscv-pk on an rv32i/ilp32 target then you'll have to modify its choice not to use CSR instructions. I don't know how feasible this would be as I suspect that it fundamentally depends on certain CSRs to work.
Reply all
Reply to author
Forward
0 new messages