Running an RISC-V OpenSBI simulation from scratch in Intel Simics on Ubuntu 24.04
From a fresh Ubuntu 24 distro install the following packages:
sudo apt install -y git build-essential wget cpio unzip rsync bc libncurses5-dev screen bison file flex libcanberra-gtk-*
Then get Buildroot sources:
git clone https://github.com/buildroot/buildroot.git
and create a new Buildroot configuration:
cd buildroot/configs
vi simics_simple_riscv_defconfig
Use these parameters from "Intel Simics Simulator 7 Documentation / TARGET GUIDES / RISC-V* Simple Board Target Guide / 3 Simulated Machines / 3.1.1 Building linux, bootloader, and root file system" (Documentation is included in Simics installation):
# Architecture
BR2_riscv=y
BR2_RISCV_64=y
# System
BR2_TARGET_GENERIC_GETTY_PORT="ttyS0"
BR2_SYSTEM_DHCP="eth0"
# Kernel
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.5.8"
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_5=y
BR2_LINUX_KERNEL_IMAGE=y
# Boot loader
BR2_TARGET_OPENSBI=y
BR2_TARGET_OPENSBI_PLAT="generic"
# Root file system
BR2_TARGET_ROOTFS_EXT2=y
# Host packages
BR2_PACKAGE_HOST_DTC=y
add the following additional params at the end of configuration:
# Boot loader fix:
# Simics want ELF at address 0x80000000
# while new SBI versions set 0x0
# (many thanks to Gustav Wiklander)
BR2_TARGET_OPENSBI_CUSTOM_VERSION=y
BR2_TARGET_OPENSBI_CUSTOM_VERSION_VALUE="1.4"
Now set the new Builroot configuration and compile the kernel:
cd ..
make simics_simple_riscv_defconfig
make -j$(nproc)
WARNING! To access the following page you need an Intel Registration Center account. Registration is free.
Go to this page
to download both
simics-7-packages-2024-41-linux64.ispm
and
领英推荐
intel-simics-package-manager-1.12.0-linux64.tar.gz
and then put them in your working directory (e.g. your home).
Now extract intel-simics-package-manager-1.12.0-linux64.tar.gz files and run the installation:
cd ~
tar -zxvf intel-simics-package-manager-1.12.0-linux64.tar.gz
./intel-simics-package-manager-1.12.0/ispm packages --install-bundle ~/simics-7-packages-2024-41-linux64.ispm --install-dir ~/simics --create-project ~/simics-projects/first
Remember:
After that, create the targets/risc-v-simple/images/linux directory inside your project:
mkdir -p simics-projects/first/targets/risc-v-simple/images/linux
and copy both fw_dynamic.elf and rootfs.ext2 from Buildroot output to that directory:
cp buildroot/output/images/fw_dynamic.elf buildroot/output/images/Image buildroot/output/images/rootfs.ext2 simics-projects/first/targets/risc-v-simple/images/linux
Now enter in your project directory and run Simics from there:
cd simics-projects/first/
./simics
and from Simics prompt type:
load-target target = "risc-v-simple/linux"
run
Et voilà! Buildroot kernel image will boot in a new output window:
Stay tuned to my next articles to get my experiences about customized processor pipelines and MMU.