#STEP1: Install requirements. ## Assumes a clean Ubuntu 20.04 host OS sudo apt-get install debian-ports-archive-keyring sudo apt-get update sudo apt-get install gcc-riscv64-linux-gnu qemu-system-misc opensbi qemu-user-static binfmt-support debootstrap libguestfs-tools wget http://za.archive.ubuntu.com/ubuntu/pool/universe/u/u-boot/u-boot-qemu_2020.04+dfsg-2ubuntu1_all.deb sudo dpkg -i u-boot-qemu_2020.04+dfsg-2ubuntu1_all.deb #STEP2: Create a RISC-V filesystem using chroot ## Basically a space on your local HD that looks like an install of linux with all the libraraies and executables you expect to see from / availble from a designated folder. Provides the ability to have an alternative filesystem accessible from within a host filesystem sudo debootstrap --arch=riscv64 --keyring /usr/share/keyrings/debian-ports-archive-keyring.gpg --include=debian-ports-archive-keyring unstable /tmp/riscv64-chroot http://deb.debian.org/debian-ports #STEP3: Configure this new file system by 'logging in' and running some commands sudo chroot /tmp/riscv64-chroot ## Update chroot FS apt-get update ## Configure a 'network' cat >>/etc/network/interfaces <>/etc/default/u-boot < int main() { printf("Hello, World!\n"); return 0; } ****************** riscv64-linux-gnu-gcc -o mainRV main.c scp -P 22222 mainRV yourname@localhost: ## Login to the emulator and run the code: ./mainRV ------------------ #LASTLY Some general notes: - To Exit QEMU and shutdown the emulation: Ctrl-A x - The way this has been done means you have access to a limited repo from debian of packages that have already been compiled and ported to RISC-V - You can search this repo using apt eg: $ apt-cache search keyword (Or easier - install aptitude and search with it if you're familiar with it) See here for docs on Debian port: https://wiki.debian.org/RISC-V