TechNexion-customization / ubuntu-tn-imx

GNU General Public License v3.0
23 stars 16 forks source link

Preempt_RT kernel and TSN support for edm-g-imx8mp Boards #15

Closed morteza1984 closed 2 years ago

morteza1984 commented 2 years ago

Dear TechNexion,

I have two EDM-G-IMX8M-PLUS boards with original Ubuntu which are used in a real-time application. Using Preempt_RT is a must because of the signal jitter. Is there an easy way to use/integrate the preempt_rt pach in the build process described here? I think the correct patch would be: https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patch-5.4.70-rt40.patch.gz

Could you help with this? Thank you and best regards, Morteza RealtimeIT MHF GmbH

richard-hu commented 2 years ago

Dear, Morteza:

Officially, Preempt_RT patch isn't supported by default. But we are willing to prompt EDM-G-IMX8M-PLUS and enable more feature for it. Would you mind sharing your project information to TechNexion support team? I will pass your information to TechNexion support team and they will contact you soon. :)

By the way, we will release new BSP based on Linux 5.10.72.2.2.0 in the end of January。 Then, the next kernel will be Linux 5.15.x. (Probably will be released in the bottom of this year, 2022Q3 or 2022Q4). As far as i know, most of Preempt_RT patches are merged to Linux 5.15.

BR,

Richard

morteza1984 commented 2 years ago

Dear Richard,

Thank you for the information. In our project, we develop a TSN-based demo application and use the EDM-G-IMX8M-PLUS boards as TSN end-stations (because of the hardware support especially TAPRIO) to send and receive low-jitter traffic. One board receives signal from a Motor using GPIO and sends this data based on the Qbv Schedules to the receiver board while the network is full of lower priority non-real-time traffic. To achieve an End-to-End jitter below 30 Microseconds, the preempt_rt capability is a must on both boards.

Best regards, Morteza

richard-hu commented 2 years ago

Hi, @morteza1984 :

We have some experience to help customer enable Preempt-RT feature on Linux 4.14.

Besides applying Preempt-RT, it requires to adjust kernel defconfig to disable display/graphics related drivers to avoid kernel Oops.

I just create a kernel branch to work on it. https://github.com/TechNexion-customization/linux-imx-tn/commits/tn-imx_5.4.70_2.3.0-rt

The good start is the RT patch is merged without conflicts.

But I can't guarantee when it will be done and if the latency is accepted in your use case.

BR,

Richard

morteza1984 commented 2 years ago

Dear Richard,

Thank you very much for the update! I am able to boot the preempt_rt patched kernel with the following additional defconfig options:

CONFIG_EXPERT=y CONFIG_ARCH_SUPPORTS_RT=y CONFIG_PREEMPT=y CONFIG_PREEMPT_RT=y

Regarding realtime and the promised TSN features of the board, I observe that the ENET driver does not appear after booting but stmmac. I see the following output:

ubuntu@technexion:~$ dmesg | grep ethernet [ 0.200785] imx-dwmac 30bf0000.ethernet: IRQ eth_lpi not found [ 0.200888] imx-dwmac 30bf0000.ethernet: no reset control found [ 0.201034] imx-dwmac 30bf0000.ethernet: User ID: 0x10, Synopsys ID: 0x51 [ 0.201041] imx-dwmac 30bf0000.ethernet: DWMAC4/5 [ 0.201047] imx-dwmac 30bf0000.ethernet: DMA HW capability register supported [ 0.201051] imx-dwmac 30bf0000.ethernet: RX Checksum Offload Engine supported [ 0.201054] imx-dwmac 30bf0000.ethernet: TX Checksum insertion supported [ 0.201058] imx-dwmac 30bf0000.ethernet: Wake-Up On Lan supported [ 0.201084] imx-dwmac 30bf0000.ethernet: Enable RX Mitigation via HW Watchdog Timer [ 0.201090] imx-dwmac 30bf0000.ethernet: Enabled Flow TC (entries=8) [ 0.201099] imx-dwmac 30bf0000.ethernet: Enabling HW TC (entries=256, max_off=256) [ 0.201732] imx-dwmac 30bf0000.ethernet: Cannot register the MDIO bus [ 0.201737] imx-dwmac 30bf0000.ethernet: stmmac_dvr_probe: MDIO bus (id: 1) registration failed [ 0.854046] imx-dwmac 30bf0000.ethernet: IRQ eth_lpi not found [ 0.854134] imx-dwmac 30bf0000.ethernet: no reset control found [ 0.854595] imx-dwmac 30bf0000.ethernet: User ID: 0x10, Synopsys ID: 0x51 [ 0.854602] imx-dwmac 30bf0000.ethernet: DWMAC4/5 [ 0.854608] imx-dwmac 30bf0000.ethernet: DMA HW capability register supported [ 0.854612] imx-dwmac 30bf0000.ethernet: RX Checksum Offload Engine supported [ 0.854616] imx-dwmac 30bf0000.ethernet: TX Checksum insertion supported [ 0.854619] imx-dwmac 30bf0000.ethernet: Wake-Up On Lan supported [ 0.854623] imx-dwmac 30bf0000.ethernet: Enable RX Mitigation via HW Watchdog Timer [ 0.854629] imx-dwmac 30bf0000.ethernet: Enabled Flow TC (entries=8) [ 0.854638] imx-dwmac 30bf0000.ethernet: Enabling HW TC (entries=256, max_off=256) [ 75.421857] imx-dwmac 30bf0000.ethernet eth0: PHY [stmmac-1:01] driver [Atheros 8035 ethernet] [ 75.428040] imx-dwmac 30bf0000.ethernet eth0: No Safety Features support found [ 75.428065] imx-dwmac 30bf0000.ethernet eth0: IEEE 1588-2008 Advanced Timestamp supported [ 75.428724] imx-dwmac 30bf0000.ethernet eth0: registered PTP clock [ 75.428739] imx-dwmac 30bf0000.ethernet eth0: configuring for phy/rgmii-id link mode [ 79.529940] imx-dwmac 30bf0000.ethernet eth0: Link is Up - 1Gbps/Full - flow control off [ 426.656972] imx-dwmac 30bf0000.ethernet eth0: Link is Down

I am somehow confused. The imx8 plus chip is supposed to offer TSN capability through the ENET driver:

https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/AVB-TSN-demo-on-i-MX8MP/ta-p/1123791#toc-hId-1588139873

However, it looks like the stmmac supports TSN features too:

https://lkml.org/lkml/2019/12/18/290

Which one is the correct driver and how can ENET be loaded (if required at all)?

Thank you and best regards, Morteza

richard-hu commented 2 years ago

@morteza1984

Sorry for the late reply. (Switch back from other project.) From the description from i.mx8MP TRM https://www.nxp.com/webapp/Download?colCode=IMX8MPRM, 圖片 There are two ethernet MACs(ENET) in i.mx8MP. Only ENET2 support TSN and ENET2 uses the dwmac IP from Snopsys.

It corresponds to the eqos node in DTS. arch/arm64/boot/dts/freescale/imx8mp-edm-g.dtsi `&eqos { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_eqos>; phy-mode = "rgmii-id"; phy-handle = <&ethphy0>; status = "okay";

mdio {
    compatible = "snps,dwmac-mdio";
    #address-cells = <1>;
    #size-cells = <0>;

    ethphy0: ethernet-phy@1 {
        /* Atheros AR8035 PHY */
        compatible = "ethernet-phy-ieee802.3-c22";
        reset-assert-us = <10000>;
        reset-deassert-us = <30000>;
        reset-gpios = <&gpio1 9 GPIO_ACTIVE_LOW>;
        reg = <1>;
        eee-broken-1000t;
        at803x,eee-disabled;
        at803x,vddio-1p8v;
    };
};

}; The ethernet driver isdrivers/net/ethernet/stmicro/stmmac/stmmac_platform.c`

ENET1 uses FEC IP from NXP itself. It doesn't support TSN.

BR,

Richard

morteza1984 commented 2 years ago

Thank you for the information. I will test it. Best regards, Morteza

morteza1984 commented 2 years ago

I tested the TSN functionality in 5.4.70. The basic functionality of TAPTIO is enabled but the stmmac driver for this kernel version is too old and has issues e.g. with cycle base times in the past. There are many improvements for stmmac in newer kernel versions. I also tested the latest 5.10.72 kernel and TAPRIO is working perfectly (because of the newer driver).

richard-hu commented 2 years ago

@morteza1984

It's great to hear TAPRIO works perfectly in Linux 5.10.72.

It's might be a good idea if we can integrate RT patches in Yocto BSP meta layer to provide RT linux. We are still improving Linux 5.10.72 BSP and will make second release in Q2. Please feel free to give feedback.

Thanks for sharing the experience. :)

BR,

Richard