Apalis iMX8QM Second ethernet

we will be designing a custom carrier board which has the second Ethernet interface from iMX8QM brought out via a KSZ8041 PHY as recommended in the apalis imx8 datasheet.
We are using Torizon with the docker containers. I wanted to know to enable the second Ethernet what changes need to be done.

  1. Are the drivers for the KSZ8041 in the default torizon image or do we have to make a custom torizon image ?
  2. What additional steps need to be done to have the second Ethernet working ? device overlay, network interface configuration ?

Greetings @nkj,

Let me try and answer your questions here one by one.

Are the drivers for the KSZ8041 in the
default torizon image or do we have to
make a custom torizon image?

The default Torizon configuration should have CONFIG_MICREL_PHY which should be the in tree Linux driver for this PHY.

What additional steps need to be done
to have the second Ethernet working ?
device overlay, network interface
configuration ?

Off the top of my head you’ll probably need some kind of configuration in the device tree that encapsulates the PHY so that the kernel can access it. As for network configuration I don’t believe you need anything fancy but this may differ based on how you want to use the interface.

Unfortunately I can’t give you more detailed examples of changes and configuration that you’ll need to do. I don’t believe we have any reference designs or examples of such but I can take another look and perhaps someone else here in Toradex has a better idea.

Best Regards,
Jeremias

would be helpful to have a device tree overlay similar to the one for e.g. offered by the m41t0 RTC

While we don’t have an overlay for a second ethernet on the i.MX8 we do have a reference device tree which implements a second ethernet, but for our Colibri Vybrid modules.

This is a link to the commit which added the device tree support: linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules

So not everything will apply 1 to 1 with the i.MX8 but the general concepts will. For example in the device tree you’ll need to identify an additional fec node to represent the additional ethernet and phy. You’ll also need to mess with the pin muxings to route the needed pins to your phy.

This is the default fec node in the Apalis i.MX8 device tree for comparison: fsl-imx8qm-apalis-v1.1.dtsi « freescale « dts « boot « arm64 « arch - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules

You’ll essentially need to create a 2nd one of these for your other interface/phy. Fore more information on how to interpret the fec device tree node please consult the in kernel documentation here: fsl-fec.txt « net « bindings « devicetree « Documentation - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules

Finally I tried to find specific kernel documentation for the ksz8041, but I couldn’t find any. But I did find general documentation for micrel phys: micrel.txt « net « bindings « devicetree « Documentation - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules

Best Regards,
Jeremias

eth2 schematic
dts overlay

so i am trying to get the overlay for the second ethernet. i have tired to base it of the existing fec1
but i keep getting a syntax error

Error: device-trees/overlays/apalis-imx8_eth2.dts:12.20-21 syntax error                                                 FATAL ERROR: Unable to parse input tree                                                                                 error: cannot apply device-trees/overlays/apalis-imx8_eth2.dts.  

Hi nkj,

I assume you are talking about the Apalis IMX8QM if yes read the text below. Please always specify the SOM module you are talking about!!
Ethernet: !!!
Make sure you have at least IMX8QM V1.1

The Ethernet MAC Interface is only supporting 1.8 to 2.5 volts as specified from now on. All the IMX.8 modules that will final production ones will only be specified for 1.8 or 2.5.

So you interface on the Ethernet side needs to be changed we recommend 1.8 volt.

The secondary Ethernet on the Apalis IMX8 (MAC) is can be switch to 1.8volt or 2.5volt via device tree. The port of the IMX8 will be switched to 1.8volt.

The MDC and MDIO signal remains at 3.3 volts on the iMX8 side.

So you need level shifting from 3.3 to 1.8 of the Switch since you need to operate the switch at 1.8volt.

The reset should also be shifted to 1.8 volts.

The 22 ohms resistor R27 in the clock line RGMII_REF_CLK should be left away or best up there a 0-ohm resistor

the RGMII device we are using here as the Interface need also 1.8 Volt Strapping pull-ups for the configuration.

Here is a little ref. Schematic with an ethernet PHY.

Hi matthias.tx

The Apalis IMX8QM module is in the title of the post and as well in first post environment information section. we are using IMX8QM V1.1 boards. we have as one of the V1.0 series. but we will be using mainly the 1.1 version.

for the second Ethernet port we are using it in RMII mode and not RGMII mode. which according to the datasheet should work as well in 3.3 volts. The KSZ8041 PHY operates in RMII mode.

my question was related to the device tree overlay modifications required to get it working.

I believe the syntax error is due to how you defined the pinctrl_fec2_gpios node. See the device tree here: imx8-apalis-v1.1.dtsi « freescale « dts « boot « arm64 « arch - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules

The pinctrl_fec1 node and really all pinctrl nodes are subnodes of iomuxc and must be defined as such even in overlays. So you probably want it to look something like this: apalis-imx8x_ad7879_overlay.dts « overlays - device-tree-overlays.git - Sources for Device Tree Overlays

Best Regards,
Jeremias

i managed to get further with your help. i am able to deploy this overlay but the system hangs on the starting kernel line and reboots 3 times and switches back to the rollback overlay.

i had to comment the line 59 power-domains = <&pd IMX_SC_R_BOARD_R1>; to get it to built. uncommenting this line gives a syntax error.

U-Boot 2020.04-5.1.0+git.0a26a04408ca (Jan 01 1970 - 00:00:00 +0000)

CPU:   NXP i.MX8QM RevB A53 at 1200 MHz

DRAM:  4 GiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial
Model: Toradex Apalis iMX8 QuadMax 4GB Wi-Fi / BT IT V1.1B, Serial# 06738425

 BuildInfo:
  - SCFW 732e719a, SECO-FW 376e3c15, IMX-MKIMAGE 6745ccdc, ATF
  - U-Boot 2020.04-5.1.0+git.0a26a04408ca

switch to partitions #0, OK
mmc0(part 0) is current device
flash target is MMC:0
Net:   eth0: ethernet@5b040000
Fastboot: Normal
Saving Environment to MMC... Writing to MMC(0)... OK
Normal Boot
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0(part 0) is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
1007 bytes read in 11 ms (88.9 KiB/s)
## Executing script at 83100000
4394 bytes read in 23 ms (186.5 KiB/s)
162801 bytes read in 36 ms (4.3 MiB/s)
35 bytes read in 27 ms (1000 Bytes/s)
Applying Overlay: apalis-imx8_eth2.dtbo
1357 bytes read in 35 ms (37.1 KiB/s)
12136124 bytes read in 296 ms (39.1 MiB/s)
Uncompressed size: 30505472 = 0x1D17A00
9168678 bytes read in 228 ms (38.4 MiB/s)
## Flattened Device Tree blob at 83000000
   Booting using the fdt blob at 0x83000000
   Loading Ramdisk to fcd90000, end fd64e726 ... OK
   Using Device Tree in place at 0000000083000000, end 000000008304afff

Starting kernel ...

apalis-im8_eth2.dts

That’s interesting, though I’m not completely sure of the effects of commenting that line. So with this line commented and with the overlay applied you can boot into the kernel then?

hi jeremias

no, applying the overlay results in the kernel not booting.

i have as well now gotten it to compile with that line enabled by adding the #include but this also results in the kernel not booting.

i have now also tried to just to pin changes only and already this leads to a not booting kernel

// Enable second ethernet on imx8.

/dts-v1/;
/plugin/;

#include <dt-bindings/firmware/imx/rsrc.h>
#include <dt-bindings/pinctrl/pads-imx8qm.h>

/ {
	compatible = "toradex,apalis-imx8";
};


&iomuxc {
	apalis-imx8qm {
			pinctrl_fec2_gpios: fec2gpiosgrp {
						fsl,pins = <
							IMX8QM_COMP_CTL_GPIO_1V8_3V3_ENET_ENETB_PAD	0x000014a0 /* Use pads in 3.3V mode */
							IMX8QM_ENET1_MDC_CONN_ENET1_MDC			 0x06000040
							IMX8QM_ENET1_MDIO_CONN_ENET1_MDIO		0x06000020
							IMX8QM_ENET1_RGMII_TX_CTL_CONN_ENET1_RGMII_TX_CTL	0x06000040
							IMX8QM_ENET1_RGMII_TXC_CONN_ENET1_RCLK50M_IN 0x06000040
							IMX8QM_ENET1_RGMII_TXD0_CONN_ENET1_RGMII_TXD0	0x06000040
							IMX8QM_ENET1_RGMII_TXD1_CONN_ENET1_RGMII_TXD1	0x06000040
							IMX8QM_ENET1_RGMII_RX_CTL_CONN_ENET1_RGMII_RX_CTL	0x06000040
							IMX8QM_ENET1_RGMII_RXD0_CONN_ENET1_RGMII_RXD0	0x06000040
							IMX8QM_ENET1_RGMII_RXD1_CONN_ENET1_RGMII_RXD1	0x06000040
							IMX8QM_ENET1_RGMII_RXD2_CONN_ENET1_RMII_RX_ER	0x06000040
						>;
					};
	};
};

Ah okay I misunderstood your message there.

As for your issue, what I assume is happening is that there’s some kind of pin conflict. Taking a look at the source tree: imx8-apalis-v1.1.dtsi « freescale « dts « boot « arm64 « arch - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules

It seems the pins for this Ethernet interface are used by this pinctrl group as GPIOs. They’re included by this line here: imx8-apalis-v1.1.dtsi « freescale « dts « boot « arm64 « arch - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules

What you can do is redefine the pinctrl-0 here in the overlay. Basically you’ll just copy and paste the definition in the device tree but remove the pinctrl_fec2_gpios, group from the list. This “should” free these pins up for alternate usage.

Best Regards,
Jeremias

thanks for your help. i have a booting kernel and i can see the second ethernet device showing up and i can see the PHY chip being picked up. I dont have the interface working yet but this could be something electrical.

apalis-imx8-06738425:~$ dmesg | grep fec
[    1.586618] fec 5b040000.ethernet: Adding to iommu group 1
[    1.587563] fec 5b050000.ethernet: Adding to iommu group 1
[    1.588541] fec 5b050000.ethernet: Invalid MAC address: 00:00:00:00:00:00
[    1.595352] fec 5b050000.ethernet: Using random MAC address: ae:51:0a:77:45:5a
[    1.596564] libphy: fec_enet_mii_bus: probed
[    1.599629] fec 5b050000.ethernet eth0: registered PHC device 0
[    2.004186] libphy: fec_enet_mii_bus: probed
[    2.008645] fec 5b040000.ethernet eth1: registered PHC device 1
[    6.782953] fec 5b040000.ethernet ethernet0: renamed from eth1
[  103.419724] fec 5b040000.ethernet ethernet0: Link is Up - 100Mbps/Full - flow control rx/tx
apalis-imx8-06738425:~$ dmesg | grep 5b050000
[    1.587563] fec 5b050000.ethernet: Adding to iommu group 1
[    1.588541] fec 5b050000.ethernet: Invalid MAC address: 00:00:00:00:00:00
[    1.595352] fec 5b050000.ethernet: Using random MAC address: ae:51:0a:77:45:5a
[    1.599629] fec 5b050000.ethernet eth0: registered PHC device 0
[    7.992109] Micrel KSZ8041RNLI 5b050000.ethernet-1:01: attached PHY driver [Micrel KSZ8041RNLI] (mii_bus:phy_addr=5b050000.ethern

In our design we are using the clock supplied by the KSZ8041RNLI PHY
besides setting the IMX8QM_ENET1_RGMII_TXC_CONN_ENET1_RCLK50M_IN 0x06000040 is there anything additional that needs to be specified to tell the imx8 MAC to use this external clk

&iomuxc {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_cam1_gpios>, <&pinctrl_dap1_gpios>,
		    <&pinctrl_esai0_gpios>,
		    <&pinctrl_gpio3>, <&pinctrl_gpio4>,
		    <&pinctrl_gpio_usbh_oc_n>, <&pinctrl_lpuart1ctrl>,
		    <&pinctrl_lvds0_i2c0_gpio>, <&pinctrl_lvds1_i2c0_gpios>,
		    <&pinctrl_mipi_dsi_0_1_en>, <&pinctrl_mipi_dsi1_gpios>,
		    <&pinctrl_mlb_gpios>, <&pinctrl_qspi1a_gpios>,
		    <&pinctrl_sata1_act>, <&pinctrl_sim0_gpios>,
		    <&pinctrl_usdhc1_gpios>;
	apalis-imx8qm {
			pinctrl_fec2_gpios: fec2gpiosgrp {
						fsl,pins = <
							IMX8QM_COMP_CTL_GPIO_1V8_3V3_ENET_ENETA_PAD	0x000014a0 /* Use pads in 3.3V mode */
							IMX8QM_ENET1_MDC_CONN_ENET1_MDC			 0x06000040
							IMX8QM_ENET1_MDIO_CONN_ENET1_MDIO		0x06000020
							IMX8QM_ENET1_RGMII_TX_CTL_CONN_ENET1_RGMII_TX_CTL	0x06000040
							IMX8QM_ENET1_RGMII_TXC_CONN_ENET1_RCLK50M_IN 0x06000040
							IMX8QM_ENET1_RGMII_TXD0_CONN_ENET1_RGMII_TXD0	0x06000040
							IMX8QM_ENET1_RGMII_TXD1_CONN_ENET1_RGMII_TXD1	0x06000040
							IMX8QM_ENET1_RGMII_RX_CTL_CONN_ENET1_RGMII_RX_CTL	0x06000040
							IMX8QM_ENET1_RGMII_RXD0_CONN_ENET1_RGMII_RXD0	0x06000040
							IMX8QM_ENET1_RGMII_RXD1_CONN_ENET1_RGMII_RXD1	0x06000040
							IMX8QM_ENET1_RGMII_RXD2_CONN_ENET1_RMII_RX_ER	0x06000040
						>;
					};
	};
};

&fec2 {
	
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_fec2_gpios>;
	//pinctrl-1 = <&pinctrl_fec1_sleep>;
	fsl,magic-packet;
	//fsl,rgmii_txc_dly;
	fsl,mii-exclusive;
	phy-handle = <&ethphy1>;
	phy-mode = "rmii";
	//phy-reset-duration = <10>;
	//phy-reset-gpios = <&lsio_gpio1 11 GPIO_ACTIVE_LOW>;

	mdio {
		#address-cells = <1>;
		#size-cells = <0>;

		ethphy1: ethernet-phy@0 {
			compatible = "ethernet-phy-ieee802.3-c22";
			clock-frequency = <5000000>;
			//micrel,rmii-reference-clock-select-25-mhz;
			//interrupt-parent = <&lsio_gpio1>;
			//interrupts = <29 IRQ_TYPE_LEVEL_LOW>;
			micrel,led-mode = <0>;
			power-domains = <&pd IMX_SC_R_BOARD_R1>;
			max-speed = <100>;
			reg = <1>;
		};
	};
};

&fec2 {
	status="okay";
};

I’m not completely sure if there’s extra configurations required. I checked out some reference device trees like this one: fsl-imx8qxp-enet2-tja1100.dtsi\freescale\dts\boot\arm64\arch - linux-imx - i.MX Linux kernel

And other than setting the RCLK out pin they also seem to set this tja110x,refclk_in; property in the mdio node. This may also be required though I couldn’t find much documentation on this property and it may be hardware specific to the chosen PHY.

Best Regards,
Jeremias

could there be an already existing clock being sent out from the imx8 on that pin ? is there a way to check this on the device tree where the clock is defined for ethernet

Sorry, which pin are you referring to? RCLK_IN or RCLK_OUT? As far as I can these are just 50MHZ reference clocks either from the MAC to the PHY or vice versa depending on in/out.