agra-uni-bremen / riscv-vp

RISC-V Virtual Prototype
MIT License
139 stars 49 forks source link

Booting Linux #21

Closed wangliwei-intel closed 2 years ago

wangliwei-intel commented 2 years ago

Is it capable of booting linux right now? thanks.

nmeum commented 2 years ago

Yes, we successfully booted Linux using linux-vp (which models a HiFive Unleashed) in the past:

https://user-images.githubusercontent.com/2326560/156125883-c4534d1f-3fd1-450a-a340-197f7fd97c74.mp4

However, we experiment more with embedded operating systems like Zephyr and RIOT in our own work at the moment. For this reason, depending on your Linux image and your Kernel config, you might run into some minor issues here and there when attempting to boot Linux using linux-vp.

If you have any specific questions regarding linux-vp let us know.

Cirromulus commented 2 years ago

If this answered your question, please close this Issue.

wangliwei-intel commented 2 years ago

@Cirromulus Sorry, I reopen this issue. The riscv-toolchain described in README is a Newlib cross-compiler, so I think that process is for bare-metal or RTOS mode. As you said, I'm interested in linux-vp, Is there any document showing me how to do that?

B. R. Liwei

Cirromulus commented 2 years ago

Yes, the toolchain mentioned in the Readme is for embedded / bare-metal applications (FE320). The linux-vp is compatible to the Sifive Unmatched (FU540), so if you follow tutorials to building linux for that, this will help. You will have to build an ELF file with integrated rootfs which you can boot. You can then use this file together with the DTB to run on the linux-vp. @nmeum might have a more detailed build process.

wangliwei-intel commented 2 years ago

@Cirromulus Thank you. The system bus is TLM bus, is it possible to replace it with CHI or AXI model?

Cirromulus commented 2 years ago

I get the impression that you did not understand what TLM stands for. This VP is a loosely-timed SystemC TLM model. The actual bus protocol is irrelevant.

wangliwei-intel commented 2 years ago

Hi, @nmeum I followed Freedom-U-SDK to build the kernel image and rootfs for U540. Everything looks good, I end up with those files: image

Then I ran the command: linux-vp --use-data-dmi --tlm-global-quantum=1000 --dtb-file=hifive-unleashed-a00-microsemi.dtb fw_payload.elf

I got this error: linux-vp: /MyHostHome/Desktop/DockerHome/SystemC-HOME/riscv-vp-rv64/vp/src/platform/common/memory.h:49: void SimpleMemory::write_data(unsigned int, const uint8_t*, unsigned int): Assertion `addr + num_bytes <= size' failed. Aborted (core dumped)

I know I missed something, e.g. specify the kernel image and rootfs. I also need to build something specific for linux-vp. Could you please tell me how?

B. R. Liwei

nmeum commented 2 years ago

I actually used buildroot instead of the Freedom-U-SDK in the past. Attached is an older image I generated a few years ago which should boot with current linux-vp (see README.md in the attached tarball). As I mentioned in the earlier comment, we are currently not actively working with Linux, hence you might run into bugs with newer Linux versions or different configurations. If your employer is interested in improving linux-vp feel free to reach out to us via email at riscv@informatik.uni-bremen.de.

Attachments:

wangliwei-intel commented 2 years ago

@nmeum Thank you very much.