agra-uni-bremen/riscv-vp

Support for linux

Closed this issue · 12 comments

Hi,
I have build the toolchain for RISC V 32 and 64 bits for NewLib and Linux options one by one. I have four combinations of the toolchains. I tried to compile and run the "c++lib" with each of the toolchain, all can compile without any errors. But when I try to run the binary, there is a problem with Linux variant. (RV64GC toolchain is build with multilib option so they support both 64 and 32 bit.)

Below is the Makefile I modified for building this project. Before building for each of the variant, clean will be performed.

riscv32 : main.cpp
	riscv32-unknown-elf-g++ -std=c++14 main.cpp -o main -march=rv32imac -mabi=ilp32
	
riscv32_linux : main.cpp
	riscv32-unknown-linux-gnu-g++ -std=c++14 main.cpp -o main -march=rv32imac -mabi=ilp32	

riscv64 : main.cpp
	riscv64-unknown-elf-g++ -std=c++14 main.cpp -o main -march=rv32imac -mabi=ilp32	

riscv64_linux : main.cpp
	riscv64-unknown-linux-gnu-g++ -std=c++14 main.cpp -o main -march=rv32imac -mabi=ilp32			
sim:
	riscv-vp --intercept-syscalls --error-on-zero-traphandler=true main
	
clean:
	rm -f main

Error on running the make sim for the linux variants (both 32 and 64 bit) is below

riscv-vp --intercept-syscalls --error-on-zero-traphandler=true main

        SystemC 2.3.3-Accellera --- Dec 21 2022 19:31:25
        Copyright (c) 1996-2018 by all Contributors,
        ALL RIGHTS RESERVED

Error: (E549) uncaught exception: [ISS] Took null trap handler in machine mode
In file: ../../../src/sysc/kernel/sc_except.cpp:101
In process: run0 @ 700 ns
make: *** [Makefile:13: sim] Error 1

Same problem is for the sw/simple-display also.

While the sw/basic-c application builds and runs find with any of the four compilers.

RV64GC toolchain is build with multilib option so they support both 64 and 32 bit.

Please note that any RISC-V toolchain supports code generation for 32 and 64 bit targets and all ratified extensions.
A multilib toolchain simply adds certain standard C/C++ libraries, startup crt0 etc. for specific arch/abi targets.

What are you trying to do?
The linux targets are for building the actual programs that run on Linux OS, meaning you would first need to build a riscv-linux vmlinuz executable. We currently support hifive-unleashed-compatible targets (linux-vp).
All of the simple examples in sw/ are bare-metal examples that run on a virtual syscall interface, without any OS for simplicity.

What are you trying to do? The linux targets are for building the actual programs that run on Linux OS, meaning you would first need to build a riscv-linux vmlinuz executable. We currently support hifive-unleashed-compatible targets (linux-vp). All of the simple examples in sw/ are bare-metal examples that run on a virtual syscall interface, without any OS for simplicity.

Yes, my goal is to boot linux OS and putting the cross-compiled applications in the mounted file system and running them. As you mentioned, I also thought, to get these applications (compiled with linux toolchains ) running I need to have them on the linux OS booted with riscv-vp. But when the linux cross compiled sw/basic-c, could work directly, I got bit confused.

I am bit confused as to whether using this RISCV-VP, can I just run the Linux image built for RISCV? Or should I go through any bootloader. Could you provide some insight into this or point me to any links that I can refer to.
Thanks.

Any use?

Any use?

Thank you. Yes indeed this would be useful. I looked at the open issues in this repo but not the closed one :( . I will go through it and try it out, update my findings here. Thanks again.

Any use?

Thank you. Yes indeed this would be useful. I looked at the open issues in this repo but not the closed one :( . I will go through it and try it out, update my findings here. Thanks again.

I tried the suggestion as in #21 (comment) and could see it working.

Is the difference between risc-vp and linux-vp only related to bare metal and linux variant?

Any use?

Thank you. Yes indeed this would be useful. I looked at the open issues in this repo but not the closed one :( . I will go through it and try it out, update my findings here. Thanks again.

I tried the suggestion as in #21 (comment) and could see it working.

Is the difference between risc-vp and linux-vp only related to bare metal and linux variant?

Looks like different vp's are built depending on the use case?
E.g.

As TommyMurpy1234 said, these are different configurations (i.e. Memory Maps, supported Instructions, number of cores, peripherals, ...).
The linux-vp has a configuration to act like the SiFive Unleashed Board, for which different linux distributions have had experimental support.

If this answers your question, please close the issue accordingly.

As TommyMurpy1234 said, these are different configurations (i.e. Memory Maps, supported Instructions, number of cores, peripherals, ...). The linux-vp has a configuration to act like the SiFive Unleashed Board, for which different linux distributions have had experimental support.

Thanks for your answer.
@nmeum
As per your comment #21 (comment), would it be possible to let me know the git commit id of the buildroot repo, any modifications done on top that and the defconfig used to generate linux64-mc-slip.tar.gz?

I could successfully built the latest buildroot choosing the closely matching "qemu_riscv64_virt_defconfig" defconfig file. My output/Images consist of below files.
image

I am not sure whether you used tools to generate the files listed from your tar ball listed below.
image

My end target is to have a linux sources where I can build the images like you have done here linux64-mc-slip.tar.gz and run it using "linux-vp".

nmeum commented

I am not sure whether you used tools to generate the files listed from your tar ball listed below.

fw_payload.elf is an OpenSBI payload embedding the Kernel binary. For details, refer to the OpenSBI documentation. The linux-vp-dts-mc.{txt,bin} files are Linux Device Tree files in binary and plain text form. This is a slightly modified version of the HiFive Unleashed device tree. The README.md file is a README in Markdown format.

As stated in #21, linux-vp is currently not the focus of our work. Using it with recent Linux/Buildroot versions will probably require some tinkering. If you find bugs in linux-vp please let us know but, unfortunately, we don't have the capacity to provide any high-level support.

I am not sure whether you used tools to generate the files listed from your tar ball listed below.

fw_payload.elf is an OpenSBI payload embedding the Kernel binary. For details, refer to the OpenSBI documentation. The linux-vp-dts-mc.{txt,bin} files are Linux Device Tree files in binary and plain text form. This is a slightly modified version of the HiFive Unleashed device tree. The README.md file is a README in Markdown format.

As stated in #21, linux-vp is currently not the focus of our work. Using it with recent Linux/Buildroot versions will probably require some tinkering. If you find bugs in linux-vp please let us know but, unfortunately, we don't have the capacity to provide any high-level support.

Thank you very much for your reply. I will continue to work on this.