Building QEMU image for RISC-V

735 views
Skip to first unread message

Pintu Kumar

unread,
Aug 7, 2018, 10:17:24 AM8/7/18
to isa...@groups.riscv.org
Hi,

I have some basic questions about risc-v.
Can someone clarify my doubt.

1) What is the output kernel image for riscv?
I see vmlinux is created, but I could not find anything like:
arch/riscv/boot/...[zImage]
There is no boot folder itself.

2) How to create minimal rootfs image for riscv-32/64, which I can use
it for QEMU?

3) How to use boot riscv kernel/rootfs with QEMU ?
What are the minimal parameters to use, to get a basic shell working?

If there is some reference, where pre-build rootfs is available,
please let me know.


Thanks,
Pintu

Tommy Murphy

unread,
Aug 7, 2018, 10:59:34 AM8/7/18
to RISC-V ISA Dev

Bruce Hoult

unread,
Aug 7, 2018, 10:00:29 PM8/7/18
to Pintu Kumar, RISC-V ISA Dev
You could look at SiFive's freedom-u-sdk, "make qemu" will create a buildroot linux image and launch it in qemu.




--
You received this message because you are subscribed to the Google Groups "RISC-V ISA Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isa-dev+unsubscribe@groups.riscv.org.
To post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/CAOuPNLgZPms9jjh_hZOa%3Da%3Dhxsr%3D7PMnECLr5-UT5SVS4PO1rg%40mail.gmail.com.

Pintu Kumar

unread,
Aug 24, 2018, 8:11:21 AM8/24/18
to bruce...@sifive.com, gurucha...@gmail.com, isa...@groups.riscv.org
On Wed, Aug 8, 2018 at 7:30 AM Bruce Hoult <bruce...@sifive.com> wrote:
>
> You could look at SiFive's freedom-u-sdk, "make qemu" will create a buildroot linux image and launch it in qemu.
>
> https://github.com/sifive/freedom-u-sdk
>

Thank you so much :)
With this we could able to successfully boot riscv64 with qemu
environment, and run some basic application.
Also we could able to boot directly with riscv-qemu command, and out
custom kernel 4.18 (without freedom-sdk environment).

But, we observed that riscv-qemu works (console login), only with
machine type as "virt".
Can we also use the machine type as "sifive" and boot in qemu ?
We observed that if we use "sifive" then the qemu boots with some
logs, but there is no console.
How to solve this problem?

Thanks,
Pintu



>
> On Tue, Aug 7, 2018 at 7:17 AM, Pintu Kumar <pintu...@gmail.com> wrote:
>>
>> Hi,
>>
>> I have some basic questions about risc-v.
>> Can someone clarify my doubt.
>>
>> 1) What is the output kernel image for riscv?
>> I see vmlinux is created, but I could not find anything like:
>> arch/riscv/boot/...[zImage]
>> There is no boot folder itself.
>>
>> 2) How to create minimal rootfs image for riscv-32/64, which I can use
>> it for QEMU?
>>
>> 3) How to use boot riscv kernel/rootfs with QEMU ?
>> What are the minimal parameters to use, to get a basic shell working?
>>
>> If there is some reference, where pre-build rootfs is available,
>> please let me know.
>>
>>
>> Thanks,
>> Pintu
>>
>> --
>> You received this message because you are subscribed to the Google Groups "RISC-V ISA Dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to isa-dev+u...@groups.riscv.org.

Bruce Hoult

unread,
Aug 24, 2018, 8:21:52 AM8/24/18
to Pintu Kumar, gurucha...@gmail.com, RISC-V ISA Dev, Michael Clark
Michael is the expert on that. Added cc

>> To unsubscribe from this group and stop receiving emails from it, send an email to isa-dev+unsubscribe@groups.riscv.org.

Michael Clark

unread,
Aug 24, 2018, 9:08:55 AM8/24/18
to Bruce Hoult, Pintu Kumar, gurucha...@gmail.com, RISC-V ISA Dev


On 25/08/2018, at 12:21 AM, Bruce Hoult <bruce...@sifive.com> wrote:

Michael is the expert on that. Added cc

On Fri, Aug 24, 2018 at 5:11 AM, Pintu Kumar <pintu...@gmail.com> wrote:
On Wed, Aug 8, 2018 at 7:30 AM Bruce Hoult <bruce...@sifive.com> wrote:
>
> You could look at SiFive's freedom-u-sdk, "make qemu" will create a buildroot linux image and launch it in qemu.
>
> https://github.com/sifive/freedom-u-sdk
>

Thank you so much :)
With this we could able to successfully boot riscv64 with qemu
environment, and run some basic application.
Also we could able to boot directly with riscv-qemu command, and out
custom kernel 4.18 (without freedom-sdk environment).

But, we observed that riscv-qemu works (console login), only with
machine type as "virt".
Can we also use the machine type as "sifive" and boot in qemu ?
We observed that if we use "sifive" then the qemu boots with some
logs, but there is no console.
How to solve this problem?

It depends.

There is no machine type “sifive” in current upstream QEMU. There is the “sifive_e” machine which emulates the SiFive E-Series cores. It cant’t boot Linux as the E-Series core have no MMU. 

There is the “sifive_u” machine which emulates the SiFive U-Series cores that can boot Linux, but it has several constraints on root device.

We don’t currently emulate the HiFive Unleashed’s SD card peripheral in RISC-V QEMU, and depending on where you got QEMU from, it may or may not have Cadence GEM support (for network boot).

What device are you trying to use as your root device?

Have you tried by appending an initramfs to your kernel image?

Note: for console output you’ll need a kernel that is configured to use SBI or the SiFive UART vs the NS16550A in the “virt” machine.

Pintu Kumar

unread,
Aug 27, 2018, 3:30:54 AM8/27/18
to michae...@mac.com, bruce...@sifive.com, Gurucharan Kaur Saluja, isa...@groups.riscv.org
On Fri, Aug 24, 2018 at 6:38 PM 'Michael Clark' via RISC-V ISA Dev
<isa...@groups.riscv.org> wrote:
>
>
>
> On 25/08/2018, at 12:21 AM, Bruce Hoult <bruce...@sifive.com> wrote:
>
> Michael is the expert on that. Added cc
>
> On Fri, Aug 24, 2018 at 5:11 AM, Pintu Kumar <pintu...@gmail.com> wrote:
>>
>> On Wed, Aug 8, 2018 at 7:30 AM Bruce Hoult <bruce...@sifive.com> wrote:
>> >
>> > You could look at SiFive's freedom-u-sdk, "make qemu" will create a buildroot linux image and launch it in qemu.
>> >
>> > https://github.com/sifive/freedom-u-sdk
>> >
>>
>> Thank you so much :)
>> With this we could able to successfully boot riscv64 with qemu
>> environment, and run some basic application.
>> Also we could able to boot directly with riscv-qemu command, and out
>> custom kernel 4.18 (without freedom-sdk environment).
>>
>> But, we observed that riscv-qemu works (console login), only with
>> machine type as "virt".
>> Can we also use the machine type as "sifive" and boot in qemu ?
>> We observed that if we use "sifive" then the qemu boots with some
>> logs, but there is no console.
>> How to solve this problem?
>
>
> It depends.
>
> There is no machine type “sifive” in current upstream QEMU. There is the “sifive_e” machine which emulates the SiFive E-Series cores. It cant’t boot Linux as the E-Series core have no MMU.
>
> There is the “sifive_u” machine which emulates the SiFive U-Series cores that can boot Linux, but it has several constraints on root device.
>
> We don’t currently emulate the HiFive Unleashed’s SD card peripheral in RISC-V QEMU, and depending on where you got QEMU from, it may or may not have Cadence GEM support (for network boot).
>
> What device are you trying to use as your root device?
>
We are trying to use either buildroot (part of freedom-sdk) or
busybear as the root device.
Further we wanted to use ubuntu debian based rootfs.

> Have you tried by appending an initramfs to your kernel image?
>
In freedom-sdk itself, we just tried changing machine type from 'virt'
to 'sifive_x', without changing the kernel configuration.
So, I guess, it should be using initramfs itself.

> Note: for console output you’ll need a kernel that is configured to use SBI or the SiFive UART vs the NS16550A in the “virt” machine.
>
We are trying to boot with the same kernel under freedom-sdk. We are
just changing the machine type.

> --
> You received this message because you are subscribed to the Google Groups "RISC-V ISA Dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to isa-dev+u...@groups.riscv.org.
> To post to this group, send email to isa...@groups.riscv.org.
> Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
> To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/84039779-5CE6-47F0-8666-94DD2F5A2F05%40mac.com.

Michael Clark

unread,
Aug 27, 2018, 7:50:30 AM8/27/18
to Pintu Kumar, bruce...@sifive.com, Gurucharan Kaur Saluja, isa...@groups.riscv.org
It’s not possible to just change the machine type. ‘sifive_u’ currently does not have any supported root devices in QEMU so you can’t add the same drive parameters.

If you have a filesystem, you can google for some instructions on how to convert it to an initramfs (this is the same on all architectures) and then you can append it to your kernel image before you pack it with riscv-pk.

We should perhaps make some scripts at some point that allow an initramfs boot option, but at this point you need to read the documentation.

>> Note: for console output you’ll need a kernel that is configured to use SBI or the SiFive UART vs the NS16550A in the “virt” machine.
>>
> We are trying to boot with the same kernel under freedom-sdk. We are
> just changing the machine type.

That’s the issue. Each machine type has different constraints, such that the image and it’s filesystem may need to be packed differently i.e. initramfs.

We don’t have SDCARD emulation in the QEMU ‘sifive_u’ machine yet.

Khem Raj

unread,
Aug 27, 2018, 2:13:06 PM8/27/18
to pintu...@gmail.com, isa...@groups.riscv.org
Hi
you can use OpenEmbedded to build and boot into qemu the instructions are here

https://github.com/riscv/meta-riscv/blob/master/README.md

if you run into issues, feel free to send questions or open issues on github

>
> Thanks,
> Pintu
>
> --
> You received this message because you are subscribed to the Google Groups "RISC-V ISA Dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to isa-dev+u...@groups.riscv.org.
> To post to this group, send email to isa...@groups.riscv.org.
> Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
> To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/CAOuPNLgZPms9jjh_hZOa%3Da%3Dhxsr%3D7PMnECLr5-UT5SVS4PO1rg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages