All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] hw/arm: sabrelite: Improve emulation fidelity to allow booting upstream U-Boot
@ 2021-01-06  6:35 Bin Meng
  2021-01-06  6:35 ` [PATCH v3 1/4] hw/misc: imx6_ccm: Update PMU_MISC0 reset value Bin Meng
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Bin Meng @ 2021-01-06  6:35 UTC (permalink / raw)
  To: Peter Maydell, Alex Bennée, Jean-Christophe Dubois,
	qemu-arm, qemu-devel
  Cc: Bin Meng

From: Bin Meng <bin.meng@windriver.com>


At present the upstream U-Boot (as of today, v2021.01-rc3) does not
boot on QEMU sabrelite machine.

This fixes several issues to improve emulation fidelity of the i.MX6
sabrelite board. With this series, upstream U-Boot can boot to U-Boot
command shell. While we are here, add a target guide for this board
to help people run Linux kernel and U-Boot on QEMU.

Changes in v3:
- correct 2 typos in sabrelite.rst

Changes in v2:
- new patch: add sabrelite target guide

Bin Meng (4):
  hw/misc: imx6_ccm: Update PMU_MISC0 reset value
  hw/msic: imx6_ccm: Correct register value for silicon type
  hw/arm: sabrelite: Connect the Ethernet PHY at address 6
  docs/system: arm: Add sabrelite board description

 docs/system/arm/sabrelite.rst | 119 ++++++++++++++++++++++++++++++++++
 docs/system/target-arm.rst    |   1 +
 hw/arm/sabrelite.c            |   4 ++
 hw/misc/imx6_ccm.c            |   4 +-
 4 files changed, 126 insertions(+), 2 deletions(-)
 create mode 100644 docs/system/arm/sabrelite.rst

-- 
2.25.1



^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v3 1/4] hw/misc: imx6_ccm: Update PMU_MISC0 reset value
  2021-01-06  6:35 [PATCH v3 0/4] hw/arm: sabrelite: Improve emulation fidelity to allow booting upstream U-Boot Bin Meng
@ 2021-01-06  6:35 ` Bin Meng
  2021-01-06  6:35 ` [PATCH v3 2/4] hw/msic: imx6_ccm: Correct register value for silicon type Bin Meng
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 16+ messages in thread
From: Bin Meng @ 2021-01-06  6:35 UTC (permalink / raw)
  To: Peter Maydell, Alex Bennée, Jean-Christophe Dubois,
	qemu-arm, qemu-devel
  Cc: Bin Meng

From: Bin Meng <bin.meng@windriver.com>

U-Boot expects PMU_MISC0 register bit 7 is set (see init_bandgap()
in arch/arm/mach-imx/mx6/soc.c) during boot. This bit indicates the
bandgap has stabilized.

With this change, the latest upstream U-Boot (v2021.01-rc3) for imx6
sabrelite board (mx6qsabrelite_defconfig), with a slight change made
by switching CONFIG_OF_SEPARATE to CONFIG_OF_EMBED, boots to U-Boot
shell on QEMU with the following command:

$ qemu-system-arm -M sabrelite -smp 4 -m 1G -kernel u-boot \
    -display none -serial null -serial stdio

Boot log below:

  U-Boot 2021.01-rc3 (Dec 12 2020 - 17:40:02 +0800)

  CPU:   Freescale i.MX?? rev1.0 at 792 MHz
  Reset cause: POR
  Model: Freescale i.MX6 Quad SABRE Lite Board
  Board: SABRE Lite
  I2C:   ready
  DRAM:  1 GiB
  force_idle_bus: sda=0 scl=0 sda.gp=0x5c scl.gp=0x55
  force_idle_bus: failed to clear bus, sda=0 scl=0
  force_idle_bus: sda=0 scl=0 sda.gp=0x6d scl.gp=0x6c
  force_idle_bus: failed to clear bus, sda=0 scl=0
  force_idle_bus: sda=0 scl=0 sda.gp=0xcb scl.gp=0x5
  force_idle_bus: failed to clear bus, sda=0 scl=0
  MMC:   FSL_SDHC: 0, FSL_SDHC: 1
  Loading Environment from MMC... *** Warning - No block device, using default environment

  In:    serial
  Out:   serial
  Err:   serial
  Net:   Board Net Initialization Failed
  No ethernet found.
  starting USB...
  Bus usb@2184000: usb dr_mode not found
  USB EHCI 1.00
  Bus usb@2184200: USB EHCI 1.00
  scanning bus usb@2184000 for devices... 1 USB Device(s) found
  scanning bus usb@2184200 for devices... 1 USB Device(s) found
         scanning usb for storage devices... 0 Storage Device(s) found
         scanning usb for ethernet devices... 0 Ethernet Device(s) found
  Hit any key to stop autoboot:  0
  =>

Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
---

(no changes since v1)

 hw/misc/imx6_ccm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c
index cb740427ec..7e031b6775 100644
--- a/hw/misc/imx6_ccm.c
+++ b/hw/misc/imx6_ccm.c
@@ -450,7 +450,7 @@ static void imx6_ccm_reset(DeviceState *dev)
     s->analog[PMU_REG_3P0] = 0x00000F74;
     s->analog[PMU_REG_2P5] = 0x00005071;
     s->analog[PMU_REG_CORE] = 0x00402010;
-    s->analog[PMU_MISC0] = 0x04000000;
+    s->analog[PMU_MISC0] = 0x04000080;
     s->analog[PMU_MISC1] = 0x00000000;
     s->analog[PMU_MISC2] = 0x00272727;
 
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v3 2/4] hw/msic: imx6_ccm: Correct register value for silicon type
  2021-01-06  6:35 [PATCH v3 0/4] hw/arm: sabrelite: Improve emulation fidelity to allow booting upstream U-Boot Bin Meng
  2021-01-06  6:35 ` [PATCH v3 1/4] hw/misc: imx6_ccm: Update PMU_MISC0 reset value Bin Meng
@ 2021-01-06  6:35 ` Bin Meng
  2021-01-06  6:35 ` [PATCH v3 3/4] hw/arm: sabrelite: Connect the Ethernet PHY at address 6 Bin Meng
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 16+ messages in thread
From: Bin Meng @ 2021-01-06  6:35 UTC (permalink / raw)
  To: Peter Maydell, Alex Bennée, Jean-Christophe Dubois,
	qemu-arm, qemu-devel
  Cc: Bin Meng

From: Bin Meng <bin.meng@windriver.com>

Currently when U-Boot boots, it prints "??" for i.MX processor:

  CPU:   Freescale i.MX?? rev1.0 at 792 MHz

The register that was used to determine the silicon type is
undocumented in the latest IMX6DQRM (Rev. 6, 05/2020), but we
can refer to get_cpu_rev() in arch/arm/mach-imx/mx6/soc.c in
the U-Boot source codes that USB_ANALOG_DIGPROG is used.

Update its reset value to indicate i.MX6Q.

Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
---

(no changes since v1)

 hw/misc/imx6_ccm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c
index 7e031b6775..4c830fd89a 100644
--- a/hw/misc/imx6_ccm.c
+++ b/hw/misc/imx6_ccm.c
@@ -462,7 +462,7 @@ static void imx6_ccm_reset(DeviceState *dev)
     s->analog[USB_ANALOG_USB2_VBUS_DETECT] = 0x00000004;
     s->analog[USB_ANALOG_USB2_CHRG_DETECT] = 0x00000000;
     s->analog[USB_ANALOG_USB2_MISC] = 0x00000002;
-    s->analog[USB_ANALOG_DIGPROG] = 0x00000000;
+    s->analog[USB_ANALOG_DIGPROG] = 0x00630000;
 
     /* all PLLs need to be locked */
     s->analog[CCM_ANALOG_PLL_ARM]   |= CCM_ANALOG_PLL_LOCK;
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v3 3/4] hw/arm: sabrelite: Connect the Ethernet PHY at address 6
  2021-01-06  6:35 [PATCH v3 0/4] hw/arm: sabrelite: Improve emulation fidelity to allow booting upstream U-Boot Bin Meng
  2021-01-06  6:35 ` [PATCH v3 1/4] hw/misc: imx6_ccm: Update PMU_MISC0 reset value Bin Meng
  2021-01-06  6:35 ` [PATCH v3 2/4] hw/msic: imx6_ccm: Correct register value for silicon type Bin Meng
@ 2021-01-06  6:35 ` Bin Meng
  2021-04-30 14:41   ` Guenter Roeck
  2021-01-06  6:35 ` [PATCH v3 4/4] docs/system: arm: Add sabrelite board description Bin Meng
  2021-01-08 12:32 ` [PATCH v3 0/4] hw/arm: sabrelite: Improve emulation fidelity to allow booting upstream U-Boot Peter Maydell
  4 siblings, 1 reply; 16+ messages in thread
From: Bin Meng @ 2021-01-06  6:35 UTC (permalink / raw)
  To: Peter Maydell, Alex Bennée, Jean-Christophe Dubois,
	qemu-arm, qemu-devel
  Cc: Bin Meng

From: Bin Meng <bin.meng@windriver.com>

At present, when booting U-Boot on QEMU sabrelite, we see:

  Net:   Board Net Initialization Failed
  No ethernet found.

U-Boot scans PHY at address 4/5/6/7 (see board_eth_init() in the
U-Boot source: board/boundary/nitrogen6x/nitrogen6x.c). On the real
board, the Ethernet PHY is at address 6. Adjust this by updating the
"fec-phy-num" property of the fsl_imx6 SoC object.

With this change, U-Boot sees the PHY but complains MAC address:

  Net:   using phy at 6
  FEC [PRIME]
  Error: FEC address not set.

This is due to U-Boot tries to read the MAC address from the fuse,
which QEMU does not have any valid content filled in. However this
does not prevent the Ethernet from working in QEMU. We just need to
set up the MAC address later in the U-Boot command shell, by:

  => setenv ethaddr 00:11:22:33:44:55

Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
---

(no changes since v1)

 hw/arm/sabrelite.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/arm/sabrelite.c b/hw/arm/sabrelite.c
index 91d8c43a7e..a3dbf85e0e 100644
--- a/hw/arm/sabrelite.c
+++ b/hw/arm/sabrelite.c
@@ -51,6 +51,10 @@ static void sabrelite_init(MachineState *machine)
 
     s = FSL_IMX6(object_new(TYPE_FSL_IMX6));
     object_property_add_child(OBJECT(machine), "soc", OBJECT(s));
+
+    /* Ethernet PHY address is 6 */
+    object_property_set_int(OBJECT(s), "fec-phy-num", 6, &error_fatal);
+
     qdev_realize(DEVICE(s), NULL, &error_fatal);
 
     memory_region_add_subregion(get_system_memory(), FSL_IMX6_MMDC_ADDR,
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v3 4/4] docs/system: arm: Add sabrelite board description
  2021-01-06  6:35 [PATCH v3 0/4] hw/arm: sabrelite: Improve emulation fidelity to allow booting upstream U-Boot Bin Meng
                   ` (2 preceding siblings ...)
  2021-01-06  6:35 ` [PATCH v3 3/4] hw/arm: sabrelite: Connect the Ethernet PHY at address 6 Bin Meng
@ 2021-01-06  6:35 ` Bin Meng
  2021-01-08 12:32 ` [PATCH v3 0/4] hw/arm: sabrelite: Improve emulation fidelity to allow booting upstream U-Boot Peter Maydell
  4 siblings, 0 replies; 16+ messages in thread
From: Bin Meng @ 2021-01-06  6:35 UTC (permalink / raw)
  To: Peter Maydell, Alex Bennée, Jean-Christophe Dubois,
	qemu-arm, qemu-devel
  Cc: Bin Meng

From: Bin Meng <bin.meng@windriver.com>

This adds the target guide for SABRE Lite board, and documents how
to boot a Linux kernel and U-Boot bootloader.

Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

---

Changes in v3:
- correct 2 typos in sabrelite.rst

Changes in v2:
- new patch: add sabrelite target guide

 docs/system/arm/sabrelite.rst | 119 ++++++++++++++++++++++++++++++++++
 docs/system/target-arm.rst    |   1 +
 2 files changed, 120 insertions(+)
 create mode 100644 docs/system/arm/sabrelite.rst

diff --git a/docs/system/arm/sabrelite.rst b/docs/system/arm/sabrelite.rst
new file mode 100644
index 0000000000..71713310e3
--- /dev/null
+++ b/docs/system/arm/sabrelite.rst
@@ -0,0 +1,119 @@
+Boundary Devices SABRE Lite (``sabrelite``)
+===========================================
+
+Boundary Devices SABRE Lite i.MX6 Development Board is a low-cost development
+platform featuring the powerful Freescale / NXP Semiconductor's i.MX 6 Quad
+Applications Processor.
+
+Supported devices
+-----------------
+
+The SABRE Lite machine supports the following devices:
+
+ * Up to 4 Cortex A9 cores
+ * Generic Interrupt Controller
+ * 1 Clock Controller Module
+ * 1 System Reset Controller
+ * 5 UARTs
+ * 2 EPIC timers
+ * 1 GPT timer
+ * 2 Watchdog timers
+ * 1 FEC Ethernet controller
+ * 3 I2C controllers
+ * 7 GPIO controllers
+ * 4 SDHC storage controllers
+ * 4 USB 2.0 host controllers
+ * 5 ECSPI controllers
+ * 1 SST 25VF016B flash
+
+Please note above list is a complete superset the QEMU SABRE Lite machine can
+support. For a normal use case, a device tree blob that represents a real world
+SABRE Lite board, only exposes a subset of devices to the guest software.
+
+Boot options
+------------
+
+The SABRE Lite machine can start using the standard -kernel functionality
+for loading a Linux kernel, U-Boot bootloader or ELF executable.
+
+Running Linux kernel
+--------------------
+
+Linux mainline v5.10 release is tested at the time of writing. To build a Linux
+mainline kernel that can be booted by the SABRE Lite machine, simply configure
+the kernel using the imx_v6_v7_defconfig configuration:
+
+.. code-block:: bash
+
+  $ export ARCH=arm
+  $ export CROSS_COMPILE=arm-linux-gnueabihf-
+  $ make imx_v6_v7_defconfig
+  $ make
+
+To boot the newly built Linux kernel in QEMU with the SABRE Lite machine, use:
+
+.. code-block:: bash
+
+  $ qemu-system-arm -M sabrelite -smp 4 -m 1G \
+      -display none -serial null -serial stdio \
+      -kernel arch/arm/boot/zImage \
+      -dtb arch/arm/boot/dts/imx6q-sabrelite.dtb \
+      -initrd /path/to/rootfs.ext4 \
+      -append "root=/dev/ram"
+
+Running U-Boot
+--------------
+
+U-Boot mainline v2020.10 release is tested at the time of writing. To build a
+U-Boot mainline bootloader that can be booted by the SABRE Lite machine, use
+the mx6qsabrelite_defconfig with similar commands as described above for Linux:
+
+.. code-block:: bash
+
+  $ export CROSS_COMPILE=arm-linux-gnueabihf-
+  $ make mx6qsabrelite_defconfig
+
+Note we need to adjust settings by:
+
+.. code-block:: bash
+
+  $ make menuconfig
+
+then manually select the following configuration in U-Boot:
+
+  Device Tree Control > Provider of DTB for DT Control > Embedded DTB
+
+To start U-Boot using the SABRE Lite machine, provide the u-boot binary to
+the -kernel argument, along with an SD card image with rootfs:
+
+.. code-block:: bash
+
+  $ qemu-system-arm -M sabrelite -smp 4 -m 1G \
+      -display none -serial null -serial stdio \
+      -kernel u-boot
+
+The following example shows booting Linux kernel from dhcp, and uses the
+rootfs on an SD card. This requires some additional command line parameters
+for QEMU:
+
+.. code-block:: none
+
+  -nic user,tftp=/path/to/kernel/zImage \
+  -drive file=sdcard.img,id=rootfs -device sd-card,drive=rootfs
+
+The directory for the built-in TFTP server should also contain the device tree
+blob of the SABRE Lite board. The sample SD card image was populated with the
+root file system with one single partition. You may adjust the kernel "root="
+boot parameter accordingly.
+
+After U-Boot boots, type the following commands in the U-Boot command shell to
+boot the Linux kernel:
+
+.. code-block:: none
+
+  => setenv ethaddr 00:11:22:33:44:55
+  => setenv bootfile zImage
+  => dhcp
+  => tftpboot 14000000 imx6q-sabrelite.dtb
+  => setenv bootargs root=/dev/mmcblk3p1
+  => bootz 12000000 - 14000000
diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst
index bde4b8e044..edd013c7bb 100644
--- a/docs/system/target-arm.rst
+++ b/docs/system/target-arm.rst
@@ -83,6 +83,7 @@ undocumented; you can get a complete list by running
    arm/versatile
    arm/vexpress
    arm/aspeed
+   arm/sabrelite
    arm/digic
    arm/musicpal
    arm/gumstix
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v3 0/4] hw/arm: sabrelite: Improve emulation fidelity to allow booting upstream U-Boot
  2021-01-06  6:35 [PATCH v3 0/4] hw/arm: sabrelite: Improve emulation fidelity to allow booting upstream U-Boot Bin Meng
                   ` (3 preceding siblings ...)
  2021-01-06  6:35 ` [PATCH v3 4/4] docs/system: arm: Add sabrelite board description Bin Meng
@ 2021-01-08 12:32 ` Peter Maydell
  4 siblings, 0 replies; 16+ messages in thread
From: Peter Maydell @ 2021-01-08 12:32 UTC (permalink / raw)
  To: Bin Meng
  Cc: Bin Meng, qemu-arm, Alex Bennée, QEMU Developers,
	Jean-Christophe Dubois

On Wed, 6 Jan 2021 at 06:35, Bin Meng <bmeng.cn@gmail.com> wrote:
>
> From: Bin Meng <bin.meng@windriver.com>
>
>
> At present the upstream U-Boot (as of today, v2021.01-rc3) does not
> boot on QEMU sabrelite machine.
>
> This fixes several issues to improve emulation fidelity of the i.MX6
> sabrelite board. With this series, upstream U-Boot can boot to U-Boot
> command shell. While we are here, add a target guide for this board
> to help people run Linux kernel and U-Boot on QEMU.
>
> Changes in v3:
> - correct 2 typos in sabrelite.rst
>
> Changes in v2:
> - new patch: add sabrelite target guide
>
> Bin Meng (4):
>   hw/misc: imx6_ccm: Update PMU_MISC0 reset value
>   hw/msic: imx6_ccm: Correct register value for silicon type
>   hw/arm: sabrelite: Connect the Ethernet PHY at address 6
>   docs/system: arm: Add sabrelite board description


Applied to target-arm.next, thanks.

-- PMM


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3 3/4] hw/arm: sabrelite: Connect the Ethernet PHY at address 6
  2021-01-06  6:35 ` [PATCH v3 3/4] hw/arm: sabrelite: Connect the Ethernet PHY at address 6 Bin Meng
@ 2021-04-30 14:41   ` Guenter Roeck
  2021-05-01  4:28     ` Bin Meng
  0 siblings, 1 reply; 16+ messages in thread
From: Guenter Roeck @ 2021-04-30 14:41 UTC (permalink / raw)
  To: Bin Meng
  Cc: Peter Maydell, Bin Meng, qemu-devel, Jean-Christophe Dubois,
	qemu-arm, Alex Bennée

Hi,

On Wed, Jan 06, 2021 at 02:35:03PM +0800, Bin Meng wrote:
> From: Bin Meng <bin.meng@windriver.com>
> 
> At present, when booting U-Boot on QEMU sabrelite, we see:
> 
>   Net:   Board Net Initialization Failed
>   No ethernet found.
> 
> U-Boot scans PHY at address 4/5/6/7 (see board_eth_init() in the
> U-Boot source: board/boundary/nitrogen6x/nitrogen6x.c). On the real
> board, the Ethernet PHY is at address 6. Adjust this by updating the
> "fec-phy-num" property of the fsl_imx6 SoC object.
> 
> With this change, U-Boot sees the PHY but complains MAC address:
> 
>   Net:   using phy at 6
>   FEC [PRIME]
>   Error: FEC address not set.
> 
> This is due to U-Boot tries to read the MAC address from the fuse,
> which QEMU does not have any valid content filled in. However this
> does not prevent the Ethernet from working in QEMU. We just need to
> set up the MAC address later in the U-Boot command shell, by:
> 
>   => setenv ethaddr 00:11:22:33:44:55
> 

With this patch in place, the standard Ethernet interface no longer works when
booting sabrelite Linux images directly (without u-boot) using the following
qemu command.
	qemu-system-arm -M sabrelite -kernel arch/arm/boot/zImage
	...

The Ethernet interface still instantiates, but packet transfer to the host
no longer works. Reverting this patch fixes the problem for me.

Is there a qemu command line parameter that is now necessary to instantiate
the Ethernet interface when booting Linux ?

Thanks,
Guenter


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3 3/4] hw/arm: sabrelite: Connect the Ethernet PHY at address 6
  2021-04-30 14:41   ` Guenter Roeck
@ 2021-05-01  4:28     ` Bin Meng
  2021-05-01 13:12       ` Guenter Roeck
  2021-05-01 20:12       ` Guenter Roeck
  0 siblings, 2 replies; 16+ messages in thread
From: Bin Meng @ 2021-05-01  4:28 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Peter Maydell, Bin Meng, qemu-devel@nongnu.org Developers,
	Jean-Christophe Dubois, qemu-arm, Alex Bennée

On Fri, Apr 30, 2021 at 10:41 PM Guenter Roeck <linux@roeck-us.net> wrote:
>
> Hi,
>
> On Wed, Jan 06, 2021 at 02:35:03PM +0800, Bin Meng wrote:
> > From: Bin Meng <bin.meng@windriver.com>
> >
> > At present, when booting U-Boot on QEMU sabrelite, we see:
> >
> >   Net:   Board Net Initialization Failed
> >   No ethernet found.
> >
> > U-Boot scans PHY at address 4/5/6/7 (see board_eth_init() in the
> > U-Boot source: board/boundary/nitrogen6x/nitrogen6x.c). On the real
> > board, the Ethernet PHY is at address 6. Adjust this by updating the
> > "fec-phy-num" property of the fsl_imx6 SoC object.
> >
> > With this change, U-Boot sees the PHY but complains MAC address:
> >
> >   Net:   using phy at 6
> >   FEC [PRIME]
> >   Error: FEC address not set.
> >
> > This is due to U-Boot tries to read the MAC address from the fuse,
> > which QEMU does not have any valid content filled in. However this
> > does not prevent the Ethernet from working in QEMU. We just need to
> > set up the MAC address later in the U-Boot command shell, by:
> >
> >   => setenv ethaddr 00:11:22:33:44:55
> >
>
> With this patch in place, the standard Ethernet interface no longer works when
> booting sabrelite Linux images directly (without u-boot) using the following
> qemu command.
>         qemu-system-arm -M sabrelite -kernel arch/arm/boot/zImage
>         ...
>
> The Ethernet interface still instantiates, but packet transfer to the host
> no longer works. Reverting this patch fixes the problem for me.
>
> Is there a qemu command line parameter that is now necessary to instantiate
> the Ethernet interface when booting Linux ?

Enabling "guest_errors" shows that Linux kernel fec driver is trying
to read PHY at address 0, which is not what we want.

[imx.fec.phy]imx_phy_read: Bad phy num 0

The device tree blob of the sabrelite does not contain a node for the
ethernet phy specifying phy address, so I suspect Linux kernel driver
is using default phy address 0 instead.

Could you please test on a real hardware to see what happens?

Regards,
Bin


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3 3/4] hw/arm: sabrelite: Connect the Ethernet PHY at address 6
  2021-05-01  4:28     ` Bin Meng
@ 2021-05-01 13:12       ` Guenter Roeck
  2021-05-01 20:12       ` Guenter Roeck
  1 sibling, 0 replies; 16+ messages in thread
From: Guenter Roeck @ 2021-05-01 13:12 UTC (permalink / raw)
  To: Bin Meng
  Cc: Peter Maydell, Bin Meng, qemu-devel@nongnu.org Developers,
	Jean-Christophe Dubois, qemu-arm, Alex Bennée

On 4/30/21 9:28 PM, Bin Meng wrote:
> On Fri, Apr 30, 2021 at 10:41 PM Guenter Roeck <linux@roeck-us.net> wrote:
>>
>> Hi,
>>
>> On Wed, Jan 06, 2021 at 02:35:03PM +0800, Bin Meng wrote:
>>> From: Bin Meng <bin.meng@windriver.com>
>>>
>>> At present, when booting U-Boot on QEMU sabrelite, we see:
>>>
>>>   Net:   Board Net Initialization Failed
>>>   No ethernet found.
>>>
>>> U-Boot scans PHY at address 4/5/6/7 (see board_eth_init() in the
>>> U-Boot source: board/boundary/nitrogen6x/nitrogen6x.c). On the real
>>> board, the Ethernet PHY is at address 6. Adjust this by updating the
>>> "fec-phy-num" property of the fsl_imx6 SoC object.
>>>
>>> With this change, U-Boot sees the PHY but complains MAC address:
>>>
>>>   Net:   using phy at 6
>>>   FEC [PRIME]
>>>   Error: FEC address not set.
>>>
>>> This is due to U-Boot tries to read the MAC address from the fuse,
>>> which QEMU does not have any valid content filled in. However this
>>> does not prevent the Ethernet from working in QEMU. We just need to
>>> set up the MAC address later in the U-Boot command shell, by:
>>>
>>>   => setenv ethaddr 00:11:22:33:44:55
>>>
>>
>> With this patch in place, the standard Ethernet interface no longer works when
>> booting sabrelite Linux images directly (without u-boot) using the following
>> qemu command.
>>         qemu-system-arm -M sabrelite -kernel arch/arm/boot/zImage
>>         ...
>>
>> The Ethernet interface still instantiates, but packet transfer to the host
>> no longer works. Reverting this patch fixes the problem for me.
>>
>> Is there a qemu command line parameter that is now necessary to instantiate
>> the Ethernet interface when booting Linux ?
> 
> Enabling "guest_errors" shows that Linux kernel fec driver is trying
> to read PHY at address 0, which is not what we want.
> 
> [imx.fec.phy]imx_phy_read: Bad phy num 0
> 
> The device tree blob of the sabrelite does not contain a node for the
> ethernet phy specifying phy address, so I suspect Linux kernel driver
> is using default phy address 0 instead.
> 
> Could you please test on a real hardware to see what happens?
> 

I don't have access to real hardware, sorry.

Guenter



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3 3/4] hw/arm: sabrelite: Connect the Ethernet PHY at address 6
  2021-05-01  4:28     ` Bin Meng
  2021-05-01 13:12       ` Guenter Roeck
@ 2021-05-01 20:12       ` Guenter Roeck
  2021-05-01 21:40         ` Philippe Mathieu-Daudé
  2021-05-01 23:06         ` Bin Meng
  1 sibling, 2 replies; 16+ messages in thread
From: Guenter Roeck @ 2021-05-01 20:12 UTC (permalink / raw)
  To: Bin Meng
  Cc: Peter Maydell, Bin Meng, qemu-devel@nongnu.org Developers,
	Jean-Christophe Dubois, qemu-arm, Alex Bennée

On 4/30/21 9:28 PM, Bin Meng wrote:
> On Fri, Apr 30, 2021 at 10:41 PM Guenter Roeck <linux@roeck-us.net> wrote:
>>
>> Hi,
>>
>> On Wed, Jan 06, 2021 at 02:35:03PM +0800, Bin Meng wrote:
>>> From: Bin Meng <bin.meng@windriver.com>
>>>
>>> At present, when booting U-Boot on QEMU sabrelite, we see:
>>>
>>>   Net:   Board Net Initialization Failed
>>>   No ethernet found.
>>>
>>> U-Boot scans PHY at address 4/5/6/7 (see board_eth_init() in the
>>> U-Boot source: board/boundary/nitrogen6x/nitrogen6x.c). On the real
>>> board, the Ethernet PHY is at address 6. Adjust this by updating the
>>> "fec-phy-num" property of the fsl_imx6 SoC object.
>>>
>>> With this change, U-Boot sees the PHY but complains MAC address:
>>>
>>>   Net:   using phy at 6
>>>   FEC [PRIME]
>>>   Error: FEC address not set.
>>>
>>> This is due to U-Boot tries to read the MAC address from the fuse,
>>> which QEMU does not have any valid content filled in. However this
>>> does not prevent the Ethernet from working in QEMU. We just need to
>>> set up the MAC address later in the U-Boot command shell, by:
>>>
>>>   => setenv ethaddr 00:11:22:33:44:55
>>>
>>
>> With this patch in place, the standard Ethernet interface no longer works when
>> booting sabrelite Linux images directly (without u-boot) using the following
>> qemu command.
>>         qemu-system-arm -M sabrelite -kernel arch/arm/boot/zImage
>>         ...
>>
>> The Ethernet interface still instantiates, but packet transfer to the host
>> no longer works. Reverting this patch fixes the problem for me.
>>
>> Is there a qemu command line parameter that is now necessary to instantiate
>> the Ethernet interface when booting Linux ?
> 
> Enabling "guest_errors" shows that Linux kernel fec driver is trying
> to read PHY at address 0, which is not what we want.
> 
> [imx.fec.phy]imx_phy_read: Bad phy num 0
> 
> The device tree blob of the sabrelite does not contain a node for the
> ethernet phy specifying phy address, so I suspect Linux kernel driver
> is using default phy address 0 instead.
> 
> Could you please test on a real hardware to see what happens?
> 

The problem is that qemu returns 0 when the OS tries to read from a
non-existing PHY. Linux expects it to return 0xffff, and believes that
a PHY is there if 0 is returned. This helps:

diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
index f03450c028..3c90c38e26 100644
--- a/hw/net/imx_fec.c
+++ b/hw/net/imx_fec.c
@@ -285,7 +285,7 @@ static uint32_t imx_phy_read(IMXFECState *s, int reg)
     if (phy != s->phy_num) {
         qemu_log_mask(LOG_GUEST_ERROR, "[%s.phy]%s: Bad phy num %u\n",
                       TYPE_IMX_FEC, __func__, phy);
-        return 0;
+        return 0xffff;
     }

Note that this is not really a guest error; any OS can and likely
will scan the MII bus for connected phy chips.

Guenter


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v3 3/4] hw/arm: sabrelite: Connect the Ethernet PHY at address 6
  2021-05-01 20:12       ` Guenter Roeck
@ 2021-05-01 21:40         ` Philippe Mathieu-Daudé
  2021-05-01 23:21           ` Guenter Roeck
  2021-05-01 23:06         ` Bin Meng
  1 sibling, 1 reply; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-01 21:40 UTC (permalink / raw)
  To: Guenter Roeck, Bin Meng
  Cc: Peter Maydell, Bin Meng, qemu-devel@nongnu.org Developers,
	qemu-arm, Jean-Christophe Dubois

On 5/1/21 10:12 PM, Guenter Roeck wrote:
> On 4/30/21 9:28 PM, Bin Meng wrote:
>> On Fri, Apr 30, 2021 at 10:41 PM Guenter Roeck <linux@roeck-us.net> wrote:
>>>
>>> Hi,
>>>
>>> On Wed, Jan 06, 2021 at 02:35:03PM +0800, Bin Meng wrote:
>>>> From: Bin Meng <bin.meng@windriver.com>
>>>>
>>>> At present, when booting U-Boot on QEMU sabrelite, we see:
>>>>
>>>>   Net:   Board Net Initialization Failed
>>>>   No ethernet found.
>>>>
>>>> U-Boot scans PHY at address 4/5/6/7 (see board_eth_init() in the
>>>> U-Boot source: board/boundary/nitrogen6x/nitrogen6x.c). On the real
>>>> board, the Ethernet PHY is at address 6. Adjust this by updating the
>>>> "fec-phy-num" property of the fsl_imx6 SoC object.
>>>>
>>>> With this change, U-Boot sees the PHY but complains MAC address:
>>>>
>>>>   Net:   using phy at 6
>>>>   FEC [PRIME]
>>>>   Error: FEC address not set.
>>>>
>>>> This is due to U-Boot tries to read the MAC address from the fuse,
>>>> which QEMU does not have any valid content filled in. However this
>>>> does not prevent the Ethernet from working in QEMU. We just need to
>>>> set up the MAC address later in the U-Boot command shell, by:
>>>>
>>>>   => setenv ethaddr 00:11:22:33:44:55
>>>>
>>>
>>> With this patch in place, the standard Ethernet interface no longer works when
>>> booting sabrelite Linux images directly (without u-boot) using the following
>>> qemu command.
>>>         qemu-system-arm -M sabrelite -kernel arch/arm/boot/zImage
>>>         ...
>>>
>>> The Ethernet interface still instantiates, but packet transfer to the host
>>> no longer works. Reverting this patch fixes the problem for me.
>>>
>>> Is there a qemu command line parameter that is now necessary to instantiate
>>> the Ethernet interface when booting Linux ?
>>
>> Enabling "guest_errors" shows that Linux kernel fec driver is trying
>> to read PHY at address 0, which is not what we want.
>>
>> [imx.fec.phy]imx_phy_read: Bad phy num 0
>>
>> The device tree blob of the sabrelite does not contain a node for the
>> ethernet phy specifying phy address, so I suspect Linux kernel driver
>> is using default phy address 0 instead.
>>
>> Could you please test on a real hardware to see what happens?
>>
> 
> The problem is that qemu returns 0 when the OS tries to read from a
> non-existing PHY. Linux expects it to return 0xffff, and believes that
> a PHY is there if 0 is returned.

Correct.

> This helps:
> 
> diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
> index f03450c028..3c90c38e26 100644
> --- a/hw/net/imx_fec.c
> +++ b/hw/net/imx_fec.c
> @@ -285,7 +285,7 @@ static uint32_t imx_phy_read(IMXFECState *s, int reg)
>      if (phy != s->phy_num) {
>          qemu_log_mask(LOG_GUEST_ERROR, "[%s.phy]%s: Bad phy num %u\n",
>                        TYPE_IMX_FEC, __func__, phy);
> -        return 0;
> +        return 0xffff;
>      }
> 
> Note that this is not really a guest error; any OS can and likely
> will scan the MII bus for connected phy chips.

Correct. This should be a trace event instead.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3 3/4] hw/arm: sabrelite: Connect the Ethernet PHY at address 6
  2021-05-01 20:12       ` Guenter Roeck
  2021-05-01 21:40         ` Philippe Mathieu-Daudé
@ 2021-05-01 23:06         ` Bin Meng
  1 sibling, 0 replies; 16+ messages in thread
From: Bin Meng @ 2021-05-01 23:06 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Peter Maydell, Bin Meng, qemu-devel@nongnu.org Developers,
	Jean-Christophe Dubois, qemu-arm, Alex Bennée

On Sun, May 2, 2021 at 4:12 AM Guenter Roeck <linux@roeck-us.net> wrote:
>
> On 4/30/21 9:28 PM, Bin Meng wrote:
> > On Fri, Apr 30, 2021 at 10:41 PM Guenter Roeck <linux@roeck-us.net> wrote:
> >>
> >> Hi,
> >>
> >> On Wed, Jan 06, 2021 at 02:35:03PM +0800, Bin Meng wrote:
> >>> From: Bin Meng <bin.meng@windriver.com>
> >>>
> >>> At present, when booting U-Boot on QEMU sabrelite, we see:
> >>>
> >>>   Net:   Board Net Initialization Failed
> >>>   No ethernet found.
> >>>
> >>> U-Boot scans PHY at address 4/5/6/7 (see board_eth_init() in the
> >>> U-Boot source: board/boundary/nitrogen6x/nitrogen6x.c). On the real
> >>> board, the Ethernet PHY is at address 6. Adjust this by updating the
> >>> "fec-phy-num" property of the fsl_imx6 SoC object.
> >>>
> >>> With this change, U-Boot sees the PHY but complains MAC address:
> >>>
> >>>   Net:   using phy at 6
> >>>   FEC [PRIME]
> >>>   Error: FEC address not set.
> >>>
> >>> This is due to U-Boot tries to read the MAC address from the fuse,
> >>> which QEMU does not have any valid content filled in. However this
> >>> does not prevent the Ethernet from working in QEMU. We just need to
> >>> set up the MAC address later in the U-Boot command shell, by:
> >>>
> >>>   => setenv ethaddr 00:11:22:33:44:55
> >>>
> >>
> >> With this patch in place, the standard Ethernet interface no longer works when
> >> booting sabrelite Linux images directly (without u-boot) using the following
> >> qemu command.
> >>         qemu-system-arm -M sabrelite -kernel arch/arm/boot/zImage
> >>         ...
> >>
> >> The Ethernet interface still instantiates, but packet transfer to the host
> >> no longer works. Reverting this patch fixes the problem for me.
> >>
> >> Is there a qemu command line parameter that is now necessary to instantiate
> >> the Ethernet interface when booting Linux ?
> >
> > Enabling "guest_errors" shows that Linux kernel fec driver is trying
> > to read PHY at address 0, which is not what we want.
> >
> > [imx.fec.phy]imx_phy_read: Bad phy num 0
> >
> > The device tree blob of the sabrelite does not contain a node for the
> > ethernet phy specifying phy address, so I suspect Linux kernel driver
> > is using default phy address 0 instead.
> >
> > Could you please test on a real hardware to see what happens?
> >
>
> The problem is that qemu returns 0 when the OS tries to read from a
> non-existing PHY. Linux expects it to return 0xffff, and believes that
> a PHY is there if 0 is returned. This helps:

Good catch! Please send a patch for this.

>
> diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
> index f03450c028..3c90c38e26 100644
> --- a/hw/net/imx_fec.c
> +++ b/hw/net/imx_fec.c
> @@ -285,7 +285,7 @@ static uint32_t imx_phy_read(IMXFECState *s, int reg)
>      if (phy != s->phy_num) {
>          qemu_log_mask(LOG_GUEST_ERROR, "[%s.phy]%s: Bad phy num %u\n",
>                        TYPE_IMX_FEC, __func__, phy);
> -        return 0;
> +        return 0xffff;
>      }
>
> Note that this is not really a guest error; any OS can and likely
> will scan the MII bus for connected phy chips.

Agree.

Regards,
Bin


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3 3/4] hw/arm: sabrelite: Connect the Ethernet PHY at address 6
  2021-05-01 21:40         ` Philippe Mathieu-Daudé
@ 2021-05-01 23:21           ` Guenter Roeck
  2021-05-02  0:24             ` Bin Meng
  0 siblings, 1 reply; 16+ messages in thread
From: Guenter Roeck @ 2021-05-01 23:21 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Bin Meng
  Cc: Peter Maydell, Bin Meng, qemu-devel@nongnu.org Developers,
	qemu-arm, Jean-Christophe Dubois

On 5/1/21 2:40 PM, Philippe Mathieu-Daudé wrote:
> On 5/1/21 10:12 PM, Guenter Roeck wrote:
>> On 4/30/21 9:28 PM, Bin Meng wrote:
>>> On Fri, Apr 30, 2021 at 10:41 PM Guenter Roeck <linux@roeck-us.net> wrote:
>>>>
>>>> Hi,
>>>>
>>>> On Wed, Jan 06, 2021 at 02:35:03PM +0800, Bin Meng wrote:
>>>>> From: Bin Meng <bin.meng@windriver.com>
>>>>>
>>>>> At present, when booting U-Boot on QEMU sabrelite, we see:
>>>>>
>>>>>   Net:   Board Net Initialization Failed
>>>>>   No ethernet found.
>>>>>
>>>>> U-Boot scans PHY at address 4/5/6/7 (see board_eth_init() in the
>>>>> U-Boot source: board/boundary/nitrogen6x/nitrogen6x.c). On the real
>>>>> board, the Ethernet PHY is at address 6. Adjust this by updating the
>>>>> "fec-phy-num" property of the fsl_imx6 SoC object.
>>>>>
>>>>> With this change, U-Boot sees the PHY but complains MAC address:
>>>>>
>>>>>   Net:   using phy at 6
>>>>>   FEC [PRIME]
>>>>>   Error: FEC address not set.
>>>>>
>>>>> This is due to U-Boot tries to read the MAC address from the fuse,
>>>>> which QEMU does not have any valid content filled in. However this
>>>>> does not prevent the Ethernet from working in QEMU. We just need to
>>>>> set up the MAC address later in the U-Boot command shell, by:
>>>>>
>>>>>   => setenv ethaddr 00:11:22:33:44:55
>>>>>
>>>>
>>>> With this patch in place, the standard Ethernet interface no longer works when
>>>> booting sabrelite Linux images directly (without u-boot) using the following
>>>> qemu command.
>>>>         qemu-system-arm -M sabrelite -kernel arch/arm/boot/zImage
>>>>         ...
>>>>
>>>> The Ethernet interface still instantiates, but packet transfer to the host
>>>> no longer works. Reverting this patch fixes the problem for me.
>>>>
>>>> Is there a qemu command line parameter that is now necessary to instantiate
>>>> the Ethernet interface when booting Linux ?
>>>
>>> Enabling "guest_errors" shows that Linux kernel fec driver is trying
>>> to read PHY at address 0, which is not what we want.
>>>
>>> [imx.fec.phy]imx_phy_read: Bad phy num 0
>>>
>>> The device tree blob of the sabrelite does not contain a node for the
>>> ethernet phy specifying phy address, so I suspect Linux kernel driver
>>> is using default phy address 0 instead.
>>>
>>> Could you please test on a real hardware to see what happens?
>>>
>>
>> The problem is that qemu returns 0 when the OS tries to read from a
>> non-existing PHY. Linux expects it to return 0xffff, and believes that
>> a PHY is there if 0 is returned.
> 
> Correct.
> 

I'll send a patch. Next question is why the Ethernet interfaces on mcimx6ul-evk
and mcimx7d-sabre don't work. I either get no connectivity at all (similar to
the above) or something like

fec 2188000.ethernet eth1: Unable to connect to phy
ifconfig: SIOCSIFFLAGS: No such device

Any idea ?

Thanks,
Guenter


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3 3/4] hw/arm: sabrelite: Connect the Ethernet PHY at address 6
  2021-05-01 23:21           ` Guenter Roeck
@ 2021-05-02  0:24             ` Bin Meng
  2021-05-02  1:37               ` Guenter Roeck
  0 siblings, 1 reply; 16+ messages in thread
From: Bin Meng @ 2021-05-02  0:24 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Peter Maydell, qemu-devel@nongnu.org Developers, Bin Meng,
	Philippe Mathieu-Daudé,
	Jean-Christophe Dubois, qemu-arm

On Sun, May 2, 2021 at 7:21 AM Guenter Roeck <linux@roeck-us.net> wrote:
>
> On 5/1/21 2:40 PM, Philippe Mathieu-Daudé wrote:
> > On 5/1/21 10:12 PM, Guenter Roeck wrote:
> >> On 4/30/21 9:28 PM, Bin Meng wrote:
> >>> On Fri, Apr 30, 2021 at 10:41 PM Guenter Roeck <linux@roeck-us.net> wrote:
> >>>>
> >>>> Hi,
> >>>>
> >>>> On Wed, Jan 06, 2021 at 02:35:03PM +0800, Bin Meng wrote:
> >>>>> From: Bin Meng <bin.meng@windriver.com>
> >>>>>
> >>>>> At present, when booting U-Boot on QEMU sabrelite, we see:
> >>>>>
> >>>>>   Net:   Board Net Initialization Failed
> >>>>>   No ethernet found.
> >>>>>
> >>>>> U-Boot scans PHY at address 4/5/6/7 (see board_eth_init() in the
> >>>>> U-Boot source: board/boundary/nitrogen6x/nitrogen6x.c). On the real
> >>>>> board, the Ethernet PHY is at address 6. Adjust this by updating the
> >>>>> "fec-phy-num" property of the fsl_imx6 SoC object.
> >>>>>
> >>>>> With this change, U-Boot sees the PHY but complains MAC address:
> >>>>>
> >>>>>   Net:   using phy at 6
> >>>>>   FEC [PRIME]
> >>>>>   Error: FEC address not set.
> >>>>>
> >>>>> This is due to U-Boot tries to read the MAC address from the fuse,
> >>>>> which QEMU does not have any valid content filled in. However this
> >>>>> does not prevent the Ethernet from working in QEMU. We just need to
> >>>>> set up the MAC address later in the U-Boot command shell, by:
> >>>>>
> >>>>>   => setenv ethaddr 00:11:22:33:44:55
> >>>>>
> >>>>
> >>>> With this patch in place, the standard Ethernet interface no longer works when
> >>>> booting sabrelite Linux images directly (without u-boot) using the following
> >>>> qemu command.
> >>>>         qemu-system-arm -M sabrelite -kernel arch/arm/boot/zImage
> >>>>         ...
> >>>>
> >>>> The Ethernet interface still instantiates, but packet transfer to the host
> >>>> no longer works. Reverting this patch fixes the problem for me.
> >>>>
> >>>> Is there a qemu command line parameter that is now necessary to instantiate
> >>>> the Ethernet interface when booting Linux ?
> >>>
> >>> Enabling "guest_errors" shows that Linux kernel fec driver is trying
> >>> to read PHY at address 0, which is not what we want.
> >>>
> >>> [imx.fec.phy]imx_phy_read: Bad phy num 0
> >>>
> >>> The device tree blob of the sabrelite does not contain a node for the
> >>> ethernet phy specifying phy address, so I suspect Linux kernel driver
> >>> is using default phy address 0 instead.
> >>>
> >>> Could you please test on a real hardware to see what happens?
> >>>
> >>
> >> The problem is that qemu returns 0 when the OS tries to read from a
> >> non-existing PHY. Linux expects it to return 0xffff, and believes that
> >> a PHY is there if 0 is returned.
> >
> > Correct.
> >
>
> I'll send a patch. Next question is why the Ethernet interfaces on mcimx6ul-evk
> and mcimx7d-sabre don't work. I either get no connectivity at all (similar to
> the above) or something like
>
> fec 2188000.ethernet eth1: Unable to connect to phy
> ifconfig: SIOCSIFFLAGS: No such device
>
> Any idea ?

I don't see these 2 are supported targets of QEMU:
https://wiki.qemu.org/Documentation/Platforms/ARM

Regards,
Bin


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3 3/4] hw/arm: sabrelite: Connect the Ethernet PHY at address 6
  2021-05-02  0:24             ` Bin Meng
@ 2021-05-02  1:37               ` Guenter Roeck
  2021-05-02 13:58                 ` Guenter Roeck
  0 siblings, 1 reply; 16+ messages in thread
From: Guenter Roeck @ 2021-05-02  1:37 UTC (permalink / raw)
  To: Bin Meng
  Cc: Peter Maydell, qemu-devel@nongnu.org Developers, Bin Meng,
	Philippe Mathieu-Daudé,
	Jean-Christophe Dubois, qemu-arm

On 5/1/21 5:24 PM, Bin Meng wrote:
> On Sun, May 2, 2021 at 7:21 AM Guenter Roeck <linux@roeck-us.net> wrote:
>>
>> On 5/1/21 2:40 PM, Philippe Mathieu-Daudé wrote:
>>> On 5/1/21 10:12 PM, Guenter Roeck wrote:
>>>> On 4/30/21 9:28 PM, Bin Meng wrote:
>>>>> On Fri, Apr 30, 2021 at 10:41 PM Guenter Roeck <linux@roeck-us.net> wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> On Wed, Jan 06, 2021 at 02:35:03PM +0800, Bin Meng wrote:
>>>>>>> From: Bin Meng <bin.meng@windriver.com>
>>>>>>>
>>>>>>> At present, when booting U-Boot on QEMU sabrelite, we see:
>>>>>>>
>>>>>>>   Net:   Board Net Initialization Failed
>>>>>>>   No ethernet found.
>>>>>>>
>>>>>>> U-Boot scans PHY at address 4/5/6/7 (see board_eth_init() in the
>>>>>>> U-Boot source: board/boundary/nitrogen6x/nitrogen6x.c). On the real
>>>>>>> board, the Ethernet PHY is at address 6. Adjust this by updating the
>>>>>>> "fec-phy-num" property of the fsl_imx6 SoC object.
>>>>>>>
>>>>>>> With this change, U-Boot sees the PHY but complains MAC address:
>>>>>>>
>>>>>>>   Net:   using phy at 6
>>>>>>>   FEC [PRIME]
>>>>>>>   Error: FEC address not set.
>>>>>>>
>>>>>>> This is due to U-Boot tries to read the MAC address from the fuse,
>>>>>>> which QEMU does not have any valid content filled in. However this
>>>>>>> does not prevent the Ethernet from working in QEMU. We just need to
>>>>>>> set up the MAC address later in the U-Boot command shell, by:
>>>>>>>
>>>>>>>   => setenv ethaddr 00:11:22:33:44:55
>>>>>>>
>>>>>>
>>>>>> With this patch in place, the standard Ethernet interface no longer works when
>>>>>> booting sabrelite Linux images directly (without u-boot) using the following
>>>>>> qemu command.
>>>>>>         qemu-system-arm -M sabrelite -kernel arch/arm/boot/zImage
>>>>>>         ...
>>>>>>
>>>>>> The Ethernet interface still instantiates, but packet transfer to the host
>>>>>> no longer works. Reverting this patch fixes the problem for me.
>>>>>>
>>>>>> Is there a qemu command line parameter that is now necessary to instantiate
>>>>>> the Ethernet interface when booting Linux ?
>>>>>
>>>>> Enabling "guest_errors" shows that Linux kernel fec driver is trying
>>>>> to read PHY at address 0, which is not what we want.
>>>>>
>>>>> [imx.fec.phy]imx_phy_read: Bad phy num 0
>>>>>
>>>>> The device tree blob of the sabrelite does not contain a node for the
>>>>> ethernet phy specifying phy address, so I suspect Linux kernel driver
>>>>> is using default phy address 0 instead.
>>>>>
>>>>> Could you please test on a real hardware to see what happens?
>>>>>
>>>>
>>>> The problem is that qemu returns 0 when the OS tries to read from a
>>>> non-existing PHY. Linux expects it to return 0xffff, and believes that
>>>> a PHY is there if 0 is returned.
>>>
>>> Correct.
>>>
>>
>> I'll send a patch. Next question is why the Ethernet interfaces on mcimx6ul-evk
>> and mcimx7d-sabre don't work. I either get no connectivity at all (similar to
>> the above) or something like
>>
>> fec 2188000.ethernet eth1: Unable to connect to phy
>> ifconfig: SIOCSIFFLAGS: No such device
>>
>> Any idea ?
> 
> I don't see these 2 are supported targets of QEMU:
> https://wiki.qemu.org/Documentation/Platforms/ARM
> 

Reality says otherwise.

$ qemu-system-arm --version
QEMU emulator version 6.0.0 (v6.0.0-25-geac5bb0cc1-dirty)
Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers
$ qemu-system-arm -M ? | grep mcim
mcimx6ul-evk         Freescale i.MX6UL Evaluation Kit (Cortex A7)
mcimx7d-sabre        Freescale i.MX7 DUAL SABRE (Cortex A7)

Guenter


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3 3/4] hw/arm: sabrelite: Connect the Ethernet PHY at address 6
  2021-05-02  1:37               ` Guenter Roeck
@ 2021-05-02 13:58                 ` Guenter Roeck
  0 siblings, 0 replies; 16+ messages in thread
From: Guenter Roeck @ 2021-05-02 13:58 UTC (permalink / raw)
  To: Bin Meng
  Cc: Peter Maydell, qemu-devel@nongnu.org Developers, Bin Meng,
	Philippe Mathieu-Daudé,
	Jean-Christophe Dubois, qemu-arm

On 5/1/21 6:37 PM, Guenter Roeck wrote:
> On 5/1/21 5:24 PM, Bin Meng wrote:
>> On Sun, May 2, 2021 at 7:21 AM Guenter Roeck <linux@roeck-us.net> wrote:
>>>
>>> On 5/1/21 2:40 PM, Philippe Mathieu-Daudé wrote:
>>>> On 5/1/21 10:12 PM, Guenter Roeck wrote:
>>>>> On 4/30/21 9:28 PM, Bin Meng wrote:
>>>>>> On Fri, Apr 30, 2021 at 10:41 PM Guenter Roeck <linux@roeck-us.net> wrote:
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> On Wed, Jan 06, 2021 at 02:35:03PM +0800, Bin Meng wrote:
>>>>>>>> From: Bin Meng <bin.meng@windriver.com>
>>>>>>>>
>>>>>>>> At present, when booting U-Boot on QEMU sabrelite, we see:
>>>>>>>>
>>>>>>>>   Net:   Board Net Initialization Failed
>>>>>>>>   No ethernet found.
>>>>>>>>
>>>>>>>> U-Boot scans PHY at address 4/5/6/7 (see board_eth_init() in the
>>>>>>>> U-Boot source: board/boundary/nitrogen6x/nitrogen6x.c). On the real
>>>>>>>> board, the Ethernet PHY is at address 6. Adjust this by updating the
>>>>>>>> "fec-phy-num" property of the fsl_imx6 SoC object.
>>>>>>>>
>>>>>>>> With this change, U-Boot sees the PHY but complains MAC address:
>>>>>>>>
>>>>>>>>   Net:   using phy at 6
>>>>>>>>   FEC [PRIME]
>>>>>>>>   Error: FEC address not set.
>>>>>>>>
>>>>>>>> This is due to U-Boot tries to read the MAC address from the fuse,
>>>>>>>> which QEMU does not have any valid content filled in. However this
>>>>>>>> does not prevent the Ethernet from working in QEMU. We just need to
>>>>>>>> set up the MAC address later in the U-Boot command shell, by:
>>>>>>>>
>>>>>>>>   => setenv ethaddr 00:11:22:33:44:55
>>>>>>>>
>>>>>>>
>>>>>>> With this patch in place, the standard Ethernet interface no longer works when
>>>>>>> booting sabrelite Linux images directly (without u-boot) using the following
>>>>>>> qemu command.
>>>>>>>         qemu-system-arm -M sabrelite -kernel arch/arm/boot/zImage
>>>>>>>         ...
>>>>>>>
>>>>>>> The Ethernet interface still instantiates, but packet transfer to the host
>>>>>>> no longer works. Reverting this patch fixes the problem for me.
>>>>>>>
>>>>>>> Is there a qemu command line parameter that is now necessary to instantiate
>>>>>>> the Ethernet interface when booting Linux ?
>>>>>>
>>>>>> Enabling "guest_errors" shows that Linux kernel fec driver is trying
>>>>>> to read PHY at address 0, which is not what we want.
>>>>>>
>>>>>> [imx.fec.phy]imx_phy_read: Bad phy num 0
>>>>>>
>>>>>> The device tree blob of the sabrelite does not contain a node for the
>>>>>> ethernet phy specifying phy address, so I suspect Linux kernel driver
>>>>>> is using default phy address 0 instead.
>>>>>>
>>>>>> Could you please test on a real hardware to see what happens?
>>>>>>
>>>>>
>>>>> The problem is that qemu returns 0 when the OS tries to read from a
>>>>> non-existing PHY. Linux expects it to return 0xffff, and believes that
>>>>> a PHY is there if 0 is returned.
>>>>
>>>> Correct.
>>>>
>>>
>>> I'll send a patch. Next question is why the Ethernet interfaces on mcimx6ul-evk
>>> and mcimx7d-sabre don't work. I either get no connectivity at all (similar to
>>> the above) or something like
>>>
>>> fec 2188000.ethernet eth1: Unable to connect to phy
>>> ifconfig: SIOCSIFFLAGS: No such device
>>>
>>> Any idea ?
>>
>> I don't see these 2 are supported targets of QEMU:
>> https://wiki.qemu.org/Documentation/Platforms/ARM
>>
> 
> Reality says otherwise.
> 
> $ qemu-system-arm --version
> QEMU emulator version 6.0.0 (v6.0.0-25-geac5bb0cc1-dirty)
> Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers
> $ qemu-system-arm -M ? | grep mcim
> mcimx6ul-evk         Freescale i.MX6UL Evaluation Kit (Cortex A7)
> mcimx7d-sabre        Freescale i.MX7 DUAL SABRE (Cortex A7)
> 

Anyway, the underlying problem is that the phy chips are not connected
to the MDIO bus associated with each Ethernet controller. In other words,
unlike the current imx fec emulation suggests, there is no 1:1 connection
between Ethernet and phy. This is even mentioned in commit 461c51ad42
("Add a phy-num property to the i.MX FEC emulator"):

"As an example with the i.MX6UL the NXP SOC has 2 Ethernet devices but
 only one MDIO bus on which the 2 related PHY are connected but at unique
 addresses."

Unfortunately that commit doesn't actually solve the problem where 2 Ethernet
devices are connected to a single MDIO bus; it just adds support for setting
the phy address.

I have no idea how to solve that in a clean way in qemu.

Guenter


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-05-02 14:01 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-06  6:35 [PATCH v3 0/4] hw/arm: sabrelite: Improve emulation fidelity to allow booting upstream U-Boot Bin Meng
2021-01-06  6:35 ` [PATCH v3 1/4] hw/misc: imx6_ccm: Update PMU_MISC0 reset value Bin Meng
2021-01-06  6:35 ` [PATCH v3 2/4] hw/msic: imx6_ccm: Correct register value for silicon type Bin Meng
2021-01-06  6:35 ` [PATCH v3 3/4] hw/arm: sabrelite: Connect the Ethernet PHY at address 6 Bin Meng
2021-04-30 14:41   ` Guenter Roeck
2021-05-01  4:28     ` Bin Meng
2021-05-01 13:12       ` Guenter Roeck
2021-05-01 20:12       ` Guenter Roeck
2021-05-01 21:40         ` Philippe Mathieu-Daudé
2021-05-01 23:21           ` Guenter Roeck
2021-05-02  0:24             ` Bin Meng
2021-05-02  1:37               ` Guenter Roeck
2021-05-02 13:58                 ` Guenter Roeck
2021-05-01 23:06         ` Bin Meng
2021-01-06  6:35 ` [PATCH v3 4/4] docs/system: arm: Add sabrelite board description Bin Meng
2021-01-08 12:32 ` [PATCH v3 0/4] hw/arm: sabrelite: Improve emulation fidelity to allow booting upstream U-Boot Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.