RISC-V QEMU Ethernet support

575 views
Skip to first unread message

Alex Guo

unread,
Mar 6, 2016, 2:44:24 AM3/6/16
to sw-...@lists.riscv.org
Hi,

Does the riscv-qemu support any NIC card so I can use ethernet to
connect to outside in riscv-linux?

I checked the HTIF implementation, it seems no ethernet there. Also I
tried virtio but it report an error: "No 'virtio-bus' bus found for
device 'virtio-net-device'".

Thanks.

Best,
Alex Guo

Palmer Dabbelt

unread,
Mar 6, 2016, 2:47:23 AM3/6/16
to xf...@xfguo.org, sw-...@lists.riscv.org
Here's the script I used to use to boot QEMU, which came up with virtio
networking.

https://github.com/palmer-dabbelt/riscv-gentoo-infra/blob/37a28d444e1e1fad2443b56875c2a64796a1fc8a/boot

I haven't used QEMU in a long time, so I have no idea if it still works.

Alex Guo

unread,
Mar 6, 2016, 10:16:03 AM3/6/16
to Palmer Dabbelt, sw-...@lists.riscv.org
Hi, Dabbelt, Thanks for your reply.

That script is not work for me. I think it failed because I built the qemu by myself but with wrong configurations.

The slide of riscv-software-stack-tutorial-hpca2015.pdf wrote that there is an argument of "--disable-riscv-htif" when configure the qemu, but I can't find it any more. Did you build the riscv-qemu by yourself?

Best,

Alex Guo

Sagar Karandikar

unread,
Mar 6, 2016, 7:42:16 PM3/6/16
to Alex Guo, sw-...@lists.riscv.org
The new version of riscv-qemu doesn't have the --disable-riscv-htif flag, since only htif devices have been tested at this point.

To enable virtio, you’ll need to add a line to riscv_board.c in hw/riscv in QEMU [1] and then make some modifications to riscv-linux (which I haven’t worked out yet).


--
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 post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/56DC49AD.2050102%40xfguo.org.

Alex Guo

unread,
Mar 12, 2016, 1:50:43 AM3/12/16
to Sagar Karandikar, sw-...@lists.riscv.org
The another way to use the Ethernet in qemu is to implement a HTIF ethernet device and its driver both in qemu and riscv-linux, right?

- Alex

Palmer Dabbelt

unread,
Mar 12, 2016, 2:00:04 AM3/12/16
to xf...@xfguo.org, sag...@eecs.berkeley.edu, sw-...@lists.riscv.org
The best way to get ethernet working in qemu is to use virtio. We used to just
hard-code everything, with a call like

sysbus_create_simple("virtio-mmio", 0x400, env->irq[1]);

in the RISC-V QEMU board emulation file (qemu/hw/riscv/riscv_board.c) and an
option like

CONFIG_CMDLINE="virtio_mmio.device=0x200@0x400:1"

in linux/.config. This approach should still work, but the right way to fix
this is to present a the virtio device as part of the device tree (or whatever
Andrew is calling his replacement) that QEMU exposes to Linux, which doesn't
require hard-coding all these offsets.
>> <mailto:sw-dev+un...@groups.riscv.org>.
>> To post to this group, send email to sw-...@groups.riscv.org
>> <mailto:sw-...@groups.riscv.org>.
>> <https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/56DC49AD.2050102%40xfguo.org?utm_medium=email&utm_source=footer>.
>>
>>
>> --
>> 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
>> <mailto:sw-dev+un...@groups.riscv.org>.
>> To post to this group, send email to sw-...@groups.riscv.org
>> <mailto:sw-...@groups.riscv.org>.
>> Visit this group at
>> https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
>> To view this discussion on the web visit
>> https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAGge8_ONd2bLb5SkkDM_tkQFeZVCkOBEBjy5P5YwyfxXkMng8g%40mail.gmail.com
>> <https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAGge8_ONd2bLb5SkkDM_tkQFeZVCkOBEBjy5P5YwyfxXkMng8g%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
> --
> 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 post to this group, send email to sw-...@groups.riscv.org.
> Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
> To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/56E3BC3A.90504%40xfguo.org.

Alex Guo

unread,
Mar 14, 2016, 7:30:15 AM3/14/16
to Palmer Dabbelt, sag...@eecs.berkeley.edu, sw-...@lists.riscv.org
Hi Dabbelt, I just followed your instructions,

1) hard-code in riscv-qemu:

    sysbus_create_simple("virtio-mmio", 0xfffff400, env->irq[5]);

2) and the command line arguments:

    "CONFIG_CMDLINE="root=/dev/htifblk0 virtio_mmio.device=0x200@0xfffff400:5"

3) start qemu

    $ qemu-system-riscv \
        -kernel bbl \
        -append vmlinux \
        -drive file=ext4.img \
        -nographic \
        -netdev user,id=net0 -device virtio-net-device,netdev=net0

The boot log:

...
[    0.250000] Unpacking initramfs...
[    0.250000] virtio-mmio: Registering device virtio-mmio.0 at 0xfffff400-0xfffff5ff, IRQ 5.
[    0.250000] futex hash table entries: 256 (order: 0, 6144 bytes)
[    0.260000] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.260000] jffs2: version 2.2. (NAND) (SUMMARY)  © 2001-2006 Red Hat, Inc.
[    0.270000] io scheduler noop registered
[    0.270000] io scheduler deadline registered (default)
[    0.360000] virtio_net: probe of virtio0 failed with error -22
[    0.360000] SLIP: version 0.8.4-NET3.019-NEWTTY (dynamic channels, max=256).
....

It seems that virtio_net can't use virtio-mmio.0 as its virtio bus. Any suggestion?

Thanks.

Alex
 

On 2016年03月12日 15:00, Palmer Dabbelt wrote:
The best way to get ethernet working in qemu is to use virtio.  We used to just
hard-code everything, with a call like

  sysbus_create_simple("virtio-mmio", 0x400, env->irq[1]);

in the RISC-V QEMU board emulation file (qemu/hw/riscv/riscv_board.c) and an
option like

  CONFIG_CMDLINE="virtio_mmio.device=0x200@0x400:1"

in linux/.config.  This approach should still work, but the right way to fix
this is to present a the virtio device as part of the device tree (or whatever
Andrew is calling his replacement) that QEMU exposes to Linux, which doesn't
require hard-coding all these offsets.

On Fri, 11 Mar 2016 22:50:34 PST (-0800), xf...@xfguo.org wrote:
The another way to use the Ethernet in qemu is to implement a HTIF
ethernet device and its driver both in qemu and riscv-linux, right?

- Alex

On 2016年03月07日 08:41, Sagar Karandikar wrote:
The new version of riscv-qemu doesn't have the --disable-riscv-htif
flag, since only htif devices have been tested at this point.

To enable virtio, you’ll need to add a line to riscv_board.c in
hw/riscv in QEMU [1] and then make some modifications to riscv-linux
(which I haven’t worked out yet).

-Sagar

[1]
Reply all
Reply to author
Forward
0 new messages