Skip to contentSkip to conversation

Ethernet support for QEMU sifive_u machine

PATCH New Anup Patel 2 participants 26 messages Dec 17, 2018 – Aug 7, 2019

Subsystems (2)
lore
Share & tools
lore

Anup Patel

author
#0 lore raw

cover Ethernet support for QEMU sifive_u machine

This patchset enables Cadance MACB ethernet driver for QEMU sifive_u machine. The Cadance MACB ethernet driver works fine for QEMU sifive_u machince in both M-mode and S-mode with some minor fixes.

The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 9deb8d2fcd13d4a40a4e63c396fe4376af46efac

To try on QEMU, please ensure following patches are applied to QEMU sources:
https://patchwork.kernel.org/patch/10729579/
https://patchwork.kernel.org/patch/10729581/

Anup Patel (3):
riscv: Add asm/dma-mapping.h for DMA mappings
net: macb: Fix clk API usage for RISC-V systems
riscv: qemu: Imply MACB ethernet for emulation

 arch/riscv/include/asm/dma-mapping.h | 37 ++++++++++++++++++++++++++++
 board/emulation/qemu-riscv/Kconfig   |  4 +++
 drivers/net/macb.c                   |  4 ++-
 3 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 arch/riscv/include/asm/dma-mapping.h
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/3 riscv: Add asm/dma-mapping.h for DMA mappings

From: Anup Patel <[email protected]>

This patch adds asm/dma-mapping.h for Linux-like DMA mappings APIs required by some of the drivers (such as, Cadance MACB Ethernet driver).

---
 arch/riscv/include/asm/dma-mapping.h | 37 ++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 arch/riscv/include/asm/dma-mapping.h
arch/riscv/include/asm/dma-mapping.h new file +37 -0
new file mode 100644
index 0000000000..9782b6f168
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2018 Western Digital Corporation or its affiliates.
+ *
+ * Authors:
+ *   Anup Patel <[email protected]>
+ */
+#ifndef __ASM_RISCV_DMA_MAPPING_H
+#define __ASM_RISCV_DMA_MAPPING_H
+
+#include <linux/dma-direction.h>
+
+#define	dma_mapping_error(x, y)	0
+
+static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
+{
+	*handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, len);
+	return (void *)*handle;
+}
+
+static inline void dma_free_coherent(void *addr)
+{
+	free(addr);
+}
+
+static inline unsigned long dma_map_single(volatile void *vaddr, size_t len,
+					   enum dma_data_direction dir)
+{
+	return (unsigned long)vaddr;
+}
+
+static inline void dma_unmap_single(volatile void *vaddr, size_t len,
+				    unsigned long paddr)
+{
+}
+
+#endif /* __ASM_RISCV_DMA_MAPPING_H */
Signature · 1 line
2.17.1
#2 lore raw

PATCH 1/3 riscv: Add asm/dma-mapping.h for DMA mappings

Quoted 7 lines · Anup Patel

From: Anup Patel <[email protected]>

This patch adds asm/dma-mapping.h for Linux-like DMA mappings APIs required by some of the drivers (such as, Cadance MACB Ethernet driver).

Quoted 6 lines
---
 arch/riscv/include/asm/dma-mapping.h | 37 ++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 arch/riscv/include/asm/dma-mapping.h

But please see nits below:

arch/riscv/include/asm/dma-mapping.h line 7

Quoted 13 lines
arch/riscv/include/asm/dma-mapping.h new file +7 -0
new file mode 100644
index 0000000000..9782b6f168
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2018 Western Digital Corporation or its affiliates.
+ *
+ * Authors:
+ *   Anup Patel <[email protected]>
+ */

nits: should have one blank line here

arch/riscv/include/asm/dma-mapping.h line 13

Quoted 6 lines
arch/riscv/include/asm/dma-mapping.h new file +6 -0
+#ifndef __ASM_RISCV_DMA_MAPPING_H
+#define __ASM_RISCV_DMA_MAPPING_H
+
+#include <linux/dma-direction.h>
+
+#define        dma_mapping_error(x, y) 0

nits: no <tab> between #define and dma_

Quoted 15 lines
arch/riscv/include/asm/dma-mapping.h new file +15 -0
+
+static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
+{
+       *handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, len);
+       return (void *)*handle;
+}
+
+static inline void dma_free_coherent(void *addr)
+{
+       free(addr);
+}
+
+static inline unsigned long dma_map_single(volatile void *vaddr, size_t len,
+                                          enum dma_data_direction dir)
+{

arch/riscv/include/asm/dma-mapping.h

Quoted 10 lines
arch/riscv/include/asm/dma-mapping.h new file +9 -1
+       return (unsigned long)vaddr;
+}
+
+static inline void dma_unmap_single(volatile void *vaddr, size_t len,
+                                   unsigned long paddr)
+{
+}
+
+#endif /* __ASM_RISCV_DMA_MAPPING_H */
--

Regards,
Bin

author
#3 lore raw

PATCH 1/3 riscv: Add asm/dma-mapping.h for DMA mappings

Quoted 20 lines · Bin Meng
Quoted 7 lines · Anup Patel

From: Anup Patel <[email protected]>

This patch adds asm/dma-mapping.h for Linux-like DMA mappings APIs required by some of the drivers (such as, Cadance MACB Ethernet driver).

Quoted 6 lines
---
 arch/riscv/include/asm/dma-mapping.h | 37 ++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 arch/riscv/include/asm/dma-mapping.h

But please see nits below:

Quoted 15 lines

arch/riscv/include/asm/dma-mapping.h line 7

Quoted 13 lines
arch/riscv/include/asm/dma-mapping.h new file +7 -0
new file mode 100644
index 0000000000..9782b6f168
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2018 Western Digital Corporation or its affiliates.
+ *
+ * Authors:
+ *   Anup Patel <[email protected]>
+ */

nits: should have one blank line here

OK, will update.

Quoted 9 lines

arch/riscv/include/asm/dma-mapping.h line 13

Quoted 7 lines
arch/riscv/include/asm/dma-mapping.h new file +6 -0
+#ifndef __ASM_RISCV_DMA_MAPPING_H
+#define __ASM_RISCV_DMA_MAPPING_H
+
+#include <linux/dma-direction.h>
+
+#define        dma_mapping_error(x, y) 0

nits: no <tab> between #define and dma_

OK, will update.

Quoted 21 lines
Quoted 21 lines
arch/riscv/include/asm/dma-mapping.h new file +20 -0
+
+static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
+{
+       *handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, len);
+       return (void *)*handle;
+}
+
+static inline void dma_free_coherent(void *addr)
+{
+       free(addr);
+}
+
+static inline unsigned long dma_map_single(volatile void *vaddr, size_t len,
+                                          enum dma_data_direction dir)
+{
+       return (unsigned long)vaddr;
+}
+
+static inline void dma_unmap_single(volatile void *vaddr, size_t len,
+                                   unsigned long paddr)
Quoted 8 lines

arch/riscv/include/asm/dma-mapping.h

Quoted 5 lines
arch/riscv/include/asm/dma-mapping.h new file +4 -1
+{
+}
+
+#endif /* __ASM_RISCV_DMA_MAPPING_H */
--

Regards,
Bin

Regards,
Anup

author
#4 lore raw

PATCH 1/3 riscv: Add asm/dma-mapping.h for DMA mappings

In reply to Anup Patel

+Michal

Quoted 59 lines · Anup Patel

From: Anup Patel <[email protected]>

This patch adds asm/dma-mapping.h for Linux-like DMA mappings APIs required by some of the drivers (such as, Cadance MACB Ethernet driver).

---
 arch/riscv/include/asm/dma-mapping.h | 37 ++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 arch/riscv/include/asm/dma-mapping.h
arch/riscv/include/asm/dma-mapping.h new file +37 -1
new file mode 100644
index 0000000000..9782b6f168
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2018 Western Digital Corporation or its affiliates.
+ *
+ * Authors:
+ *   Anup Patel <[email protected]>
+ */
+#ifndef __ASM_RISCV_DMA_MAPPING_H
+#define __ASM_RISCV_DMA_MAPPING_H
+
+#include <linux/dma-direction.h>
+
+#define        dma_mapping_error(x, y) 0
+
+static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
+{
+       *handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, len);
+       return (void *)*handle;
+}
+
+static inline void dma_free_coherent(void *addr)
+{
+       free(addr);
+}
+
+static inline unsigned long dma_map_single(volatile void *vaddr, size_t len,
+                                          enum dma_data_direction dir)
+{
+       return (unsigned long)vaddr;
+}
+
+static inline void dma_unmap_single(volatile void *vaddr, size_t len,
+                                   unsigned long paddr)
+{
+}
+
+#endif /* __ASM_RISCV_DMA_MAPPING_H */
--

2.17.1

author
#5 lore raw

PATCH 2/3 net: macb: Fix clk API usage for RISC-V systems

In reply to Anup Patel

From: Anup Patel <[email protected]>

This patch does following fixes in MACB ethernet driver for using it on RISC-V systems (particularly QEMU sifive_u machine):
1. asm/arch/clk.h is not available on RISC-V port so include it only for non-RISC-V systems.
2. Don't fail in macb_enable_clk() if clk_enable() returns -ENOSYS because we get -ENOSYS for fixed-rate clocks.

---
 drivers/net/macb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/macb.c +3 -1
index 94c89c762b..9a06b523cc 100644
@@ -38,7 +38,9 @@
 #include <linux/mii.h>
 #include <asm/io.h>
 #include <asm/dma-mapping.h>
+#ifndef CONFIG_RISCV
 #include <asm/arch/clk.h>
+#endif
 #include <linux/errno.h>
 
 #include "macb.h"
@@ -1066,7 +1068,7 @@ static int macb_enable_clk(struct udevice *dev)
 	 */
 #ifndef CONFIG_MACB_ZYNQ
 	ret = clk_enable(&clk);
-	if (ret)
+	if (ret && ret != -ENOSYS)
 		return ret;
 #endif
 
Signature · 1 line
2.17.1
#6 lore raw

PATCH 2/3 net: macb: Fix clk API usage for RISC-V systems

Quoted 11 lines · Anup Patel

From: Anup Patel <[email protected]>

This patch does following fixes in MACB ethernet driver for using it on RISC-V systems (particularly QEMU sifive_u machine):
1. asm/arch/clk.h is not available on RISC-V port so include it only for non-RISC-V systems.
2. Don't fail in macb_enable_clk() if clk_enable() returns -ENOSYS because we get -ENOSYS for fixed-rate clocks.

Quoted 5 lines
---
 drivers/net/macb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

But please see comments below:

Quoted 15 lines
drivers/net/macb.c +2 -0
index 94c89c762b..9a06b523cc 100644
@@ -38,7 +38,9 @@
 #include <linux/mii.h>
 #include <asm/io.h>
 #include <asm/dma-mapping.h>
+#ifndef CONFIG_RISCV
 #include <asm/arch/clk.h>
+#endif
 #include <linux/errno.h>
 
 #include "macb.h"

drivers/net/macb.c static int macb_enable_clk(struct udevice *dev) · line 1069

Quoted 2 lines
drivers/net/macb.c +0 -0
@@ -1066,7 +1068,7 @@ static int macb_enable_clk(struct udevice *dev)
         */
 #ifndef CONFIG_MACB_ZYNQ

I suspect this "#ifndef CONFIG_MACB_ZYNQ" can be removed per the comments below, with the adding check of (ret != -ENOSYS).

/*
* Zynq clock driver didn't support for enable or disable
* clock. Hence, clk_enable() didn't apply for Zynq */

Someone else who has access to Zynq targets need to confirm.

drivers/net/macb.c static int macb_enable_clk(struct udevice *dev)

Quoted 7 lines
drivers/net/macb.c +1 -2
        ret = clk_enable(&clk);
-       if (ret)
+       if (ret && ret != -ENOSYS)
                return ret;
 #endif
 
--

Regards,
Bin

author
#7 lore raw

PATCH 2/3 net: macb: Fix clk API usage for RISC-V systems

Quoted 44 lines · Bin Meng
Quoted 11 lines · Anup Patel

From: Anup Patel <[email protected]>

This patch does following fixes in MACB ethernet driver for using it on RISC-V systems (particularly QEMU sifive_u machine):
1. asm/arch/clk.h is not available on RISC-V port so include it only for non-RISC-V systems.
2. Don't fail in macb_enable_clk() if clk_enable() returns -ENOSYS because we get -ENOSYS for fixed-rate clocks.

Quoted 5 lines
---
 drivers/net/macb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

But please see comments below:

Quoted 15 lines
drivers/net/macb.c +2 -0
index 94c89c762b..9a06b523cc 100644
@@ -38,7 +38,9 @@
 #include <linux/mii.h>
 #include <asm/io.h>
 #include <asm/dma-mapping.h>
+#ifndef CONFIG_RISCV
 #include <asm/arch/clk.h>
+#endif
 #include <linux/errno.h>
 
 #include "macb.h"

drivers/net/macb.c static int macb_enable_clk(struct udevice *dev) · line 1069

Quoted 2 lines
drivers/net/macb.c +0 -0
@@ -1066,7 +1068,7 @@ static int macb_enable_clk(struct udevice *dev)
         */
 #ifndef CONFIG_MACB_ZYNQ

I suspect this "#ifndef CONFIG_MACB_ZYNQ" can be removed per the comments below, with the adding check of (ret != -ENOSYS).

Quoted 6 lines

/*
* Zynq clock driver didn't support for enable or disable
* clock. Hence, clk_enable() didn't apply for Zynq */

Someone else who has access to Zynq targets need to confirm.

I think let someone with Zynq SOC based board remove this.

Regards,
Anup

author
#8 lore raw

PATCH 3/3 riscv: qemu: Imply MACB ethernet for emulation

In reply to Anup Patel

From: Anup Patel <[email protected]>

This patch enables Cadence MACB ethernet driver for QEMU RISC-V emulation by implying MACB, MII, RGMII and NET_RANDOM_ETHADDR on BOARD_SPECIFIC_OPTIONS.

---
 board/emulation/qemu-riscv/Kconfig | 4 ++++
 1 file changed, 4 insertions(+)
board/emulation/qemu-riscv/Kconfig +4 -0
index 0d865acf10..5d9611bdc7 100644
@@ -34,5 +34,9 @@ config BOARD_SPECIFIC_OPTIONS # dummy
 	imply BOARD_LATE_INIT
 	imply OF_BOARD_SETUP
 	imply SIFIVE_SERIAL
+	imply MACB
+	imply RGMII
+	imply MII
+	imply NET_RANDOM_ETHADDR
 
 endif
Signature · 1 line
2.17.1
#9 lore raw

PATCH 3/3 riscv: qemu: Imply MACB ethernet for emulation

Quoted 12 lines · Anup Patel

From: Anup Patel <[email protected]>

This patch enables Cadence MACB ethernet driver for QEMU RISC-V emulation by implying MACB, MII, RGMII and NET_RANDOM_ETHADDR on BOARD_SPECIFIC_OPTIONS.

---
 board/emulation/qemu-riscv/Kconfig | 4 ++++
 1 file changed, 4 insertions(+)
#10 lore raw

cover Ethernet support for QEMU sifive_u machine

In reply to Anup Patel

Hi Anup,

Quoted 6 lines · Anup Patel

This patchset enables Cadance MACB ethernet driver for QEMU sifive_u machine. The Cadance MACB ethernet driver works fine for QEMU sifive_u machince in both M-mode and S-mode with some minor fixes.

Quoted 9 lines

The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 9deb8d2fcd13d4a40a4e63c396fe4376af46efac

To try on QEMU, please ensure following patches are applied to QEMU sources:
https://patchwork.kernel.org/patch/10729579/
https://patchwork.kernel.org/patch/10729581/

What "-device " parameter should I tell QEMU to instantiate the MACB? "-device ?" does not give me anything that looks like MACB. Without a proper "-device " parameter, I can boot U-Boot on QEMU sifive_u and see U-Boot driver is probed, but a simple 'ping' test does not work.

Quoted 5 lines

Anup Patel (3):
riscv: Add asm/dma-mapping.h for DMA mappings
net: macb: Fix clk API usage for RISC-V systems
riscv: qemu: Imply MACB ethernet for emulation

Quoted 7 lines
 arch/riscv/include/asm/dma-mapping.h | 37 ++++++++++++++++++++++++++++
 board/emulation/qemu-riscv/Kconfig   |  4 +++
 drivers/net/macb.c                   |  4 ++-
 3 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 arch/riscv/include/asm/dma-mapping.h

--

Regards,
Bin

author
#11 lore raw

cover Ethernet support for QEMU sifive_u machine

Quoted 20 lines · Bin Meng

Hi Anup,

Quoted 6 lines · Anup Patel

This patchset enables Cadance MACB ethernet driver for QEMU sifive_u machine. The Cadance MACB ethernet driver works fine for QEMU sifive_u machince in both M-mode and S-mode with some minor fixes.

Quoted 9 lines

The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 9deb8d2fcd13d4a40a4e63c396fe4376af46efac

To try on QEMU, please ensure following patches are applied to QEMU sources:
https://patchwork.kernel.org/patch/10729579/
https://patchwork.kernel.org/patch/10729581/

Quoted 4 lines

What "-device " parameter should I tell QEMU to instantiate the MACB? "-device ?" does not give me anything that looks like MACB. Without a proper "-device " parameter, I can boot U-Boot on QEMU sifive_u and see U-Boot driver is probed, but a simple 'ping' test does not work.

Try the following:

# setenv ipaddr 10.0.2.1
# ping 10.0.2.2

The above works for me on QEMU.

Regards,
Anup

#12 lore raw

cover Ethernet support for QEMU sifive_u machine

Hi Anup,

Quoted 22 lines · Anup Patel
Quoted 20 lines · Bin Meng

Hi Anup,

Quoted 15 lines · Anup Patel

This patchset enables Cadance MACB ethernet driver for QEMU sifive_u machine. The Cadance MACB ethernet driver works fine for QEMU sifive_u machince in both M-mode and S-mode with some minor fixes.

The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 9deb8d2fcd13d4a40a4e63c396fe4376af46efac

To try on QEMU, please ensure following patches are applied to QEMU sources:
https://patchwork.kernel.org/patch/10729579/
https://patchwork.kernel.org/patch/10729581/

Quoted 9 lines
Quoted 4 lines

What "-device " parameter should I tell QEMU to instantiate the MACB? "-device ?" does not give me anything that looks like MACB. Without a proper "-device " parameter, I can boot U-Boot on QEMU sifive_u and see U-Boot driver is probed, but a simple 'ping' test does not work.

Try the following:

# setenv ipaddr 10.0.2.1
# ping 10.0.2.2

Yes, I have set up all the required network parameters.

Quoted 1 line

The above works for me on QEMU.

My understanding is that we need enable QEMU network via "-netdev " (either usr, or tap), with a corresponding "-device". I don't know how to set it up. What's your command line to test this?

Regards,
Bin

author
#13 lore raw

cover Ethernet support for QEMU sifive_u machine

Quoted 36 lines · Bin Meng

Hi Anup,

Quoted 22 lines · Anup Patel
Quoted 20 lines · Bin Meng

Hi Anup,

Quoted 15 lines · Anup Patel

This patchset enables Cadance MACB ethernet driver for QEMU sifive_u machine. The Cadance MACB ethernet driver works fine for QEMU sifive_u machince in both M-mode and S-mode with some minor fixes.

The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 9deb8d2fcd13d4a40a4e63c396fe4376af46efac

To try on QEMU, please ensure following patches are applied to QEMU sources:
https://patchwork.kernel.org/patch/10729579/
https://patchwork.kernel.org/patch/10729581/

Quoted 9 lines
Quoted 4 lines

What "-device " parameter should I tell QEMU to instantiate the MACB? "-device ?" does not give me anything that looks like MACB. Without a proper "-device " parameter, I can boot U-Boot on QEMU sifive_u and see U-Boot driver is probed, but a simple 'ping' test does not work.

Try the following:

# setenv ipaddr 10.0.2.1
# ping 10.0.2.2
Quoted 8 lines

Yes, I have set up all the required network parameters.

Quoted 1 line

The above works for me on QEMU.

My understanding is that we need enable QEMU network via "-netdev " (either usr, or tap), with a corresponding "-device". I don't know how to set it up. What's your command line to test this?

"-netdev" or "-device" parameters are not mandatory. By default, virtual NICs are in NAT mode. The QEMU NAT gateway is at IP address 10.0.2.2. We can always ping the NAT gateway when virtual NIC is in NAT mode.

Here's how I compile for M-mode:
# ARCH=riscv
# CROSS_COMPILE=riscv64-unknown-linux-gnu-

# make qemu-riscv64_defconfig
# make

My U-boot log is as follows:

anup at anup-ubuntu64:~/Work/riscv-test/u-boot$ qemu-system-riscv64 -M sifive_u -m 256M -display none -serial stdio -kernel ./u-boot

U-Boot 2019.01-rc1-00948-ge6b3cdafd0 (Dec 19 2018 - 10:05:50 +0530)

CPU:   rv64imafdcsu
Model: ucbbar,spike-bare,qemu
DRAM:  256 MiB
In:    uart at 10013000
Out:   uart at 10013000
Err:   uart at 10013000

Net:
Warning: ethernet at 100900fc (eth0) using random MAC address - f6:1f:8c:13:83:c0
eth0: ethernet at 100900fc
Hit any key to stop autoboot: 0

Device 0: unknown device
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (2 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x82100000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (1 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x81000000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
=> ping 10.0.2.2
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
host 10.0.2.2 is alive
=>
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
host 10.0.2.2 is alive
=> qemu-system-riscv64: terminating on signal 2

Regards,
Anup

#14 lore raw

cover Ethernet support for QEMU sifive_u machine

Hi Anup,

Quoted 103 lines · Anup Patel
Quoted 36 lines · Bin Meng

Hi Anup,

Quoted 22 lines · Anup Patel
Quoted 20 lines · Bin Meng

Hi Anup,

Quoted 15 lines · Anup Patel

This patchset enables Cadance MACB ethernet driver for QEMU sifive_u machine. The Cadance MACB ethernet driver works fine for QEMU sifive_u machince in both M-mode and S-mode with some minor fixes.

The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 9deb8d2fcd13d4a40a4e63c396fe4376af46efac

To try on QEMU, please ensure following patches are applied to QEMU sources:
https://patchwork.kernel.org/patch/10729579/
https://patchwork.kernel.org/patch/10729581/

Quoted 9 lines
Quoted 4 lines

What "-device " parameter should I tell QEMU to instantiate the MACB? "-device ?" does not give me anything that looks like MACB. Without a proper "-device " parameter, I can boot U-Boot on QEMU sifive_u and see U-Boot driver is probed, but a simple 'ping' test does not work.

Try the following:

# setenv ipaddr 10.0.2.1
# ping 10.0.2.2
Quoted 8 lines

Yes, I have set up all the required network parameters.

Quoted 1 line

The above works for me on QEMU.

My understanding is that we need enable QEMU network via "-netdev " (either usr, or tap), with a corresponding "-device". I don't know how to set it up. What's your command line to test this?

"-netdev" or "-device" parameters are not mandatory. By default, virtual NICs are in NAT mode. The QEMU NAT gateway is at IP address 10.0.2.2. We can always ping the NAT gateway when virtual NIC is in NAT mode.

Here's how I compile for M-mode:
# ARCH=riscv
# CROSS_COMPILE=riscv64-unknown-linux-gnu-

# make qemu-riscv64_defconfig
# make

My U-boot log is as follows:

anup at anup-ubuntu64:~/Work/riscv-test/u-boot$ qemu-system-riscv64 -M sifive_u -m 256M -display none -serial stdio -kernel ./u-boot

U-Boot 2019.01-rc1-00948-ge6b3cdafd0 (Dec 19 2018 - 10:05:50 +0530)

CPU:   rv64imafdcsu
Model: ucbbar,spike-bare,qemu
DRAM:  256 MiB
In:    uart at 10013000
Out:   uart at 10013000
Err:   uart at 10013000

Net:
Warning: ethernet at 100900fc (eth0) using random MAC address - f6:1f:8c:13:83:c0
eth0: ethernet at 100900fc
Hit any key to stop autoboot: 0

Device 0: unknown device
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (2 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x82100000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (1 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x81000000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
=> ping 10.0.2.2
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1)

Quoted 9 lines

Using ethernet at 100900fc device
host 10.0.2.2 is alive
=>
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
host 10.0.2.2 is alive
=> qemu-system-riscv64: terminating on signal 2

I have always been using "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot" to test U-Boot on qemu risc-v.
With above command, I can "ping 10.0.2.2" and get the exact the same result as yours.

However I wanted to connect the tap interface to the emulated network controller for testing, that's why I wanted to use "-device" and "-netdev", but I don't know which device string I need to tell QEMU. After a bit googleing I got the following page:
https://forums.xilinx.com/t5/Embedded-Processor-System-Design/Zynq-QEMU-Network-Issues/td-p/797050

From the page it looks that the device should be "-device cadence_gem", but when I pass it to QEMU I got:

qemu-system-riscv64: -device cadence_gem,netdev=net0: Parameter 'driver' expects pluggable device type

It looks cadence_gem is not a pluggable device. Any ideas?

Regards,
Bin

author
#15 lore raw

cover Ethernet support for QEMU sifive_u machine

Quoted 128 lines · Bin Meng

Hi Anup,

Quoted 103 lines · Anup Patel
Quoted 36 lines · Bin Meng

Hi Anup,

Quoted 22 lines · Anup Patel
Quoted 20 lines · Bin Meng

Hi Anup,

Quoted 15 lines · Anup Patel

This patchset enables Cadance MACB ethernet driver for QEMU sifive_u machine. The Cadance MACB ethernet driver works fine for QEMU sifive_u machince in both M-mode and S-mode with some minor fixes.

The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 9deb8d2fcd13d4a40a4e63c396fe4376af46efac

To try on QEMU, please ensure following patches are applied to QEMU sources:
https://patchwork.kernel.org/patch/10729579/
https://patchwork.kernel.org/patch/10729581/

Quoted 9 lines
Quoted 4 lines

What "-device " parameter should I tell QEMU to instantiate the MACB? "-device ?" does not give me anything that looks like MACB. Without a proper "-device " parameter, I can boot U-Boot on QEMU sifive_u and see U-Boot driver is probed, but a simple 'ping' test does not work.

Try the following:

# setenv ipaddr 10.0.2.1
# ping 10.0.2.2
Quoted 8 lines

Yes, I have set up all the required network parameters.

Quoted 1 line

The above works for me on QEMU.

My understanding is that we need enable QEMU network via "-netdev " (either usr, or tap), with a corresponding "-device". I don't know how to set it up. What's your command line to test this?

"-netdev" or "-device" parameters are not mandatory. By default, virtual NICs are in NAT mode. The QEMU NAT gateway is at IP address 10.0.2.2. We can always ping the NAT gateway when virtual NIC is in NAT mode.

Here's how I compile for M-mode:
# ARCH=riscv
# CROSS_COMPILE=riscv64-unknown-linux-gnu-

# make qemu-riscv64_defconfig
# make

My U-boot log is as follows:

anup at anup-ubuntu64:~/Work/riscv-test/u-boot$ qemu-system-riscv64 -M sifive_u -m 256M -display none -serial stdio -kernel ./u-boot

U-Boot 2019.01-rc1-00948-ge6b3cdafd0 (Dec 19 2018 - 10:05:50 +0530)

CPU:   rv64imafdcsu
Model: ucbbar,spike-bare,qemu
DRAM:  256 MiB
In:    uart at 10013000
Out:   uart at 10013000
Err:   uart at 10013000

Net:
Warning: ethernet at 100900fc (eth0) using random MAC address - f6:1f:8c:13:83:c0
eth0: ethernet at 100900fc
Hit any key to stop autoboot: 0

Device 0: unknown device
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (2 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x82100000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (1 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x81000000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
=> ping 10.0.2.2
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1)

Quoted 9 lines

Using ethernet at 100900fc device
host 10.0.2.2 is alive
=>
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
host 10.0.2.2 is alive
=> qemu-system-riscv64: terminating on signal 2

I have always been using "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot" to test U-Boot on qemu risc-v.
With above command, I can "ping 10.0.2.2" and get the exact the same result as yours.

However I wanted to connect the tap interface to the emulated network controller for testing, that's why I wanted to use "-device" and "-netdev", but I don't know which device string I need to tell QEMU. After a bit googleing I got the following page:
https://forums.xilinx.com/t5/Embedded-Processor-System-Design/Zynq-QEMU-Network-Issues/td-p/797050

Quoted 7 lines

From the page it looks that the device should be "-device cadence_gem", but when I pass it to QEMU I got:

qemu-system-riscv64: -device cadence_gem,netdev=net0: Parameter 'driver' expects pluggable device type

It looks cadence_gem is not a pluggable device. Any ideas?

I have mostly tried TAP devices with VirtIO-Net. I believe this could be some bug in Cadence GEM emulation of QEMU.

Regards,
Anup

#16 lore raw

cover Ethernet support for QEMU sifive_u machine

Hi Anup,

Quoted 133 lines · Anup Patel
Quoted 131 lines · Bin Meng

Hi Anup,

Quoted 103 lines · Anup Patel
Quoted 36 lines · Bin Meng

Hi Anup,

Quoted 22 lines · Anup Patel
Quoted 20 lines · Bin Meng

Hi Anup,

Quoted 15 lines · Anup Patel

This patchset enables Cadance MACB ethernet driver for QEMU sifive_u machine. The Cadance MACB ethernet driver works fine for QEMU sifive_u machince in both M-mode and S-mode with some minor fixes.

The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 9deb8d2fcd13d4a40a4e63c396fe4376af46efac

To try on QEMU, please ensure following patches are applied to QEMU sources:
https://patchwork.kernel.org/patch/10729579/
https://patchwork.kernel.org/patch/10729581/

Quoted 9 lines
Quoted 4 lines

What "-device " parameter should I tell QEMU to instantiate the MACB? "-device ?" does not give me anything that looks like MACB. Without a proper "-device " parameter, I can boot U-Boot on QEMU sifive_u and see U-Boot driver is probed, but a simple 'ping' test does not work.

Try the following:

# setenv ipaddr 10.0.2.1
# ping 10.0.2.2
Quoted 8 lines

Yes, I have set up all the required network parameters.

Quoted 1 line

The above works for me on QEMU.

My understanding is that we need enable QEMU network via "-netdev " (either usr, or tap), with a corresponding "-device". I don't know how to set it up. What's your command line to test this?

"-netdev" or "-device" parameters are not mandatory. By default, virtual NICs are in NAT mode. The QEMU NAT gateway is at IP address 10.0.2.2. We can always ping the NAT gateway when virtual NIC is in NAT mode.

Here's how I compile for M-mode:
# ARCH=riscv
# CROSS_COMPILE=riscv64-unknown-linux-gnu-

# make qemu-riscv64_defconfig
# make

My U-boot log is as follows:

anup at anup-ubuntu64:~/Work/riscv-test/u-boot$ qemu-system-riscv64 -M sifive_u -m 256M -display none -serial stdio -kernel ./u-boot

U-Boot 2019.01-rc1-00948-ge6b3cdafd0 (Dec 19 2018 - 10:05:50 +0530)

CPU:   rv64imafdcsu
Model: ucbbar,spike-bare,qemu
DRAM:  256 MiB
In:    uart at 10013000
Out:   uart at 10013000
Err:   uart at 10013000

Net:
Warning: ethernet at 100900fc (eth0) using random MAC address - f6:1f:8c:13:83:c0
eth0: ethernet at 100900fc
Hit any key to stop autoboot: 0

Device 0: unknown device
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (2 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x82100000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (1 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x81000000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
=> ping 10.0.2.2
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1)

Quoted 9 lines

Using ethernet at 100900fc device
host 10.0.2.2 is alive
=>
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
host 10.0.2.2 is alive
=> qemu-system-riscv64: terminating on signal 2

I have always been using "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot" to test U-Boot on qemu risc-v.
With above command, I can "ping 10.0.2.2" and get the exact the same result as yours.

However I wanted to connect the tap interface to the emulated network controller for testing, that's why I wanted to use "-device" and "-netdev", but I don't know which device string I need to tell QEMU. After a bit googleing I got the following page:
https://forums.xilinx.com/t5/Embedded-Processor-System-Design/Zynq-QEMU-Network-Issues/td-p/797050

From the page it looks that the device should be "-device cadence_gem", but when I pass it to QEMU I got:

Quoted 7 lines
Quoted 4 lines

qemu-system-riscv64: -device cadence_gem,netdev=net0: Parameter 'driver' expects pluggable device type

It looks cadence_gem is not a pluggable device. Any ideas?

I have mostly tried TAP devices with VirtIO-Net. I believe this could be some bug in Cadence GEM emulation of QEMU.

I managed to get tap interface connected to the cadence_gem controller. The QEMU command line is "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot -nic tap,model=cadence_gem"

A single "ping" works after I set related network environments in the shell. But "tftp" test fails. It looks the driver just time out.

=> tftp 84000000 bmeng/uImage.riscv
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
TFTP from server 10.10.0.100; our IP address is 10.10.0.108 Filename 'bmeng/uImage.riscv'.
Load address: 0x84000000
Loading: #T T #T T #T #T T #T #T T #
Retry count exceeded; starting again

Can you please take a look?

Regards,
Bin

#17 lore raw

cover Ethernet support for QEMU sifive_u machine

Hi Anup,

Quoted 162 lines · Bin Meng

Hi Anup,

Quoted 133 lines · Anup Patel
Quoted 131 lines · Bin Meng

Hi Anup,

Quoted 103 lines · Anup Patel
Quoted 36 lines · Bin Meng

Hi Anup,

Quoted 22 lines · Anup Patel
Quoted 20 lines · Bin Meng

Hi Anup,

Quoted 15 lines · Anup Patel

This patchset enables Cadance MACB ethernet driver for QEMU sifive_u machine. The Cadance MACB ethernet driver works fine for QEMU sifive_u machince in both M-mode and S-mode with some minor fixes.

The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 9deb8d2fcd13d4a40a4e63c396fe4376af46efac

To try on QEMU, please ensure following patches are applied to QEMU sources:
https://patchwork.kernel.org/patch/10729579/
https://patchwork.kernel.org/patch/10729581/

Quoted 9 lines
Quoted 4 lines

What "-device " parameter should I tell QEMU to instantiate the MACB? "-device ?" does not give me anything that looks like MACB. Without a proper "-device " parameter, I can boot U-Boot on QEMU sifive_u and see U-Boot driver is probed, but a simple 'ping' test does not work.

Try the following:

# setenv ipaddr 10.0.2.1
# ping 10.0.2.2
Quoted 8 lines

Yes, I have set up all the required network parameters.

Quoted 1 line

The above works for me on QEMU.

My understanding is that we need enable QEMU network via "-netdev " (either usr, or tap), with a corresponding "-device". I don't know how to set it up. What's your command line to test this?

"-netdev" or "-device" parameters are not mandatory. By default, virtual NICs are in NAT mode. The QEMU NAT gateway is at IP address 10.0.2.2. We can always ping the NAT gateway when virtual NIC is in NAT mode.

Here's how I compile for M-mode:
# ARCH=riscv
# CROSS_COMPILE=riscv64-unknown-linux-gnu-

# make qemu-riscv64_defconfig
# make

My U-boot log is as follows:

anup at anup-ubuntu64:~/Work/riscv-test/u-boot$ qemu-system-riscv64 -M sifive_u -m 256M -display none -serial stdio -kernel ./u-boot

U-Boot 2019.01-rc1-00948-ge6b3cdafd0 (Dec 19 2018 - 10:05:50 +0530)

CPU:   rv64imafdcsu
Model: ucbbar,spike-bare,qemu
DRAM:  256 MiB
In:    uart at 10013000
Out:   uart at 10013000
Err:   uart at 10013000

Net:
Warning: ethernet at 100900fc (eth0) using random MAC address - f6:1f:8c:13:83:c0
eth0: ethernet at 100900fc
Hit any key to stop autoboot: 0

Device 0: unknown device
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (2 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x82100000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (1 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x81000000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
=> ping 10.0.2.2
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1)

Quoted 9 lines

Using ethernet at 100900fc device
host 10.0.2.2 is alive
=>
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
host 10.0.2.2 is alive
=> qemu-system-riscv64: terminating on signal 2

I have always been using "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot" to test U-Boot on qemu risc-v.
With above command, I can "ping 10.0.2.2" and get the exact the same result as yours.

However I wanted to connect the tap interface to the emulated network controller for testing, that's why I wanted to use "-device" and "-netdev", but I don't know which device string I need to tell QEMU. After a bit googleing I got the following page:
https://forums.xilinx.com/t5/Embedded-Processor-System-Design/Zynq-QEMU-Network-Issues/td-p/797050

From the page it looks that the device should be "-device cadence_gem", but when I pass it to QEMU I got:

Quoted 7 lines
Quoted 4 lines

qemu-system-riscv64: -device cadence_gem,netdev=net0: Parameter 'driver' expects pluggable device type

It looks cadence_gem is not a pluggable device. Any ideas?

I have mostly tried TAP devices with VirtIO-Net. I believe this could be some bug in Cadence GEM emulation of QEMU.

I managed to get tap interface connected to the cadence_gem controller. The QEMU command line is "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot -nic tap,model=cadence_gem"

A single "ping" works after I set related network environments in the shell. But "tftp" test fails. It looks the driver just time out.

=> tftp 84000000 bmeng/uImage.riscv
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
TFTP from server 10.10.0.100; our IP address is 10.10.0.108 Filename 'bmeng/uImage.riscv'.
Load address: 0x84000000
Loading: #T T #T T #T #T T #T #T T #
Retry count exceeded; starting again

Quoted 1 line

Can you please take a look?

Any idea about the timeouts?

Regards,
Bin

author
#18 lore raw

cover Ethernet support for QEMU sifive_u machine

Quoted 166 lines · Bin Meng

Hi Anup,

Quoted 162 lines · Bin Meng

Hi Anup,

Quoted 133 lines · Anup Patel
Quoted 131 lines · Bin Meng

Hi Anup,

Quoted 103 lines · Anup Patel
Quoted 36 lines · Bin Meng

Hi Anup,

Quoted 22 lines · Anup Patel
Quoted 20 lines · Bin Meng

Hi Anup,

Quoted 15 lines · Anup Patel

This patchset enables Cadance MACB ethernet driver for QEMU sifive_u machine. The Cadance MACB ethernet driver works fine for QEMU sifive_u machince in both M-mode and S-mode with some minor fixes.

The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 9deb8d2fcd13d4a40a4e63c396fe4376af46efac

To try on QEMU, please ensure following patches are applied to QEMU sources:
https://patchwork.kernel.org/patch/10729579/
https://patchwork.kernel.org/patch/10729581/

Quoted 9 lines
Quoted 4 lines

What "-device " parameter should I tell QEMU to instantiate the MACB? "-device ?" does not give me anything that looks like MACB. Without a proper "-device " parameter, I can boot U-Boot on QEMU sifive_u and see U-Boot driver is probed, but a simple 'ping' test does not work.

Try the following:

# setenv ipaddr 10.0.2.1
# ping 10.0.2.2
Quoted 8 lines

Yes, I have set up all the required network parameters.

Quoted 1 line

The above works for me on QEMU.

My understanding is that we need enable QEMU network via "-netdev " (either usr, or tap), with a corresponding "-device". I don't know how to set it up. What's your command line to test this?

"-netdev" or "-device" parameters are not mandatory. By default, virtual NICs are in NAT mode. The QEMU NAT gateway is at IP address 10.0.2.2. We can always ping the NAT gateway when virtual NIC is in NAT mode.

Here's how I compile for M-mode:
# ARCH=riscv
# CROSS_COMPILE=riscv64-unknown-linux-gnu-

# make qemu-riscv64_defconfig
# make

My U-boot log is as follows:

anup at anup-ubuntu64:~/Work/riscv-test/u-boot$ qemu-system-riscv64 -M sifive_u -m 256M -display none -serial stdio -kernel ./u-boot

U-Boot 2019.01-rc1-00948-ge6b3cdafd0 (Dec 19 2018 - 10:05:50 +0530)

CPU:   rv64imafdcsu
Model: ucbbar,spike-bare,qemu
DRAM:  256 MiB
In:    uart at 10013000
Out:   uart at 10013000
Err:   uart at 10013000

Net:
Warning: ethernet at 100900fc (eth0) using random MAC address - f6:1f:8c:13:83:c0
eth0: ethernet at 100900fc
Hit any key to stop autoboot: 0

Device 0: unknown device
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (2 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x82100000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (1 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x81000000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
=> ping 10.0.2.2
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1)

Quoted 9 lines

Using ethernet at 100900fc device
host 10.0.2.2 is alive
=>
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
host 10.0.2.2 is alive
=> qemu-system-riscv64: terminating on signal 2

I have always been using "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot" to test U-Boot on qemu risc-v.
With above command, I can "ping 10.0.2.2" and get the exact the same result as yours.

However I wanted to connect the tap interface to the emulated network controller for testing, that's why I wanted to use "-device" and "-netdev", but I don't know which device string I need to tell QEMU. After a bit googleing I got the following page:
https://forums.xilinx.com/t5/Embedded-Processor-System-Design/Zynq-QEMU-Network-Issues/td-p/797050

From the page it looks that the device should be "-device cadence_gem", but when I pass it to QEMU I got:

Quoted 7 lines
Quoted 4 lines

qemu-system-riscv64: -device cadence_gem,netdev=net0: Parameter 'driver' expects pluggable device type

It looks cadence_gem is not a pluggable device. Any ideas?

I have mostly tried TAP devices with VirtIO-Net. I believe this could be some bug in Cadence GEM emulation of QEMU.

I managed to get tap interface connected to the cadence_gem controller. The QEMU command line is "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot -nic tap,model=cadence_gem"

A single "ping" works after I set related network environments in the shell. But "tftp" test fails. It looks the driver just time out.

=> tftp 84000000 bmeng/uImage.riscv
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
TFTP from server 10.10.0.100; our IP address is 10.10.0.108 Filename 'bmeng/uImage.riscv'.
Load address: 0x84000000
Loading: #T T #T T #T #T T #T #T T #
Retry count exceeded; starting again

Quoted 3 lines
Quoted 1 line

Can you please take a look?

Any idea about the timeouts?

Sorry, I got busy with other stuff.

I think this is specific to QEMU environment. The ethernet driver also few udelay calls which can further slow things down.

From your log it seems that, it is working functionally but you are seeing too many timeouts. Try playing with "TIMEOUT" or "TIMEOUT_COUNT" in net/tftp.c

You can also try same thing over VirtIO net of QEMU virt machine.

Regards,
Anup

#19 lore raw

cover Ethernet support for QEMU sifive_u machine

Hi Anup,

Quoted 172 lines · Anup Patel
Quoted 166 lines · Bin Meng

Hi Anup,

Quoted 162 lines · Bin Meng

Hi Anup,

Quoted 133 lines · Anup Patel
Quoted 131 lines · Bin Meng

Hi Anup,

Quoted 103 lines · Anup Patel
Quoted 36 lines · Bin Meng

Hi Anup,

Quoted 22 lines · Anup Patel
Quoted 20 lines · Bin Meng

Hi Anup,

Quoted 15 lines · Anup Patel

This patchset enables Cadance MACB ethernet driver for QEMU sifive_u machine. The Cadance MACB ethernet driver works fine for QEMU sifive_u machince in both M-mode and S-mode with some minor fixes.

The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 9deb8d2fcd13d4a40a4e63c396fe4376af46efac

To try on QEMU, please ensure following patches are applied to QEMU sources:
https://patchwork.kernel.org/patch/10729579/
https://patchwork.kernel.org/patch/10729581/

Quoted 9 lines
Quoted 4 lines

What "-device " parameter should I tell QEMU to instantiate the MACB? "-device ?" does not give me anything that looks like MACB. Without a proper "-device " parameter, I can boot U-Boot on QEMU sifive_u and see U-Boot driver is probed, but a simple 'ping' test does not work.

Try the following:

# setenv ipaddr 10.0.2.1
# ping 10.0.2.2
Quoted 8 lines

Yes, I have set up all the required network parameters.

Quoted 1 line

The above works for me on QEMU.

My understanding is that we need enable QEMU network via "-netdev " (either usr, or tap), with a corresponding "-device". I don't know how to set it up. What's your command line to test this?

"-netdev" or "-device" parameters are not mandatory. By default, virtual NICs are in NAT mode. The QEMU NAT gateway is at IP address 10.0.2.2. We can always ping the NAT gateway when virtual NIC is in NAT mode.

Here's how I compile for M-mode:
# ARCH=riscv
# CROSS_COMPILE=riscv64-unknown-linux-gnu-

# make qemu-riscv64_defconfig
# make

My U-boot log is as follows:

anup at anup-ubuntu64:~/Work/riscv-test/u-boot$ qemu-system-riscv64 -M sifive_u -m 256M -display none -serial stdio -kernel ./u-boot

U-Boot 2019.01-rc1-00948-ge6b3cdafd0 (Dec 19 2018 - 10:05:50 +0530)

CPU:   rv64imafdcsu
Model: ucbbar,spike-bare,qemu
DRAM:  256 MiB
In:    uart at 10013000
Out:   uart at 10013000
Err:   uart at 10013000

Net:
Warning: ethernet at 100900fc (eth0) using random MAC address - f6:1f:8c:13:83:c0
eth0: ethernet at 100900fc
Hit any key to stop autoboot: 0

Device 0: unknown device
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (2 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x82100000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (1 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x81000000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
=> ping 10.0.2.2
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1)

Quoted 9 lines

Using ethernet at 100900fc device
host 10.0.2.2 is alive
=>
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
host 10.0.2.2 is alive
=> qemu-system-riscv64: terminating on signal 2

I have always been using "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot" to test U-Boot on qemu risc-v.
With above command, I can "ping 10.0.2.2" and get the exact the same result as yours.

However I wanted to connect the tap interface to the emulated network controller for testing, that's why I wanted to use "-device" and "-netdev", but I don't know which device string I need to tell QEMU. After a bit googleing I got the following page:
https://forums.xilinx.com/t5/Embedded-Processor-System-Design/Zynq-QEMU-Network-Issues/td-p/797050

From the page it looks that the device should be "-device cadence_gem", but when I pass it to QEMU I got:

Quoted 7 lines
Quoted 4 lines

qemu-system-riscv64: -device cadence_gem,netdev=net0: Parameter 'driver' expects pluggable device type

It looks cadence_gem is not a pluggable device. Any ideas?

I have mostly tried TAP devices with VirtIO-Net. I believe this could be some bug in Cadence GEM emulation of QEMU.

I managed to get tap interface connected to the cadence_gem controller. The QEMU command line is "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot -nic tap,model=cadence_gem"

A single "ping" works after I set related network environments in the shell. But "tftp" test fails. It looks the driver just time out.

=> tftp 84000000 bmeng/uImage.riscv
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
TFTP from server 10.10.0.100; our IP address is 10.10.0.108 Filename 'bmeng/uImage.riscv'.
Load address: 0x84000000
Loading: #T T #T T #T #T T #T #T T #
Retry count exceeded; starting again

Quoted 3 lines
Quoted 1 line

Can you please take a look?

Any idea about the timeouts?

Quoted 9 lines

Sorry, I got busy with other stuff.

I think this is specific to QEMU environment. The ethernet driver also few udelay calls which can further slow things down.

From your log it seems that, it is working functionally but you are seeing too many timeouts. Try playing with "TIMEOUT" or "TIMEOUT_COUNT" in net/tftp.c

I suspect there are some issues with the MACB driver to be used with RISC-V.

Quoted 1 line

You can also try same thing over VirtIO net of QEMU virt machine.

The default same settings with VirtIO net interface works like a charm.

Regards,
Bin

author
#20 lore raw

cover Ethernet support for QEMU sifive_u machine

Quoted 181 lines · Bin Meng

Hi Anup,

Quoted 177 lines · Anup Patel
Quoted 166 lines · Bin Meng

Hi Anup,

Quoted 162 lines · Bin Meng

Hi Anup,

Quoted 133 lines · Anup Patel
Quoted 131 lines · Bin Meng

Hi Anup,

Quoted 103 lines · Anup Patel
Quoted 36 lines · Bin Meng

Hi Anup,

Quoted 22 lines · Anup Patel
Quoted 20 lines · Bin Meng

Hi Anup,

Quoted 15 lines · Anup Patel

This patchset enables Cadance MACB ethernet driver for QEMU sifive_u machine. The Cadance MACB ethernet driver works fine for QEMU sifive_u machince in both M-mode and S-mode with some minor fixes.

The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 9deb8d2fcd13d4a40a4e63c396fe4376af46efac

To try on QEMU, please ensure following patches are applied to QEMU sources:
https://patchwork.kernel.org/patch/10729579/
https://patchwork.kernel.org/patch/10729581/

Quoted 9 lines
Quoted 4 lines

What "-device " parameter should I tell QEMU to instantiate the MACB? "-device ?" does not give me anything that looks like MACB. Without a proper "-device " parameter, I can boot U-Boot on QEMU sifive_u and see U-Boot driver is probed, but a simple 'ping' test does not work.

Try the following:

# setenv ipaddr 10.0.2.1
# ping 10.0.2.2
Quoted 8 lines

Yes, I have set up all the required network parameters.

Quoted 1 line

The above works for me on QEMU.

My understanding is that we need enable QEMU network via "-netdev " (either usr, or tap), with a corresponding "-device". I don't know how to set it up. What's your command line to test this?

"-netdev" or "-device" parameters are not mandatory. By default, virtual NICs are in NAT mode. The QEMU NAT gateway is at IP address 10.0.2.2. We can always ping the NAT gateway when virtual NIC is in NAT mode.

Here's how I compile for M-mode:
# ARCH=riscv
# CROSS_COMPILE=riscv64-unknown-linux-gnu-

# make qemu-riscv64_defconfig
# make

My U-boot log is as follows:

anup at anup-ubuntu64:~/Work/riscv-test/u-boot$ qemu-system-riscv64 -M sifive_u -m 256M -display none -serial stdio -kernel ./u-boot

U-Boot 2019.01-rc1-00948-ge6b3cdafd0 (Dec 19 2018 - 10:05:50 +0530)

CPU:   rv64imafdcsu
Model: ucbbar,spike-bare,qemu
DRAM:  256 MiB
In:    uart at 10013000
Out:   uart at 10013000
Err:   uart at 10013000

Net:
Warning: ethernet at 100900fc (eth0) using random MAC address - f6:1f:8c:13:83:c0
eth0: ethernet at 100900fc
Hit any key to stop autoboot: 0

Device 0: unknown device
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (2 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x82100000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (1 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x81000000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
=> ping 10.0.2.2
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1)

Quoted 9 lines

Using ethernet at 100900fc device
host 10.0.2.2 is alive
=>
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
host 10.0.2.2 is alive
=> qemu-system-riscv64: terminating on signal 2

I have always been using "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot" to test U-Boot on qemu risc-v.
With above command, I can "ping 10.0.2.2" and get the exact the same result as yours.

However I wanted to connect the tap interface to the emulated network controller for testing, that's why I wanted to use "-device" and "-netdev", but I don't know which device string I need to tell QEMU. After a bit googleing I got the following page:
https://forums.xilinx.com/t5/Embedded-Processor-System-Design/Zynq-QEMU-Network-Issues/td-p/797050

From the page it looks that the device should be "-device cadence_gem", but when I pass it to QEMU I got:

Quoted 7 lines
Quoted 4 lines

qemu-system-riscv64: -device cadence_gem,netdev=net0: Parameter 'driver' expects pluggable device type

It looks cadence_gem is not a pluggable device. Any ideas?

I have mostly tried TAP devices with VirtIO-Net. I believe this could be some bug in Cadence GEM emulation of QEMU.

I managed to get tap interface connected to the cadence_gem controller. The QEMU command line is "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot -nic tap,model=cadence_gem"

A single "ping" works after I set related network environments in the shell. But "tftp" test fails. It looks the driver just time out.

=> tftp 84000000 bmeng/uImage.riscv
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
TFTP from server 10.10.0.100; our IP address is 10.10.0.108 Filename 'bmeng/uImage.riscv'.
Load address: 0x84000000
Loading: #T T #T T #T #T T #T #T T #
Retry count exceeded; starting again

Quoted 3 lines
Quoted 1 line

Can you please take a look?

Any idea about the timeouts?

Sorry, I got busy with other stuff.

I think this is specific to QEMU environment. The ethernet driver also few udelay calls which can further slow things down.

Quoted 6 lines
Quoted 4 lines

From your log it seems that, it is working functionally but you are seeing too many timeouts. Try playing with "TIMEOUT" or "TIMEOUT_COUNT" in net/tftp.c

I suspect there are some issues with the MACB driver to be used with RISC-V.

Unlikely because Microsemi folks seems to use it on HiFive Unleashed board.
https://github.com/Microsemi-SoC-IP/HiFive_U-Boot

We are still debugging on HiFive Unleashed board so stay tuned for more patches.

Regards,
Anup

#21 lore raw

cover Ethernet support for QEMU sifive_u machine

Hi Anup,

Quoted 188 lines · Anup Patel
Quoted 186 lines · Bin Meng

Hi Anup,

Quoted 181 lines · Anup Patel
Quoted 166 lines · Bin Meng

Hi Anup,

Quoted 162 lines · Bin Meng

Hi Anup,

Quoted 133 lines · Anup Patel
Quoted 131 lines · Bin Meng

Hi Anup,

Quoted 103 lines · Anup Patel
Quoted 36 lines · Bin Meng

Hi Anup,

Quoted 22 lines · Anup Patel
Quoted 20 lines · Bin Meng

Hi Anup,

Quoted 15 lines · Anup Patel

This patchset enables Cadance MACB ethernet driver for QEMU sifive_u machine. The Cadance MACB ethernet driver works fine for QEMU sifive_u machince in both M-mode and S-mode with some minor fixes.

The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 9deb8d2fcd13d4a40a4e63c396fe4376af46efac

To try on QEMU, please ensure following patches are applied to QEMU sources:
https://patchwork.kernel.org/patch/10729579/
https://patchwork.kernel.org/patch/10729581/

Quoted 9 lines
Quoted 4 lines

What "-device " parameter should I tell QEMU to instantiate the MACB? "-device ?" does not give me anything that looks like MACB. Without a proper "-device " parameter, I can boot U-Boot on QEMU sifive_u and see U-Boot driver is probed, but a simple 'ping' test does not work.

Try the following:

# setenv ipaddr 10.0.2.1
# ping 10.0.2.2
Quoted 8 lines

Yes, I have set up all the required network parameters.

Quoted 1 line

The above works for me on QEMU.

My understanding is that we need enable QEMU network via "-netdev " (either usr, or tap), with a corresponding "-device". I don't know how to set it up. What's your command line to test this?

"-netdev" or "-device" parameters are not mandatory. By default, virtual NICs are in NAT mode. The QEMU NAT gateway is at IP address 10.0.2.2. We can always ping the NAT gateway when virtual NIC is in NAT mode.

Here's how I compile for M-mode:
# ARCH=riscv
# CROSS_COMPILE=riscv64-unknown-linux-gnu-

# make qemu-riscv64_defconfig
# make

My U-boot log is as follows:

anup at anup-ubuntu64:~/Work/riscv-test/u-boot$ qemu-system-riscv64 -M sifive_u -m 256M -display none -serial stdio -kernel ./u-boot

U-Boot 2019.01-rc1-00948-ge6b3cdafd0 (Dec 19 2018 - 10:05:50 +0530)

CPU:   rv64imafdcsu
Model: ucbbar,spike-bare,qemu
DRAM:  256 MiB
In:    uart at 10013000
Out:   uart at 10013000
Err:   uart at 10013000

Net:
Warning: ethernet at 100900fc (eth0) using random MAC address - f6:1f:8c:13:83:c0
eth0: ethernet at 100900fc
Hit any key to stop autoboot: 0

Device 0: unknown device
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (2 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x82100000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (1 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x81000000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
=> ping 10.0.2.2
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1)

Quoted 9 lines

Using ethernet at 100900fc device
host 10.0.2.2 is alive
=>
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
host 10.0.2.2 is alive
=> qemu-system-riscv64: terminating on signal 2

I have always been using "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot" to test U-Boot on qemu risc-v.
With above command, I can "ping 10.0.2.2" and get the exact the same result as yours.

However I wanted to connect the tap interface to the emulated network controller for testing, that's why I wanted to use "-device" and "-netdev", but I don't know which device string I need to tell QEMU. After a bit googleing I got the following page:
https://forums.xilinx.com/t5/Embedded-Processor-System-Design/Zynq-QEMU-Network-Issues/td-p/797050

From the page it looks that the device should be "-device cadence_gem", but when I pass it to QEMU I got:

Quoted 7 lines
Quoted 4 lines

qemu-system-riscv64: -device cadence_gem,netdev=net0: Parameter 'driver' expects pluggable device type

It looks cadence_gem is not a pluggable device. Any ideas?

I have mostly tried TAP devices with VirtIO-Net. I believe this could be some bug in Cadence GEM emulation of QEMU.

I managed to get tap interface connected to the cadence_gem controller. The QEMU command line is "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot -nic tap,model=cadence_gem"

A single "ping" works after I set related network environments in the shell. But "tftp" test fails. It looks the driver just time out.

=> tftp 84000000 bmeng/uImage.riscv
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
TFTP from server 10.10.0.100; our IP address is 10.10.0.108 Filename 'bmeng/uImage.riscv'.
Load address: 0x84000000
Loading: #T T #T T #T #T T #T #T T #
Retry count exceeded; starting again

Quoted 3 lines
Quoted 1 line

Can you please take a look?

Any idea about the timeouts?

Sorry, I got busy with other stuff.

I think this is specific to QEMU environment. The ethernet driver also few udelay calls which can further slow things down.

From your log it seems that, it is working functionally but you are seeing too many timeouts. Try playing with "TIMEOUT" or "TIMEOUT_COUNT" in net/tftp.c

Quoted 5 lines
Quoted 1 line

I suspect there are some issues with the MACB driver to be used with RISC-V.

Unlikely because Microsemi folks seems to use it on HiFive Unleashed board.
https://github.com/Microsemi-SoC-IP/HiFive_U-Boot

It looks Microsemi's port is using the non-DM version of MACB driver while this series is using DM version. Something is wrong when working with QEMU's MACB controller.

Quoted 3 lines

We are still debugging on HiFive Unleashed board so stay tuned for more patches.

Regards,
Bin

author
#22 lore raw

cover Ethernet support for QEMU sifive_u machine

Quoted 194 lines · Bin Meng

Hi Anup,

Quoted 190 lines · Anup Patel
Quoted 187 lines · Bin Meng

Hi Anup,

Quoted 172 lines · Anup Patel
Quoted 166 lines · Bin Meng

Hi Anup,

Quoted 162 lines · Bin Meng

Hi Anup,

Quoted 133 lines · Anup Patel
Quoted 131 lines · Bin Meng

Hi Anup,

Quoted 103 lines · Anup Patel
Quoted 36 lines · Bin Meng

Hi Anup,

Quoted 22 lines · Anup Patel
Quoted 20 lines · Bin Meng

Hi Anup,

Quoted 15 lines · Anup Patel

This patchset enables Cadance MACB ethernet driver for
QEMU sifive_u machine. The Cadance MACB ethernet driver
works fine for QEMU sifive_u machince in both M-mode and
S-mode with some minor fixes.

The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id
9deb8d2fcd13d4a40a4e63c396fe4376af46efac

To try on QEMU, please ensure following patches are
applied to QEMU sources:
https://patchwork.kernel.org/patch/10729579/
https://patchwork.kernel.org/patch/10729581/

Quoted 9 lines
Quoted 4 lines

What "-device " parameter should I tell QEMU to instantiate the MACB? "-device ?" does not give me anything that looks like MACB. Without a proper "-device " parameter, I can boot U-Boot on QEMU sifive_u and see U-Boot driver is probed, but a simple 'ping' test does not work.

Try the following:

# setenv ipaddr 10.0.2.1
# ping 10.0.2.2
Quoted 8 lines

Yes, I have set up all the required network parameters.

Quoted 1 line

The above works for me on QEMU.

My understanding is that we need enable QEMU network via "-netdev " (either usr, or tap), with a corresponding "-device". I don't know how to set it up. What's your command line to test this?

"-netdev" or "-device" parameters are not mandatory. By default, virtual NICs are in NAT mode. The QEMU NAT gateway is at IP address 10.0.2.2. We can always ping the NAT gateway when virtual NIC is in NAT mode.

Here's how I compile for M-mode:
# ARCH=riscv
# CROSS_COMPILE=riscv64-unknown-linux-gnu-

# make qemu-riscv64_defconfig
# make

My U-boot log is as follows:

anup at anup-ubuntu64:~/Work/riscv-test/u-boot$ qemu-system-riscv64 -M sifive_u -m 256M -display none -serial stdio -kernel ./u-boot

U-Boot 2019.01-rc1-00948-ge6b3cdafd0 (Dec 19 2018 - 10:05:50 +0530)

CPU:   rv64imafdcsu
Model: ucbbar,spike-bare,qemu
DRAM:  256 MiB
In:    uart at 10013000
Out:   uart at 10013000
Err:   uart at 10013000

Net:
Warning: ethernet at 100900fc (eth0) using random MAC address - f6:1f:8c:13:83:c0
eth0: ethernet at 100900fc
Hit any key to stop autoboot: 0

Device 0: unknown device
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (2 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x82100000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (1 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x81000000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
=> ping 10.0.2.2
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1)

Quoted 9 lines

Using ethernet at 100900fc device
host 10.0.2.2 is alive
=>
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
host 10.0.2.2 is alive
=> qemu-system-riscv64: terminating on signal 2

I have always been using "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot" to test U-Boot on qemu risc-v.
With above command, I can "ping 10.0.2.2" and get the exact the same result as yours.

However I wanted to connect the tap interface to the emulated network controller for testing, that's why I wanted to use "-device" and "-netdev", but I don't know which device string I need to tell QEMU. After a bit googleing I got the following page:
https://forums.xilinx.com/t5/Embedded-Processor-System-Design/Zynq-QEMU-Network-Issues/td-p/797050

From the page it looks that the device should be "-device cadence_gem", but when I pass it to QEMU I got:

Quoted 7 lines
Quoted 4 lines

qemu-system-riscv64: -device cadence_gem,netdev=net0: Parameter 'driver' expects pluggable device type

It looks cadence_gem is not a pluggable device. Any ideas?

I have mostly tried TAP devices with VirtIO-Net. I believe this could be some bug in Cadence GEM emulation of QEMU.

I managed to get tap interface connected to the cadence_gem controller. The QEMU command line is "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot -nic tap,model=cadence_gem"

A single "ping" works after I set related network environments in the shell. But "tftp" test fails. It looks the driver just time out.

=> tftp 84000000 bmeng/uImage.riscv
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
TFTP from server 10.10.0.100; our IP address is 10.10.0.108 Filename 'bmeng/uImage.riscv'.
Load address: 0x84000000
Loading: #T T #T T #T #T T #T #T T #
Retry count exceeded; starting again

Quoted 3 lines
Quoted 1 line

Can you please take a look?

Any idea about the timeouts?

Quoted 9 lines

Sorry, I got busy with other stuff.

I think this is specific to QEMU environment. The ethernet driver also few udelay calls which can further slow things down.

From your log it seems that, it is working functionally but you are seeing too many timeouts. Try playing with "TIMEOUT" or "TIMEOUT_COUNT" in net/tftp.c

I suspect there are some issues with the MACB driver to be used with RISC-V.

Quoted 7 lines
Quoted 3 lines

Unlikely because Microsemi folks seems to use it on HiFive Unleashed board.
https://github.com/Microsemi-SoC-IP/HiFive_U-Boot

It looks Microsemi's port is using the non-DM version of MACB driver while this series is using DM version. Something is wrong when working with QEMU's MACB controller.

Yes, could be some issue with QEMU MACB emulation.

Anyway, we have U-Boot booting on Unleashed board with few fixes in SiFive UART driver (Atish will send-out the fixes after more testing).

This means same u-boot.bin boots on QEMU virt, QEMU sifive_u and HiFive unleashed. We are on path towards having unified u-boot.bin for multiple targets.

Regards,
Anup

#23 lore raw

cover Ethernet support for QEMU sifive_u machine

Hi Anup,

Quoted 206 lines · Anup Patel
Quoted 194 lines · Bin Meng

Hi Anup,

Quoted 190 lines · Anup Patel
Quoted 187 lines · Bin Meng

Hi Anup,

Quoted 172 lines · Anup Patel
Quoted 166 lines · Bin Meng

Hi Anup,

Quoted 162 lines · Bin Meng

Hi Anup,

Quoted 133 lines · Anup Patel
Quoted 131 lines · Bin Meng

Hi Anup,

Quoted 103 lines · Anup Patel
Quoted 36 lines · Bin Meng

Hi Anup,

Quoted 22 lines · Anup Patel
Quoted 20 lines · Bin Meng

Hi Anup,

On Mon, Dec 17, 2018 at 7:51 PM Anup Patel <[email protected]> wrote:

This patchset enables Cadance MACB ethernet driver for
QEMU sifive_u machine. The Cadance MACB ethernet driver
works fine for QEMU sifive_u machince in both M-mode and
S-mode with some minor fixes.

The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id
9deb8d2fcd13d4a40a4e63c396fe4376af46efac

To try on QEMU, please ensure following patches are
applied to QEMU sources:
https://patchwork.kernel.org/patch/10729579/
https://patchwork.kernel.org/patch/10729581/

Quoted 9 lines
Quoted 4 lines

What "-device " parameter should I tell QEMU to instantiate the MACB?
"-device ?" does not give me anything that looks like MACB. Without a
proper "-device " parameter, I can boot U-Boot on QEMU sifive_u and
see U-Boot driver is probed, but a simple 'ping' test does not work.

Try the following:

# setenv ipaddr 10.0.2.1
# ping 10.0.2.2
Quoted 8 lines

Yes, I have set up all the required network parameters.

Quoted 1 line

The above works for me on QEMU.

My understanding is that we need enable QEMU network via "-netdev " (either usr, or tap), with a corresponding "-device". I don't know how to set it up. What's your command line to test this?

"-netdev" or "-device" parameters are not mandatory. By default, virtual NICs are in NAT mode. The QEMU NAT gateway is at IP address 10.0.2.2. We can always ping the NAT gateway when virtual NIC is in NAT mode.

Here's how I compile for M-mode:
# ARCH=riscv
# CROSS_COMPILE=riscv64-unknown-linux-gnu-

# make qemu-riscv64_defconfig
# make

My U-boot log is as follows:

anup at anup-ubuntu64:~/Work/riscv-test/u-boot$ qemu-system-riscv64 -M sifive_u -m 256M -display none -serial stdio -kernel ./u-boot

U-Boot 2019.01-rc1-00948-ge6b3cdafd0 (Dec 19 2018 - 10:05:50 +0530)

CPU:   rv64imafdcsu
Model: ucbbar,spike-bare,qemu
DRAM:  256 MiB
In:    uart at 10013000
Out:   uart at 10013000
Err:   uart at 10013000

Net:
Warning: ethernet at 100900fc (eth0) using random MAC address - f6:1f:8c:13:83:c0
eth0: ethernet at 100900fc
Hit any key to stop autoboot: 0

Device 0: unknown device
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (2 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x82100000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (1 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x81000000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
=> ping 10.0.2.2
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1)

Quoted 9 lines

Using ethernet at 100900fc device
host 10.0.2.2 is alive
=>
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
host 10.0.2.2 is alive
=> qemu-system-riscv64: terminating on signal 2

I have always been using "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot" to test U-Boot on qemu risc-v.
With above command, I can "ping 10.0.2.2" and get the exact the same result as yours.

However I wanted to connect the tap interface to the emulated network controller for testing, that's why I wanted to use "-device" and "-netdev", but I don't know which device string I need to tell QEMU. After a bit googleing I got the following page:
https://forums.xilinx.com/t5/Embedded-Processor-System-Design/Zynq-QEMU-Network-Issues/td-p/797050

From the page it looks that the device should be "-device cadence_gem", but when I pass it to QEMU I got:

Quoted 7 lines
Quoted 4 lines

qemu-system-riscv64: -device cadence_gem,netdev=net0: Parameter 'driver' expects pluggable device type

It looks cadence_gem is not a pluggable device. Any ideas?

I have mostly tried TAP devices with VirtIO-Net. I believe this could be some bug in Cadence GEM emulation of QEMU.

I managed to get tap interface connected to the cadence_gem controller. The QEMU command line is "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot -nic tap,model=cadence_gem"

A single "ping" works after I set related network environments in the shell. But "tftp" test fails. It looks the driver just time out.

=> tftp 84000000 bmeng/uImage.riscv
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
TFTP from server 10.10.0.100; our IP address is 10.10.0.108 Filename 'bmeng/uImage.riscv'.
Load address: 0x84000000
Loading: #T T #T T #T #T T #T #T T #
Retry count exceeded; starting again

Quoted 3 lines
Quoted 1 line

Can you please take a look?

Any idea about the timeouts?

Quoted 9 lines

Sorry, I got busy with other stuff.

I think this is specific to QEMU environment. The ethernet driver also few udelay calls which can further slow things down.

From your log it seems that, it is working functionally but you are seeing too many timeouts. Try playing with "TIMEOUT" or "TIMEOUT_COUNT" in net/tftp.c

I suspect there are some issues with the MACB driver to be used with RISC-V.

Quoted 7 lines
Quoted 3 lines

Unlikely because Microsemi folks seems to use it on HiFive Unleashed board.
https://github.com/Microsemi-SoC-IP/HiFive_U-Boot

It looks Microsemi's port is using the non-DM version of MACB driver while this series is using DM version. Something is wrong when working with QEMU's MACB controller.

Yes, could be some issue with QEMU MACB emulation.

Quoted 7 lines

Anyway, we have U-Boot booting on Unleashed board with few fixes in SiFive UART driver (Atish will send-out the fixes after more testing).

This means same u-boot.bin boots on QEMU virt, QEMU sifive_u and HiFive unleashed. We are on path towards having unified u-boot.bin for multiple targets.

This is great! Once it's ready I can help the testing.

Regards,
Bin

author
#24 lore raw

cover Ethernet support for QEMU sifive_u machine

Quoted 214 lines · Bin Meng

Hi Anup,

Quoted 210 lines · Anup Patel
Quoted 194 lines · Bin Meng

Hi Anup,

Quoted 190 lines · Anup Patel
Quoted 187 lines · Bin Meng

Hi Anup,

Quoted 172 lines · Anup Patel
Quoted 166 lines · Bin Meng

Hi Anup,

Quoted 162 lines · Bin Meng

Hi Anup,

Quoted 133 lines · Anup Patel
Quoted 131 lines · Bin Meng

Hi Anup,

Quoted 103 lines · Anup Patel
Quoted 36 lines · Bin Meng

Hi Anup,

Quoted 31 lines · Anup Patel

On Tue, Dec 18, 2018 at 3:21 PM Bin Meng <[email protected]> wrote:

Hi Anup,

On Mon, Dec 17, 2018 at 7:51 PM Anup Patel <[email protected]> wrote:

This patchset enables Cadance MACB ethernet driver for
QEMU sifive_u machine. The Cadance MACB ethernet driver
works fine for QEMU sifive_u machince in both M-mode and
S-mode with some minor fixes.

The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id
9deb8d2fcd13d4a40a4e63c396fe4376af46efac

To try on QEMU, please ensure following patches are
applied to QEMU sources:
https://patchwork.kernel.org/patch/10729579/
https://patchwork.kernel.org/patch/10729581/

What "-device " parameter should I tell QEMU to instantiate the MACB?
"-device ?" does not give me anything that looks like MACB. Without a
proper "-device " parameter, I can boot U-Boot on QEMU sifive_u and
see U-Boot driver is probed, but a simple 'ping' test does not work.

Try the following:
# setenv ipaddr 10.0.2.1
# ping 10.0.2.2

Quoted 8 lines

Yes, I have set up all the required network parameters.

Quoted 1 line

The above works for me on QEMU.

My understanding is that we need enable QEMU network via "-netdev " (either usr, or tap), with a corresponding "-device". I don't know how to set it up. What's your command line to test this?

"-netdev" or "-device" parameters are not mandatory. By default, virtual NICs are in NAT mode. The QEMU NAT gateway is at IP address 10.0.2.2. We can always ping the NAT gateway when virtual NIC is in NAT mode.

Here's how I compile for M-mode:
# ARCH=riscv
# CROSS_COMPILE=riscv64-unknown-linux-gnu-

# make qemu-riscv64_defconfig
# make

My U-boot log is as follows:

anup at anup-ubuntu64:~/Work/riscv-test/u-boot$ qemu-system-riscv64 -M sifive_u -m 256M -display none -serial stdio -kernel ./u-boot

U-Boot 2019.01-rc1-00948-ge6b3cdafd0 (Dec 19 2018 - 10:05:50 +0530)

CPU:   rv64imafdcsu
Model: ucbbar,spike-bare,qemu
DRAM:  256 MiB
In:    uart at 10013000
Out:   uart at 10013000
Err:   uart at 10013000

Net:
Warning: ethernet at 100900fc (eth0) using random MAC address - f6:1f:8c:13:83:c0
eth0: ethernet at 100900fc
Hit any key to stop autoboot: 0

Device 0: unknown device
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (2 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x82100000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (1 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x81000000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
=> ping 10.0.2.2
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1)

Quoted 9 lines

Using ethernet at 100900fc device
host 10.0.2.2 is alive
=>
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
host 10.0.2.2 is alive
=> qemu-system-riscv64: terminating on signal 2

I have always been using "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot" to test U-Boot on qemu risc-v.
With above command, I can "ping 10.0.2.2" and get the exact the same result as yours.

However I wanted to connect the tap interface to the emulated network controller for testing, that's why I wanted to use "-device" and "-netdev", but I don't know which device string I need to tell QEMU. After a bit googleing I got the following page:
https://forums.xilinx.com/t5/Embedded-Processor-System-Design/Zynq-QEMU-Network-Issues/td-p/797050

From the page it looks that the device should be "-device cadence_gem", but when I pass it to QEMU I got:

Quoted 7 lines
Quoted 4 lines

qemu-system-riscv64: -device cadence_gem,netdev=net0: Parameter 'driver' expects pluggable device type

It looks cadence_gem is not a pluggable device. Any ideas?

I have mostly tried TAP devices with VirtIO-Net. I believe this could be some bug in Cadence GEM emulation of QEMU.

I managed to get tap interface connected to the cadence_gem controller. The QEMU command line is "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot -nic tap,model=cadence_gem"

A single "ping" works after I set related network environments in the shell. But "tftp" test fails. It looks the driver just time out.

=> tftp 84000000 bmeng/uImage.riscv
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
TFTP from server 10.10.0.100; our IP address is 10.10.0.108 Filename 'bmeng/uImage.riscv'.
Load address: 0x84000000
Loading: #T T #T T #T #T T #T #T T #
Retry count exceeded; starting again

Quoted 3 lines
Quoted 1 line

Can you please take a look?

Any idea about the timeouts?

Quoted 9 lines

Sorry, I got busy with other stuff.

I think this is specific to QEMU environment. The ethernet driver also few udelay calls which can further slow things down.

From your log it seems that, it is working functionally but you are seeing too many timeouts. Try playing with "TIMEOUT" or "TIMEOUT_COUNT" in net/tftp.c

I suspect there are some issues with the MACB driver to be used with RISC-V.

Quoted 7 lines
Quoted 3 lines

Unlikely because Microsemi folks seems to use it on HiFive Unleashed board.
https://github.com/Microsemi-SoC-IP/HiFive_U-Boot

It looks Microsemi's port is using the non-DM version of MACB driver while this series is using DM version. Something is wrong when working with QEMU's MACB controller.

Yes, could be some issue with QEMU MACB emulation.

Anyway, we have U-Boot booting on Unleashed board with few fixes in SiFive UART driver (Atish will send-out the fixes after more testing).

Quoted 5 lines
Quoted 3 lines

This means same u-boot.bin boots on QEMU virt, QEMU sifive_u and HiFive unleashed. We are on path towards having unified u-boot.bin for multiple targets.

This is great! Once it's ready I can help the testing.

Thanks in-advance.

I would suggest to get this series for U-Boot 2019.01. What say?

Regards,
Anup

#25 lore raw

cover Ethernet support for QEMU sifive_u machine

In reply to Bin Meng

Hi,

Quoted 162 lines · Bin Meng

Hi Anup,

Quoted 133 lines · Anup Patel
Quoted 131 lines · Bin Meng

Hi Anup,

Quoted 103 lines · Anup Patel
Quoted 36 lines · Bin Meng

Hi Anup,

Quoted 22 lines · Anup Patel
Quoted 20 lines · Bin Meng

Hi Anup,

Quoted 15 lines · Anup Patel

This patchset enables Cadance MACB ethernet driver for QEMU sifive_u machine. The Cadance MACB ethernet driver works fine for QEMU sifive_u machince in both M-mode and S-mode with some minor fixes.

The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 9deb8d2fcd13d4a40a4e63c396fe4376af46efac

To try on QEMU, please ensure following patches are applied to QEMU sources:
https://patchwork.kernel.org/patch/10729579/
https://patchwork.kernel.org/patch/10729581/

Quoted 9 lines
Quoted 4 lines

What "-device " parameter should I tell QEMU to instantiate the MACB? "-device ?" does not give me anything that looks like MACB. Without a proper "-device " parameter, I can boot U-Boot on QEMU sifive_u and see U-Boot driver is probed, but a simple 'ping' test does not work.

Try the following:

# setenv ipaddr 10.0.2.1
# ping 10.0.2.2
Quoted 8 lines

Yes, I have set up all the required network parameters.

Quoted 1 line

The above works for me on QEMU.

My understanding is that we need enable QEMU network via "-netdev " (either usr, or tap), with a corresponding "-device". I don't know how to set it up. What's your command line to test this?

"-netdev" or "-device" parameters are not mandatory. By default, virtual NICs are in NAT mode. The QEMU NAT gateway is at IP address 10.0.2.2. We can always ping the NAT gateway when virtual NIC is in NAT mode.

Here's how I compile for M-mode:
# ARCH=riscv
# CROSS_COMPILE=riscv64-unknown-linux-gnu-

# make qemu-riscv64_defconfig
# make

My U-boot log is as follows:

anup at anup-ubuntu64:~/Work/riscv-test/u-boot$ qemu-system-riscv64 -M sifive_u -m 256M -display none -serial stdio -kernel ./u-boot

U-Boot 2019.01-rc1-00948-ge6b3cdafd0 (Dec 19 2018 - 10:05:50 +0530)

CPU:   rv64imafdcsu
Model: ucbbar,spike-bare,qemu
DRAM:  256 MiB
In:    uart at 10013000
Out:   uart at 10013000
Err:   uart at 10013000

Net:
Warning: ethernet at 100900fc (eth0) using random MAC address - f6:1f:8c:13:83:c0
eth0: ethernet at 100900fc
Hit any key to stop autoboot: 0

Device 0: unknown device
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (2 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x82100000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (1 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15 Filename 'boot.scr.uimg'.
Load address: 0x81000000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
=> ping 10.0.2.2
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1)

Quoted 9 lines

Using ethernet at 100900fc device
host 10.0.2.2 is alive
=>
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
host 10.0.2.2 is alive
=> qemu-system-riscv64: terminating on signal 2

I have always been using "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot" to test U-Boot on qemu risc-v.
With above command, I can "ping 10.0.2.2" and get the exact the same result as yours.

However I wanted to connect the tap interface to the emulated network controller for testing, that's why I wanted to use "-device" and "-netdev", but I don't know which device string I need to tell QEMU. After a bit googleing I got the following page:
https://forums.xilinx.com/t5/Embedded-Processor-System-Design/Zynq-QEMU-Network-Issues/td-p/797050

From the page it looks that the device should be "-device cadence_gem", but when I pass it to QEMU I got:

Quoted 7 lines
Quoted 4 lines

qemu-system-riscv64: -device cadence_gem,netdev=net0: Parameter 'driver' expects pluggable device type

It looks cadence_gem is not a pluggable device. Any ideas?

I have mostly tried TAP devices with VirtIO-Net. I believe this could be some bug in Cadence GEM emulation of QEMU.

I managed to get tap interface connected to the cadence_gem controller. The QEMU command line is "qemu-system-riscv64 -nographic -M sifive_u -kernel u-boot -nic tap,model=cadence_gem"

A single "ping" works after I set related network environments in the shell. But "tftp" test fails. It looks the driver just time out.

=> tftp 84000000 bmeng/uImage.riscv
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 100Mbps full-duplex (lpa: 0xcde1) Using ethernet at 100900fc device
TFTP from server 10.10.0.100; our IP address is 10.10.0.108 Filename 'bmeng/uImage.riscv'.
Load address: 0x84000000
Loading: #T T #T T #T #T T #T #T T #
Retry count exceeded; starting again

Quoted 1 line

Can you please take a look?

Just let everyone know that this GEM emulation issue has been fixed by the following QEMU patch (series):
http://patchwork.ozlabs.org/patch/1143358/

Regards,
Bin