QEMU is a free and open-source emulator and virtualizer that can perform hardware virtualization. It is capable of emulating a complete machine in software without any need for hardware virtualization support. It is a type 2 hypervisor that runs within user space and performs virtual hardware emulation. QEMU as a whole is released under the GNU General Public License, version 2. It is multi-platform software intended to be buildable on all modern Linux platforms, OS-X, Win32 (via the Mingw64 toolchain), and a variety of other UNIX targets.
Step 1: Building QEMU for SHAKTI
Firstly, clone the repository. Then proceed to create a directory called
git clone https://gitlab.com/shaktiproject/software/qemu.git cd qemu git checkout shakti/c-class mkdir build cd build ../configure --target-list="riscv32-softmmu riscv64-softmmu" make
Then add this line to bashrc,
Step 2: Check if the installation is successful
qemu-system-riscv64 -M help
This command displays the available machines that qemu can simulate,
shakti_c is what we require.
Step 3: Compile a UART Application and run it on Qemu
shakti-sdk is installed, we are going to run the
hello (software/examples/uart_applns/hello)on qemu.
Also, we need to disable
QEMU to work. So goto
shakti-sdk/bsp/core/start.S and make sure PLIC is cleared (comment or delete the following lines).
Then proceed to compile the program,
make software TARGET=vajra PROGRAM=hello
After compiling, run the
uart example using the following command,
qemu-system-riscv64 -M shakti_c -nographic -bios path/to/shakti-sdk/software/examples/uart_applns/hello/output/hello.shakti
qemu-system-riscv64 -M shakti_c -nographic -bios ~/Music/shakti-sdk/software/examples/uart_applns/hello/output/hello.shakti
Step 4.1: Build the OpenSBI test payload for QEMU
Firstly, clone the OpenSBI directory and then proceed to build the payload.
cd opensbi wget -c https://gitlab.com/behindbytes/shakti-binaries/-/raw/master/dts/shakti.dtb export CROSS_COMPILE=riscv64-unknown-elf- export FW_FDT_PATH=./shakti.dtb make PLATFORM=generic
Step 4.2: Run the test payload on QEMU
qemu-system-riscv64 -M shakti_c -nographic -bios path/to/fw_payload.elf
Akshaya currently works at the RISE labs. Her favorite subjects are Web designing and Microprocessors. She loves learning about new things and writing about them!