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 csrr s5,0xf14', extension zicsr' required #391

Open
phillippZZ opened this issue Jun 5, 2024 · 9 comments
Open

Comments

@phillippZZ
Copy link

Hi, everyone.

I tried to build a linux image with following commands:

$ git clone http://github.com/buildroot/buildroot
$ cd buildroot
$ make BR2_EXTERNAL=../linux-on-litex-vexriscv/buildroot/ litex_vexriscv_defconfig
$ make menuconfig (And I checked out "gcc 11.x support removed" in the legacy config options)
$ make

Then I got a lot of errors due to "ziscr":

/usr/src/buildroot/output/build/opensbi-1.3.1-linux-on-litex-vexriscv/lib/sbi/riscv_asm.c:195: Error: unrecognized opcode csrw 0x3b0+32+16+0+0+2+1,a1', extension zicsr' required

How can I solve this issue?

@Dolu1990
Copy link
Contributor

Dolu1990 commented Jun 5, 2024

@phillippZZ
Copy link
Author

It doesn't work. And I tried to add "March=rv32i_zicsr" somewhere for gcc but couldn't find a place to add it😅

@Dolu1990
Copy link
Contributor

This is related to :

Bootloader (opensbi)

BR2_TARGET_OPENSBI=y
BR2_TARGET_OPENSBI_CUSTOM_GIT=y
BR2_TARGET_OPENSBI_CUSTOM_REPO_URL="https://github.com/litex-hub/opensbi.git"
BR2_TARGET_OPENSBI_CUSTOM_REPO_VERSION="1.3.1-linux-on-litex-vexriscv"
BR2_TARGET_OPENSBI_PLAT="litex/vexriscv"
BR2_TARGET_OPENSBI_INSTALL_DYNAMIC_IMG=n

That opensbi branch seems to bo too outdated.

@trabucayre
Copy link
Contributor

@Dolu1990 this branch is used in CI with mainly one patch
I have observed gateware and buildroot MUST be coherent (RVC is enabled in config, --with-rvc must be added)

@phillippZZ
Copy link
Author

phillippZZ commented Jun 10, 2024

Sorry, I don't know what I'm supposed to do now. Do I use "https://github.com/riscv-software-src/opensbi" in "litex_vexriscv_defconfig", or keep using "https://github.com/litex-hub/opensbi.git" and follow @trabucayre 's instruction?

To enable RVC in config, I did the following:

BR2_RISCV_ISA_CUSTOM_RVC=y
BR2_RISCV_ISA_RVC=y

Did I configure it in the correct way?
And I don't know where to add "--with-rvc". Do I do it when building "riscv64-unknown-elf-gcc"? For now, I'm using "riscv64-unknown-elf-gcc-8.1.0-2019.01.0-x86_64-linux-ubuntu14" from the following flow:

$ wget https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.1.0-2019.01.0-x86_64-linux-ubuntu14.tar.gz
$ tar -xvf riscv64-unknown-elf-gcc-8.1.0-2019.01.0-x86_64-linux-ubuntu14.tar.gz
$ export PATH=$PATH:$PWD/riscv64-unknown-elf-gcc-8.1.0-2019.01.0-x86_64-linux-ubuntu14/bin/

@Dolu1990
Copy link
Contributor

Dolu1990 commented Jun 10, 2024

@trabucayre My bad, you are right ^^ the version is good.

@phillippZZ
By a happy hazard, i just hit the same issue.

I got things to compile with (didn't used RVC, i was on opensbi 1.4 on the generic platform, not the litex one, so it isn't 1 to 1 necessarly):

make   ... \
     PLATFORM_RISCV_XLEN=32 \
     PLATFORM_RISCV_ISA=rv32ima_zicsr_zifencei \
     PLATFORM_RISCV_ABI=ilp32 \
     ...

@phillippZZ
Copy link
Author

phillippZZ commented Jun 10, 2024

@Dolu1990 Thank you.

Do I download opensbi 1.4 and compile it with something like:

$ wget https://github.com/riscv-software-src/opensbi/archive/refs/tags/v1.4.zip
$ unzip v.1.4.zip
$ cd opensbi
$ make CROSS_COMPILE=riscv-none-embed- PLATFORM=generic PLATFORM_RISCV_XLEN=32 PLATFORM_RISCV_ISA=rv32ima_zicsr_zifencei PLATFORM_RISCV_ABI=ilp32

Somehow I get:

Assembler messages:
Error: cannot find default versions of the ISA extension zicsr' Error: cannot find default versions of the ISA extension zifencei'

Maybe there's something wrong with my riscv-none-embed-gcc.

Also, should I modify litex_vexriscv_defconfig as the following:

BR2_TARGET_OPENSBI=y
BR2_TARGET_OPENSBI_CUSTOM_GIT=n
BR2_TARGET_OPENSBI_CUSTOM_DIR="/path/to/local/opensbi"
BR2_TARGET_OPENSBI_PLAT="generic"
BR2_TARGET_OPENSBI_INSTALL_DYNAMIC_IMG=n

UPDATES:
Insteading of integrating my program while building the linux image, I chose not to build a new linux image and put my program into the rootf.cpio downloaded via "https://github.com/litex-hub/linux-on-litex-vexriscv/files/8331338/linux_2022_03_23.zip".
But I couldn't invoke the program by using "./program" or "source program".

After several attempts, I found that "sh XX.sh" works

@Dolu1990
Copy link
Contributor

Don't use opensbi 1.4, as i proposed, it is for when you use the generic opensbi platform, which is the same as proposed on linux-on-litex-vexriscv.

How did you made your program file ?

@phillippZZ
Copy link
Author

phillippZZ commented Jun 13, 2024

I didn't use opensbi 1.4 or build the linux image. I simply compiled a project called IsolBench with "riscv64-unknown-linux-gnu-gcc" and moved it into the rootf.cpio. Then I simulated the linux with the files downloaded from "https://github.com/litex-hub/linux-on-litex-vexriscv/files/8331338/linux_2022_03_23.zip".
Image
As you can see, some of the scripts don't work since the linux image doesn't support certain functionalities.

Could you tell me how I can solve these issues? And IsolBench can be downloaded from "https://github.com/CSL-KU/IsolBench"

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

No branches or pull requests

4 participants