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

Can't compile the baremetal example #8

Open
Buanderie opened this issue Dec 6, 2022 · 5 comments
Open

Can't compile the baremetal example #8

Buanderie opened this issue Dec 6, 2022 · 5 comments

Comments

@Buanderie
Copy link

Hi. Nice work there, by the way...
But I can't compile the baremetal test. I'm using the buildroot toolchain. Maybe I should use another one ?
I get this:
make testbare make -C baremetal make[1]: Entering directory '/opt/sandbox/mini-rv32ima/baremetal' ../buildroot/output/host/bin/riscv32-buildroot-linux-uclibc-gcc -o baremetal.elf baremetal.c baremetal.S -fno-stack-protector -static-libgcc -fdata-sections -ffunction-sections -g -Os -march=rv32ima -mabi=ilp32 -static -T flatfile.lds -nostdlib -Wl,--gc-sections baremetal.c: Assembler messages: baremetal.c:16: Error: unrecognized opcode csrrw x0,0x138,s1'
baremetal.c:16: Error: unrecognized opcode csrrw x0,0x138,a5' baremetal.c:16: Error: unrecognized opcode csrrw x0,0x138,a5'
baremetal.c:21: Error: unrecognized opcode csrrw x0,0x137,a5' baremetal.c:16: Error: unrecognized opcode csrrw x0,0x138,a5'
baremetal.c:16: Error: unrecognized opcode csrrw x0,0x138,s1' baremetal.c:31: Error: unrecognized opcode csrr a1,0xC00'
baremetal.c:31: Error: unrecognized opcode csrr a5,0xC00' baremetal.c:16: Error: unrecognized opcode csrrw x0,0x138,a4'
baremetal.c:26: Error: unrecognized opcode csrrw x0,0x136,a5' baremetal.c:16: Error: unrecognized opcode csrrw x0,0x138,a5'
baremetal.c:16: Error: unrecognized opcode csrrw x0,0x138,s0' baremetal.S: Assembler messages: baremetal.S:28: Error: unrecognized opcode csrw 0x138,t0'
Makefile:16: recipe for target 'baremetal.elf' failed
make[1]: *** [baremetal.elf] Error 1
make[1]: Leaving directory '/opt/sandbox/mini-rv32ima/baremetal'
Makefile:25: recipe for target 'testbare' failed
make: *** [testbare] Error 2`

@Buanderie
Copy link
Author

Buanderie commented Dec 6, 2022

Alright, figured it out.
Following this

I replaced CFLAGS+=-g -Os -march=rv32ima -mabi=ilp32 -static with CFLAGS+=-g -Os -march=rv32ima_zicsr -mabi=ilp32 -static

And it works now :)

@cnlohr
Copy link
Owner

cnlohr commented Dec 6, 2022

Hmm... I wrote it to use the system rv64 compiler, so you wouldn't need to build the toolchain to compile the example.

That said, that's probably not the best way to do it, now that it's possible to use the buildroot environment in Windows.

I am curious what other people's feelings are. (reopening issue, in case anyone else wants to comment)

@cnlohr cnlohr reopened this Dec 6, 2022
@sellicott
Copy link
Contributor

sellicott commented Dec 7, 2022

What compiler are each of you using?
I ran into this issue when building the riscv-pk tool the other day riscv-pk 287. Apparently it's an issue in the newer versions of gcc. Also be aware that it doesn't seem like binutils has caught up with this change, so the linker doesn't accept the _zicsr isa option.

@Buanderie
Copy link
Author

riscv32-buildroot-linux-uclibc-gcc.br_real (Buildroot -gfc2ef6e2) 12.2.0 Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

@cnlohr
Copy link
Owner

cnlohr commented Dec 8, 2022

I use riscv64-unknown-elf-gcc 9.3.0 I think it makes sense to remove zicsr from the line. If anyone's up for making a PR.

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