Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: unrecognized opcode csrw #1053

Closed
kuoyaoming93 opened this issue Apr 11, 2022 · 5 comments
Closed

Error: unrecognized opcode csrw #1053

kuoyaoming93 opened this issue Apr 11, 2022 · 5 comments

Comments

@kuoyaoming93
Copy link

kuoyaoming93 commented Apr 11, 2022

Hi all,

I am trying to install the RISC-V GNU toolchain in order to compile for WD SweRV-EL2 core.

I followed the guidelines to install the toolchain (2022.03.25 version), opting for the multilib option.

# Clone the repository
git clone https://github.com/riscv/riscv-gnu-toolchain --recursive
cd riscv-gnu-toolchain/

# Checkout 2022.03.25 version
git checkout 2022.03.25

# Configure as multilib and make
./configure --prefix=/opt/riscv --enable-multilib
make

After that, when I execute the following command to see the supported archs:

riscv64-unknown-elf-gcc --print-multi-lib

.;
rv32i/ilp32;@march=rv32i@mabi=ilp32
rv32im/ilp32;@march=rv32im@mabi=ilp32
rv32iac/ilp32;@march=rv32iac@mabi=ilp32
rv32imac/ilp32;@march=rv32imac@mabi=ilp32
rv32imafc/ilp32f;@march=rv32imafc@mabi=ilp32f
rv64imac/lp64;@march=rv64imac@mabi=lp64

Then, I cloned the SweRV-EL2 RISC-V core, and try to run the hello_world simulation, the following error appeared when I build hello_world.o:

Captura de pantalla de 2022-04-11 16-22-17

Did I forget something in the configuration stage?

Thank you in advance!

@jim-wilson
Copy link
Collaborator

In the old ISA spec, the csr instructions are part of the base I instruction set. In the new ISA spec, the csr instructions are part of the zicsr extension. If -march=rv32imac doesn't work, then try -march=rv32imac_zicsr. Old toolchains won't accept zicsr though as it is new. So you may need to experiment to see what options your version of the assembler needs.

You can get the assembler version by running "riscv64-unknown-elf-as --version".

Worst case, you might need different arch options for gcc and gas if you have mismatched versions of them.

@kito-cheng
Copy link
Collaborator

We using GCC 11 and binutils 2.38 for riscv-gnu-toolchain, and they are using different default ISA spec version.

I guess I should add an option for riscv-gnu-toolchain script to set the default ISA spec version :(

@jim-wilson
Copy link
Collaborator

Then I would suggest using a version of riscv-gnu-toolchain from before this change was made.

@kuoyaoming93
Copy link
Author

Thank you for the quick reply @jim-wilson @kito-cheng. I will report this to WD.

@jim-wilson
Copy link
Collaborator

Kito merged in a patch to fix this, so the top of the riscv-gnu-toolchain git tree should handle this correctly now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants