From 24d07fdc1404901fb1872ac55f875fe1d555cbb3 Mon Sep 17 00:00:00 2001 From: Julien Olivain Date: Sun, 9 Jan 2022 17:47:56 +0100 Subject: [PATCH] configs/spike_riscv64: new defconfig Signed-off-by: Julien Olivain Signed-off-by: Thomas Petazzoni --- DEVELOPERS | 2 ++ board/spike/riscv64/readme.txt | 39 +++++++++++++++++++++++++++++++++ board/spike/riscv64/start.sh | 13 +++++++++++ configs/spike_riscv64_defconfig | 13 +++++++++++ 4 files changed, 67 insertions(+) create mode 100644 board/spike/riscv64/readme.txt create mode 100755 board/spike/riscv64/start.sh create mode 100644 configs/spike_riscv64_defconfig diff --git a/DEVELOPERS b/DEVELOPERS index 13464178c0..bcc54bd11b 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1588,10 +1588,12 @@ F: package/paho-mqtt-c N: Julien Olivain F: board/qmtech/zynq/ +F: board/spike/ F: board/technexion/imx8mmpico/ F: board/technexion/imx8mpico/ F: configs/imx8mmpico_defconfig F: configs/imx8mpico_defconfig +F: configs/spike_riscv64_defconfig F: configs/zynq_qmtech_defconfig F: package/fluid-soundfont/ F: package/fluidsynth/ diff --git a/board/spike/riscv64/readme.txt b/board/spike/riscv64/readme.txt new file mode 100644 index 0000000000..5ad7df46df --- /dev/null +++ b/board/spike/riscv64/readme.txt @@ -0,0 +1,39 @@ +Linux on Spike RISC-V ISA simulator +=================================== + +This configuration provides a minimal working setup to run a Linux +kernel in the Spike RISC-V ISA simulator. + +The Spike ISA simulator can be an interresting alternative to Qemu, in +some specific cases. For example: simulating new instructions (see [1]), +simulating riscv-openocd/gdb debug sessions (see [2], [3]), or +generating an accurate per-instruction log of execution (see +riscv-isa-sim spike -l option)... + +To run Buildroot Linux in Spike, use the commands: + + make spike_riscv64_defconfig + make + ./board/spike/riscv64/start.sh + +The boot is made with the standard RISC-V OpenSBI boot loader. In +order to keep the simulation simple, the rootfs is passed as an initrd +ramfs. + +Note: at the time of this writing, Spike v1.1.0 and OpenSBI v1.0 does +not support console input emulation for 32bit RISC-V systems. A 32bit +Linux system can boot and reach the login, but it's not possible to +login. See [4]. + + +[1]. +https://github.com/riscv-software-src/riscv-isa-sim/tree/v1.1.0#simulating-a-new-instruction + +[2]. +https://github.com/riscv-software-src/riscv-isa-sim/tree/v1.1.0#debugging-with-gdb + +[3]. +https://github.com/riscv/riscv-openocd + +[4]. +https://github.com/riscv-software-src/opensbi/blob/v1.0/lib/utils/sys/htif.c#L127 diff --git a/board/spike/riscv64/start.sh b/board/spike/riscv64/start.sh new file mode 100755 index 0000000000..75b1412df8 --- /dev/null +++ b/board/spike/riscv64/start.sh @@ -0,0 +1,13 @@ +#! /bin/sh + +SCRIPT_DIR="$(dirname "$0")" +BR_BASEDIR="$(readlink -e "${SCRIPT_DIR}/../../..")" + +# Use Buildroot host spike by default, but allow the caller to +# redefine another spike binary +: "${SPIKE:=${BR_BASEDIR}/output/host/usr/bin/spike}" + +exec "${SPIKE}" \ + --initrd "${BR_BASEDIR}"/output/images/rootfs.cpio \ + "${@}" \ + "${BR_BASEDIR}"/output/images/fw_payload.elf diff --git a/configs/spike_riscv64_defconfig b/configs/spike_riscv64_defconfig new file mode 100644 index 0000000000..cc145bcd8e --- /dev/null +++ b/configs/spike_riscv64_defconfig @@ -0,0 +1,13 @@ +BR2_riscv=y +BR2_RISCV_64=y +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_CUSTOM_VERSION=y +BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.15.13" +BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_15=y +BR2_TARGET_ROOTFS_CPIO=y +# BR2_TARGET_ROOTFS_TAR is not set +BR2_TARGET_OPENSBI=y +BR2_TARGET_OPENSBI_PLAT="generic" +BR2_TARGET_OPENSBI_LINUX_PAYLOAD=y +BR2_PACKAGE_HOST_RISCV_ISA_SIM=y