Set ethernet speed on both ethernet ports for Apalis i.MX8 Yocto Linux

Hi All,

We are using Toradex Reference Image on Apalis i.MX8 using Yocto project.
We are trying to get and set network speed on both the ethernet ports eth0 and eth1.
We are able to get the ethernet speed using “ethtool” command.

root@apalis-imx8-07107218:~# ethtool eth0
Settings for eth0:
	Supported ports: [ TP MII ]
	Supported link modes:   10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	Supported pause frame use: Symmetric
	Supports auto-negotiation: Yes
	Supported FEC modes: Not reported
	Advertised link modes:  10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	Advertised pause frame use: Symmetric
	Advertised auto-negotiation: Yes
	Advertised FEC modes: Not reported
	Link partner advertised link modes:  10baseT/Half 10baseT/Full 
	                                     100baseT/Half 100baseT/Full 
	Link partner advertised pause frame use: Symmetric Receive-only
	Link partner advertised auto-negotiation: Yes
	Link partner advertised FEC modes: Not reported
	Speed: 100Mb/s
	Duplex: Full
	Port: MII
	PHYAD: 1
	Transceiver: internal
	Auto-negotiation: on
	Supports Wake-on: d
	Wake-on: d
	Link detected: yes

For setting the ethernet speed we are using below command:
ethtool -s eth0 speed 10 duplex half autoneg off
This command is setting the speed as 10 Mbps

root@apalis-imx8-07107218:~# ethtool eth0                                    
Settings for eth0:
	Supported ports: [ TP MII ]
	Supported link modes:   10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	Supported pause frame use: Symmetric
	Supports auto-negotiation: Yes
	Supported FEC modes: Not reported
	Advertised link modes:  10baseT/Half 
	Advertised pause frame use: Symmetric
	Advertised auto-negotiation: No
	Advertised FEC modes: Not reported
	Speed: 10Mb/s
	Duplex: Half
	Port: MII
	PHYAD: 1
	Transceiver: internal
	Auto-negotiation: off
	Supports Wake-on: d
	Wake-on: d
	Link detected: yes
root@apalis-imx8-07107218:~#

But on reboot, the ethernet speed is reset to previous value (100 Mbps).
Is there any other way to set the ethernet speed permanently and retain is even after reboot?

Regards,
Prathamesh Kulkarni

Hi All,

Can anyone please help me on this?

Regards,
Prathamesh Kulkarni

Hi @prathamesh.kulkarni

Welcome to toradex community.
have you tried configuring the phy speed in the devicetree with max-speed flag?
https://elixir.bootlin.com/linux/v5.4.193/source/Documentation/devicetree/bindings/net/ethernet-phy.yaml#L59

But on reboot, the ethernet speed is reset to previous value (100 Mbps)

Write simple service which will auto start for every boot.
Please refer to the how-to-autorun-application-at-the-start-up-in-linux for more details.

Thanks @ashok.tx we need to make the ethernet speed configurable through user application.
We are able to set the speed using systemd service. But is there any way by which we can set the ethernet speed manually and retain it after reboot?
Is there any way to set the ethernet speed using connmanctl service?

Regards,
Prathamesh Kulkarni

Hello All,

I am able to set the ethernet speed using ethtool command. It works fine for 10 Mbps and 100 Mbps. On my device eth1 supports 1000 Mbps speed. So I am trying to set the ethernet speed to 1000 Mbps using below command.

root@apalis-imx8-07107218:~# ethtool -s eth1 speed 1000 duplex full autoneg off
root@apalis-imx8-07107218:~#
root@apalis-imx8-07107218:~# ethtool eth1
Settings for eth1:
	Supported ports: [ TP MII ]
	Supported link modes:   10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	Supported pause frame use: Symmetric
	Supports auto-negotiation: Yes
	Supported FEC modes: Not reported
	Advertised link modes:  1000baseT/Full 
	Advertised pause frame use: Symmetric
	Advertised auto-negotiation: No
	Advertised FEC modes: Not reported
	Speed: 1000Mb/s
	Duplex: Full
	Port: MII
	PHYAD: 7
	Transceiver: internal
	Auto-negotiation: off
	Supports Wake-on: g
	Wake-on: d
	Link detected: no

But when eth1 speed is set to 1000Mbps, eth1 goes down and never comes up till I change the speed to 100Mbps.

Our network supports 1Gbps ethernet speed.
Any idea why eth1 gets down when speed is set to 1000Mbps?
Also I need to test the ethernet speed on my device Apalis I.MX8 board.
Is there any way to test the ethernet speed?

Regards,
Prathamesh Kulkarni

Hi All,

Could you please share your inputs on this?

Regards,
Prathamesh Kulkarni

Hi @prathamesh.kulkarni

Happy new year.Sorry for the late reply.
Could you provide the 2ed ethernet phy partnumber and the changes that you have made in the devicetree.Aslo attach the dmesg log.
What is the default speed that you are getting?

Please have a look at iperf3 tool for network bandwidth testing.

Hi @ashok.tx ,
The eth1 is embedded on SOM itself and eth0 is the external its part number is
KSZ8041RNLI-TR. I am getting the issue on eth1.
Below are the changes in device tree.

/* Apalis GLAN */
&fec1 {
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&pinctrl_fec1>;
	pinctrl-1 = <&pinctrl_fec1_sleep>;
	fsl,magic-packet;
	fsl,mii-exclusive;

	phy-handle = <&ethphy0>;
	phy-mode = "rgmii-id";

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

		ethphy0: ethernet-phy@7 {
			compatible = "ethernet-phy-ieee802.3-c22";
			interrupt-parent = <&lsio_gpio1>;
			interrupts = <29 IRQ_TYPE_LEVEL_LOW>;
			micrel,led-mode = <0>;
			reg = <7>;
			reset-assert-us = <2>;
			reset-deassert-us = <2>;
			reset-gpios = <&lsio_gpio1 11 GPIO_ACTIVE_LOW>;
			reset-names = "phy-reset";
                        max-speed = <1000>;
		};
	};
};

&fec2 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_fec2_gpios>;
        phy-handle = <&ethphy1>;
        phy-mode = "rmii";
	status = "okay";

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

                ethphy1: ethernet-phy@0 {
                        compatible = "ethernet-phy-ieee802.3-c22";
			/*clock-frequency = <5000000>;*/
                        micrel,led-mode = <0>;
			/*power-domains = <&pd IMX_SC_R_BOARD_R1>;*/
			max-speed = <100>;
                        reg = <1>;
                };
        };

};

If I set the eth1 speed to 1000Mbps from device tree, it sets to 1000Mbps and works fine. But if I try to set the speed to 1000Mbps from command line then I am facing above mentioned issue.

Thanks,
Prathamesh Kulkarni

Hi @prathamesh.kulkarni

Set the Auto-negotiation to on and try i.e
ethtool -s eth0 autoneg on speed 1000 duplex full