The second guide is very much outdated now. More precisely, what has changed since 2014:
spike no longer supports external disk images following the deprecation of the Host-Target Interface (HTIF). This is the reason for the mount error - an embedded initramfs is now required if using spike.
vmlinux is no longer loaded directly but rather embedded in bbl.
An easier way to build a Linux image that works with the current spike simulator is through the Freedom U SDK, which automates the entire process.
$ git clone https://github.com/sifive/freedom-u-sdk.git
$ cd freedom-u-sdk
$ git submodule update --init --recursive
$ make
$ spike work/riscv-pk/bbl
The CONFIG_INITRAMFS_SOURCE Kconfig option specifies which initramfs image to embed. This can be a cpio archive, sysroot directory, or a configuration file. See Documentation/early-userspace/README.
I saw bbl included Linux core, so it becomes independent now.
The network interface eth0 does not work now.
Another question is how to mount external FS blocks to this Linux. I think I have to change etc/fstab under sysroot to make it happen, but I am not sure how to do it in this setup.
Since spike doesn’t implement a virtual Ethernet device, eth0 being absent is expected. Keep in mind that the SDK is originally intended for use with the VC707 development board to which a physical NIC can be connected via PCIe. It should be possible to modify the buildroot to exclude the networking initscript.
At this time, spike doesn’t support external block devices, so there is no way to mount additional filesystems. You will have to add whatever files you need to the buildroot initramfs using a filesystem overlay. Unfortunately, this means that file modifications aren’t persistent.
First i followed the steps in https://github.com/riscv/riscv-linux
and in the process i was able to complile spike, gcc, linux etc.
How ever i was not successful in booting linux using spike.
Meanwhile i hit up on the instructions using freedom-u-sdk
and I have been able to compile the freedom-u-sdk by following the steps
$ git clone https://github.com/sifive/freedom-u-sdk.git
$ cd freedom-u-sdk
$ git submodule update --init --recursive
$ make
The following (few executable + linux kernel) are shown…
-rwxrwxr-x 1 gvsk gvsk 7986392 Oct 28 19:13 work/bbl.bin
-rw-rw-r-- 1 gvsk gvsk 23959176 Oct 28 19:13 work/bbl.hex
-rwxrwxr-x 1 gvsk gvsk 8718576 Oct 28 19:12 work/linux/vmlinux
-rwxrwxr-x 1 gvsk gvsk 80248 Oct 28 19:13 work/riscv-pk/pk
-rwxrwxr-x 1 gvsk gvsk 8000120 Oct 28 19:13 work/riscv-pk/bbl
However i dont find the spike (sources/executable) in the freedom-u-sdk.
So i used the spike from the riscv-tools to boot up linux
$ …/…/riscv/bin/spike work/riscv-pk/bbl
but it does not boot vmlinux.
Not sure where i am going wrong. Any pointers/suggestions are welcome.
The spike invoked from riscv won’t work on the freedom-u-sdk.Instead type “make sim” in the freedom-u-sdk top level dir. It will build everything you need and then boot the kernel in spike.