Boot linux on spike

777 views
Skip to first unread message

Yu Zhang

unread,
Jun 22, 2018, 8:54:46 PM6/22/18
to RISC-V SW Dev
Hi there!

I am trying to boot linux on spike simulator and I ran into the "dummy payload" issue that was discussed about 2 years ago here:

https://stackoverflow.com/questions/37849574/how-to-rebuild-bbl-with-payload-option

However the issue seems still exist today. I am using the latest master branch and tried the "--with-payload=<path/to/vmlinux>" option but I still get the same dummy payload message. I am relatively new to RISCV and would appreciate any help/pointers.

Thanks!
Yu

Jim Wilson

unread,
Jun 22, 2018, 9:20:28 PM6/22/18
to Yu Zhang, RISC-V SW Dev
The latest master branch of what exactly? Where exactly did you put
the --with-payload option? You need to give more info about what
exactly you are doing if you want useful responses.

If you are starting from scratch, you might want to try looking at a
known working repo. The github sifive/freedom-u-sdk repo can build
linux+buildroot and boot it on either spike or qemu. qemu is the more
useful choice, as it supports devices and spike does not. spike is
the reference implementation for the architecture though so it is
useful for that reason. There is a small problem with the spike
support, you need to enable CONFIG_HVC_RISCV_SBI in
conf/linux_defconfig. The default serial console driver is the one
that works best on the HiFive Unleashed board, and this one
unfortunately does not work on spike, so you need to enable the old
one to get linux booting on spike. You can use this freedom-u-sdk
repo as a guide for how to create your own linux+builtroot distro.

Jim

Yu Zhang

unread,
Jun 22, 2018, 9:33:11 PM6/22/18
to RISC-V SW Dev, yzha...@gmail.com
Thank you Jim for the quick response! I will be trying the repo you suggested.

I used the "official" github repo (e.g., pk/bbl is from https://github.com/riscv/riscv-pk.git)
and the following command option to build pk/bbl:

../configure --with-payload=<path_to_vmlinux> --prefix=$RISCV --host=riscv64-unknown-elf

Yu Zhang

unread,
Jun 23, 2018, 3:07:20 AM6/23/18
to RISC-V SW Dev, yzha...@gmail.com
Hi Jim,

I am happy to report that with the workaround you suggested I am now able to boot linux on spike now! I also appreciate the fact both riscv/linux sources are included in single repo (after populating the sub modules) and there exists one single top level Makefile that hides the details of configing and building. Job well done SiFive!

Running spike seems no longer require the +disk option. A quick tryout shows basic commands like 'ls', 'cd', 'mkdir', 'touch' seem to work OK. 'date' shows it was Jan. 1, 1970 (I hope that is real :-)). 'vi' behaves a little weird but all in all it was very nice to see the basic stuff working.

Yu

Prashanth Mundkur

unread,
Jun 27, 2018, 12:23:58 PM6/27/18
to Jim Wilson, Yu Zhang, RISC-V SW Dev
On 18:20 Fri 22 Jun, Jim Wilson wrote:

> If you are starting from scratch, you might want to try looking at a
> known working repo. The github sifive/freedom-u-sdk repo can build
> linux+buildroot and boot it on either spike or qemu. qemu is the more
> useful choice, as it supports devices and spike does not. spike is
> the reference implementation for the architecture though so it is
> useful for that reason. There is a small problem with the spike
> support, you need to enable CONFIG_HVC_RISCV_SBI in
> conf/linux_defconfig. The default serial console driver is the one
> that works best on the HiFive Unleashed board, and this one
> unfortunately does not work on spike, so you need to enable the old
> one to get linux booting on spike. You can use this freedom-u-sdk
> repo as a guide for how to create your own linux+builtroot distro.

Hi,

I'm trying this out, but I'd like to get this built for without any
floating-point, i.e. with ISA=rv64imac. Is there a simple way to get
this to work? Currently, it fails with:

checking for clock_t... yes
checking for F_SETLKW... yes
checking if mkdir takes one argument... no
--with-abi=lp64d is not supported for ISA rv64imac
Makefile:4149: recipe for target 'configure-gcc' failed
make[2]: *** [configure-gcc] Error 1
make[2]: Leaving directory '/src/hw/riscv/freedom-u-sdk/work/riscv-gnu-toolchain/build-gcc-linux-stage1'
Makefile:204: recipe for target 'stamps/build-gcc-linux-stage1' failed
make[1]: *** [stamps/build-gcc-linux-stage1] Error 2
make[1]: Leaving directory '/src/hw/riscv/freedom-u-sdk/work/riscv-gnu-toolchain'
Makefile:73: recipe for target '/src/hw/riscv/freedom-u-sdk/toolchain/bin/riscv64-unknown-linux-gnu-gcc' failed
make: *** [/src/hw/riscv/freedom-u-sdk/toolchain/bin/riscv64-unknown-linux-gnu-gcc] Error 2

Is there an alternate --with-abi setting I could try?

--prashanth

Jim Wilson

unread,
Jun 27, 2018, 12:53:05 PM6/27/18
to Prashanth Mundkur, Yu Zhang, RISC-V SW Dev
On Wed, Jun 27, 2018 at 9:22 AM, Prashanth Mundkur
<pmundk...@gmail.com> wrote:
> I'm trying this out, but I'd like to get this built for without any
> floating-point, i.e. with ISA=rv64imac. Is there a simple way to get
> this to work? Currently, it fails with:

We only support rv64gc with the lp64d ABI. In theory other
combinations should build, but may require some work to get them
building.

> checking for clock_t... yes
> checking for F_SETLKW... yes
> checking if mkdir takes one argument... no
> --with-abi=lp64d is not supported for ISA rv64imac

You need --with-abi=lp64 for a soft-float target.

Jim

Rohan Ahmed

unread,
Jun 10, 2024, 11:03:05 AM (10 days ago) Jun 10
to RISC-V SW Dev, Jim Wilson, Yu Zhang, RISC-V SW Dev, pmundkur.fpga
Hi Yu Zhong,

I am also trying to boot linux on spike but unabe to do so. Can you tell me the steps you follow and from which repo in detail,

Thanks,
Rohan

Tommy Murphy

unread,
Jun 10, 2024, 11:33:01 AM (10 days ago) Jun 10
to Rohan Ahmed, RISC-V SW Dev, Jim Wilson, Yu Zhang, RISC-V SW Dev, pmundkur.fpga
What about something like this? 


Rohan Ahmed

unread,
Jun 10, 2024, 11:37:25 AM (10 days ago) Jun 10
to RISC-V SW Dev, tommy_...@hotmail.com, Jim Wilson, Yu Zhang, RISC-V SW Dev, pmundkur.fpga
Yeah, I am trying with that repo now,
previously trying I was trying with  https://github.com/openhwgroup/cva6-sdk. Actually, I have to boot linux on ariane.

Thanks,
Rohan  

Tommy Murphy

unread,
Jun 10, 2024, 12:12:15 PM (10 days ago) Jun 10
to Rohan Ahmed, RISC-V SW Dev, Jim Wilson, Yu Zhang, pmundkur.fpga
> Actually, I have to boot linux on ariane

You mean not on Spike but on Ariane hardware?
In that case wouldn't it make most sense to engage with the Ariane community on this?

Rohan Ahmed

unread,
Jun 11, 2024, 12:34:19 AM (9 days ago) Jun 11
to RISC-V SW Dev, tommy_...@hotmail.com, Jim Wilson, Yu Zhang, pmundkur.fpga, Rohan Ahmed
Actually I am new to all of these and try to learn about these, my end goal is on the ariane but I think, I should first start with booting on spike to understand the concepts,

Thanks,
Rohan

Tommy Murphy

unread,
Jun 11, 2024, 3:17:31 AM (9 days ago) Jun 11
to Rohan Ahmed, RISC-V SW Dev, Jim Wilson, Yu Zhang, pmundkur.fpga
Why Spike?
QEMU would be easier and more practical as far as I recall.
And there are probably more resources available to help you with QEMU.

Rohan Ahmed

unread,
Jun 11, 2024, 3:55:21 AM (9 days ago) Jun 11
to RISC-V SW Dev, tommy_...@hotmail.com, Jim Wilson, Yu Zhang, pmundkur.fpga, Rohan Ahmed
Yeah, I found the resource mostly related to spike

Rohan Ahmed

unread,
Jun 11, 2024, 3:56:52 AM (9 days ago) Jun 11
to RISC-V SW Dev, Rohan Ahmed, tommy_...@hotmail.com, Jim Wilson, Yu Zhang, pmundkur.fpga
just one question, can we a make single elf file which is able to run the linux?

Thanks,
Rohan Ahmed

Tommy Murphy

unread,
Jun 11, 2024, 4:56:36 AM (9 days ago) Jun 11
to Rohan Ahmed, RISC-V SW Dev, Rohan Ahmed, Jim Wilson, Yu Zhang, pmundkur.fpga
> Yeah, I found the resource mostly related to spike

I don't understand. In my experience there's a lot more info available about running RISC-V Linux on QEMU than on Spike. And QEMU is arguably better suited to this use case anyway.

> just one question, can we a make single elf file which is able to run the linux?

I don't understand what you mean. You'll need to clarify/provide more detail about what you want to do. Linux normally comprises different separate component programs - e.g. bootloader, kernel, daemons/services, user space programs etc.

Rishiyur Nikhil

unread,
Jun 11, 2024, 10:04:15 AM (9 days ago) Jun 11
to Tommy Murphy, Rohan Ahmed, RISC-V SW Dev, Jim Wilson, Yu Zhang
As Tommy says, there are several ELFs involved.

I'm not an ELF and loader expert, so please take what I say with a grain of salt:

* The multiple ELFs can be pre-combined into a single ELF, but then
    the latter ELFs become "data payloads" of the first ELF, and so
    you may not have access to GDB symbolic debugging information for the
    latter ELFs.  Better to be able to load multiple ELFs (e.g., boot
    loader, OpenSBI, Linux kernel).

* For user-space programs, if you are modeling a block device, those
    ELFs can be pre-loaded on a file system in the block device.

  If you are not modeling a block device, you can build-in to the
    Linux image a memory-based file system containing user-space
    programs.

All this requires quite a bit of system-building knowledge
(configuring gcc to build suitable ELFs, configuring Linux kernel
build, ...)

Nikhil

--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/LO2P123MB379131A4B5380BB9B40B4BAFF9C72%40LO2P123MB3791.GBRP123.PROD.OUTLOOK.COM.

Rohan Ahmed

unread,
Jun 13, 2024, 3:43:26 AM (7 days ago) Jun 13
to RISC-V SW Dev, nikhil, Rohan Ahmed, RISC-V SW Dev, Jim Wilson, Yu Zhang, tommy_...@hotmail.com
Thanks to everyone for giving you insights, I am able to boot linux in spike, followed these repo; 
https://github.com/openhwgroup/cva6-sdk

It gives the single elf file which can run on spike

Thansk, Rohan Ahmed
Reply all
Reply to author
Forward
0 new messages