This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[FAQ] How do I build the native IgH EtherCAT stack for TI microprocessors?

Part Number: AM62

Tool/software:

The IgH EtherCAT stack is an open source EtherCAT stack.

It comes with a generic driver that uses generic Linux ethernet API calls, but is not optimized for specific platforms, and therefore comes with latency.

How do I build the IgH EtherCAT stack with a native driver that is more optomized for TI microprocessors?

  • Building and Testing the IgH EtherCAT Stack

    1. Requirements

    1.1. Hardware Requirements

    Note: the IgH stack has only been verified on kernel version 6.6 on the BeaglePlay. The general build instructions should carry over to other AM6x platforms.

    Item Quantity Description
    BeaglePlay 1 device to act as EtherCAT master
    32GB SD Card 1 SD card to store the boot partition and rootfs
    Beckhoff Slave Devices 1+ devices to act as EtherCAT slaves
    Ethernet cables 1+ N/A

    1.2. Software Requirements

    The following software requirements were what were used to test the stack:

    Item Version Description
    https://git.beagleboard.org/beagleboard/linux  v6.6.32-ti-rt-arm64-r9 linux kernel
    https://gitlab.com/npitre/ethercat.git  master IgH EtherCAT repository
    ti-am65-cpsw-nuss_fixes.patch N/A am65 cpsw driver patch

    2. Setup

    All steps are run on the BeaglePlay.

    Setup build environment:

    sudo apt update
    sudo apt upgrade
    sudo apt install build-essential
    sudo apt install autotools-dev autoconf libtool

    Configure a kernel with the ethernet driver as a module:

    mkdir ~/work
    cd ~/work
    git clone https://git.beagleboard.org/beagleboard/linux
    cd linux
    git checkout origin/v6.6.32-ti-rt-arm64-r9
    make bb.org_defconfig
    ./scripts/config --module CONFIG_TI_K3_AM65_CPSW_NUSS
    patch -p1 < ../../path/to/ti-am65-cpsw-nuss_fixes.patch

    Build the kernel:

    cd ~/work
    # Next command takes about 6 hours to complete on a BeaglePlay.
    # Might consider doing this overnight.
    make -C ./linux -j4 KDEB_PKGVERSION=1ethercat bindeb-pkg

    Install new kernel:

    cd ~/work
    sudo dpkg -i linux-*.deb
    sudo reboot

    Build EtherCAT modules and tools (once new kernel is booted):

    cd ~/work
    git clone https://gitlab.com/npitre/ethercat.git
    cd ethercat
    ./bootstrap
    ./configure --with-linux-dir=$HOME/work/linux --enable-am65cpsw
    make -j4 all modules

    Install EtherCAT modules and tools:

    cd ~/work/ethercat
    sudo make modules_install install
    sudo depmod

    Adjust EtherCAT configuration:

    sudo sed -e '/^DEVICE_MODULES=/s/""/"ti-am65-cpsw-nuss"/' \
    -e '/^MASTER0_DEVICE=/s/""/"ff:ff:ff:ff:ff:ff"/' \
    -i /usr/local/etc/ethercat.conf

    Connect EtherCAT clients and activate EtherCAT:

    sudo systemctl start ethercat

    Example dmesg output:

    ec_master: loading out-of-tree module taints kernel.
    EtherCAT: Master driver 1.6.1 1.6.1-4-gf25dff08
    EtherCAT: 1 master waiting for devices.
    am65-cpsw-nuss 8000000.ethernet eth0: Link is Down
    am65-cpsw-nuss 8000000.ethernet: initializing am65 cpsw nuss version 0x6BA01103, cpsw version 0x6BA81103 Ports: 3 quirks:00000002
    am65-cpsw-nuss 8000000.ethernet: Use random MAC address
    am65-cpsw-nuss 8000000.ethernet: initialized cpsw ale version 1.5
    am65-cpsw-nuss 8000000.ethernet: ALE Table size 512
    am65-cpsw-nuss 8000000.ethernet: CPTS ver 0x4e8a010c, freq:500000000, add_val:1 pps:0
    am65-cpsw-nuss 8000000.ethernet: set new flow-id-base 19
    EtherCAT: Accepting 34:08:E1:84:EE:88 as main device for master 0.
    am65-cpsw-nuss 8000000.ethernet ecm0 (uninitialized): PHY [gpio-0:00] driver [RTL8211F-VD Gigabit Ethernet] (irq=POLL)
    am65-cpsw-nuss 8000000.ethernet ecm0 (uninitialized): configuring for phy/rgmii-rxid link mode
    EtherCAT 0: Starting EtherCAT-IDLE thread.
    am65-cpsw-nuss 8000000.ethernet eth0: PHY [gpio-0:01] driver [TI DP83TD510E] (irq=POLL)
    am65-cpsw-nuss 8000000.ethernet eth0: configuring for phy/rmii link mode
    EtherCAT 0: Link state of ecm0 changed to UP.
    am65-cpsw-nuss 8000000.ethernet ecm0 (uninitialized): Link is Up - 100Mbps/Full - flow control off
    EtherCAT 0: 2 slave(s) responding on main device.
    EtherCAT 0: Slave states on main device: PREOP.
    EtherCAT 0: Scanning bus.
    EtherCAT 0: Bus scanning completed in 24 ms.
    EtherCAT 0: Using slave 0 as DC reference clock.
    EtherCAT 0: Starting EoE thread.

    View ethercat slave information:

    sudo ethercat slaves --verbose
    === Master 0, Slave 0 ===
    Device: Main
    State: PREOP
    Flag: +
    Identity:
      Vendor Id:       0xe000059d
      Product code:    0x54490025
      Revision number: 0x00010000
      Serial number:   0x00000000
    DL information:
      FMMU bit operation: no
      Distributed clocks: yes, 64 bit
      DC system time transmission delay: 0 ns
    Port  Type  Link  Loop    Signal  NextSlave  RxTime [ns]  Diff [ns]   NextDc [ns]
       0  MII   up    open    yes             -   2414441201           0           0
       1  MII   up    open    yes             1   2414442631        1430         715
       2  N/A   down  closed  no              -            -           -           -
       3  N/A   down  closed  no              -            -           -           -
    Mailboxes:
      Bootstrap RX: 0x1000/256, TX: 0x1200/256
      Standard  RX: 0x1000/256, TX: 0x1100/256
      Supported protocols: AoE, EoE, CoE, FoE
    General:
      Group: EtherCAT Toolkit
      Image name: 
      Order number: TI EtherCAT Toolkit for AM243X.R5F
      Device name: TI EtherCAT Toolkit for AM243X.R5F
      CoE details:
        Enable SDO: yes
        Enable SDO Info: yes
        Enable PDO Assign: no
        Enable PDO Configuration: yes
        Enable Upload at startup: yes
        Enable SDO complete access: yes
      Flags:
        Enable SafeOp: no
        Enable notLRW: no
      Current consumption: 0 mA
    === Master 0, Slave 1 ===
    Device: Main
    State: PREOP
    Flag: +
    Identity:
      Vendor Id:       0xe000059d
      Product code:    0x54490025
      Revision number: 0x00010000
      Serial number:   0x00000000
    DL information:
      FMMU bit operation: no
      Distributed clocks: yes, 64 bit
      DC system time transmission delay: 715 ns
    Port  Type  Link  Loop    Signal  NextSlave  RxTime [ns]  Diff [ns]   NextDc [ns]
       0  MII   up    open    yes             0    165220880           0         715
       1  MII   down  closed  no              -            -           -           -
       2  N/A   down  closed  no              -            -           -           -
       3  N/A   down  closed  no              -            -           -           -
    Mailboxes:
      Bootstrap RX: 0x1000/256, TX: 0x1200/256
      Standard  RX: 0x1000/256, TX: 0x1100/256
      Supported protocols: EoE, CoE, FoE
    General:
      Group: EtherCAT Toolkit
      Image name: 
      Order number: TI EtherCAT Toolkit for AM243X.R5F
      Device name: TI EtherCAT Toolkit for AM243X.R5F
      CoE details:
        Enable SDO: yes
        Enable SDO Info: yes
        Enable PDO Assign: no
        Enable PDO Configuration: yes
        Enable Upload at startup: yes
        Enable SDO complete access: yes
      Flags:
        Enable SafeOp: no
        Enable notLRW: no
      Current consumption: 0 mA