Skip to content

Instantly share code, notes, and snippets.

@cconstab
Last active August 8, 2022 15:14
Show Gist options
  • Save cconstab/e63ffc14f50aae0279b5dc30d9033cad to your computer and use it in GitHub Desktop.
Save cconstab/e63ffc14f50aae0279b5dc30d9033cad to your computer and use it in GitHub Desktop.
Get Qemu
https://www.qemu.org/download/
Get ubuntu for risc v5 - I choose ubuntu-20.04.4-preinstalled-server-riscv64+unmatched.img
https://wiki.ubuntu.com/RISC-V
Uncompress with xz and give yourself some more space - I did this using a WSL 2 ubuntu shell as it was easier to use the tools from linux
xz -dk ubuntu-20.04.4-preinstalled-server-riscv64+unmatched.img.xz
qemu-img resize -f raw ubuntu-20.04.4-preinstalled-server-riscv64+unmatched.img + 25G
Now you need some firmware and a kernel for risc V which can be downloaded from here
https://github.com/riscv-software-src/opensbi
Download the latest opensbi release and grab the files you need
cp opensbi-1.0-rv-bin/share/opensbi/lp64/generic/firmware/fw_jump.elf fw_jump.elf
Download a uboot deb so you can pull out uboot.elf
http://ftp.us.debian.org/debian/pool/main/u/u-boot/
u-boot-qemu_2022.04+dfsg-2_all.deb - is what I choose
expand it
ar -x u-boot-qemu_2022.04+dfsg-2_all.deb
xz -dk data.tar.xz
tar xvf data.tar
cp usr/lib/u-boot/qemu-riscv64_smode/uboot.elf uboot.elf
OK ready to roll
qemu-system-riscv64 -machine virt -m 4096 -smp 4 -bios fw_jump.elf -kernel uboot.elf -device virtio-net-device,netdev=eth0 -netdev user,id=eth0 -drive file=ubuntu-20.04.4-preinstalled-server-riscv64+unmatched.img,format=raw,if=virtio -cpu rv64
username ubuntu
password ubuntu
@theo-lemurian
Copy link

@cconstab the world has changed since you wrote this gist, and the uboot.elf step is orphaned. Where, in general, would the risc-v uboot.elf file be released into?

The files that are left in the FTP site are:
[ ] u-boot_2022.04+dfsg-2+b1_armel.deb 2022-05-15 00:11 549K
[ ] u-boot_2022.04+dfsg-2+b1_armhf.deb 2022-05-14 22:45 31K
[ ] u-boot_2022.04+dfsg-2.debian.tar.xz 2022-04-11 02:02 46K
[TXT] u-boot_2022.04+dfsg-2.dsc 2022-04-11 02:02 2.9K
[ ] u-boot_2022.04+dfsg.orig.tar.xz 2022-04-05 18:31 14M

and none of them contain a riscv uboot.elf file.

Trying to learn how to fish, so if you have the insight how these files are released, love to learn.

@theo-lemurian
Copy link

Looks like the FTP site does not maintain the RISC-V builds:

[ ] u-boot-tools_2022.04+dfsg-2+b1_amd64.deb 2022-05-14 20:13 202K
[ ] u-boot-tools_2022.04+dfsg-2+b1_arm64.deb 2022-05-14 20:13 190K
[ ] u-boot-tools_2022.04+dfsg-2+b1_armel.deb 2022-05-15 00:11 175K
[ ] u-boot-tools_2022.04+dfsg-2+b1_armhf.deb 2022-05-14 22:45 176K
[ ] u-boot-tools_2022.04+dfsg-2+b1_i386.deb 2022-05-14 22:44 206K
[ ] u-boot-tools_2022.04+dfsg-2+b1_mips64el.deb 2022-05-15 03:56 191K
[ ] u-boot-tools_2022.04+dfsg-2+b1_mipsel.deb 2022-05-15 06:02 195K
[ ] u-boot-tools_2022.04+dfsg-2+b1_ppc64el.deb 2022-05-14 21:29 218K
[ ] u-boot-tools_2022.04+dfsg-2+b1_s390x.deb 2022-05-15 04:26 189K

no RISC-V target.

@theo-lemurian
Copy link

has it percolated up to 'official' status?

https://packages.debian.org/sid/u-boot-qemu

Package: u-boot-qemu (2022.04+dfsg-2)

A boot loader for qemu
Das U-Boot is a cross-platform bootloader for embedded systems, used as the default boot loader by several board vendors. It is intended to be easy to port and to debug, and runs on many supported architectures, including PPC, ARM, MIPS, x86, m68k, NIOS, and Microblaze.

This package includes boot loaders for qemu/kvm.

Included platforms: qemu-ppce500 qemu-riscv64 qemu-riscv64_smode qemu-x86 qemu-x86_64 qemu_arm qemu_arm64

@theo-lemurian
Copy link

@cconstab
Copy link
Author

cconstab commented Aug 8, 2022

Theo, sorry for being so tardy getting back to you..., I will have a re run through the Gist and update with answers this week... Been very busy with one of my other projects at https://github.com/atsign-foundation

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