AM243x MCU+ SDK  08.01.00
LwIP with Ethernet Example

Introduction

This example is a TCP/UDP IP application using the LwIP networking stack, coupled with ethernet driver (ENET)

On AM243X, we can do ethernet based communication using two different underlying HW mechanisms

  • CPSW
    • This is a standard ethernet switch + port HW
  • ICSS
    • This is a firmware enabled ethernet switch + port HW
    • This HW can be used with industrial communication protocols as well (see Industrial Communications Toolkit)
    • In this example we use ICSS as a standard ethernet port

Both use the same ethernet driver underneath with LwIP TCP/IP networking stack

The examples do below

  • Initializes the ethernet driver for the underlying HW
  • Initializes the LwIP stack for TCP/UDP IP
  • Allows user to run and test basic networking features like DHCP, ping, iperf with TCP/UDP.

Supported Combinations

Parameter Value
CPU + OS r5fss0-0_freertos
Toolchain ti-arm-clang
Boards am243x-evm, am243x-lp
Example folder examples/networking/lwip/enet_lwip_cpsw
examples/networking/lwip/enet_lwip_icssg

Steps to Run the Example

Build the example

  • When using CCS projects to build, import the CCS project for the required combination and build it using the CCS project menu (see Using SDK with CCS Projects).
  • When using makefiles to build, note the required combination and build using make command (see Using SDK with Makefiles)

HW Setup

Note
Make sure you have setup the EVM with cable connections as shown here, EVM Setup. In addition do below steps.

AM243X-EVM

For CPSW based example

  • Connect a ethernet cable to the EVM from host PC as shown below

Ethernet cable for CPSW based ethernet

For ICSS based example

  • Connect a ethernet cable to the EVM from host PC as shown below

Ethernet cable for ICSS based ethernet

AM243X-LP

Note
AM243X-LP has two ethernet Ports which can be configured as both CPSW/ICSS ports.

For CPSW/ICSS based examples

  • Connect a ethernet cable to the AM243X-LP from host PC as shown below

Ethernet cable for CPSW/ICSS based ethernet

Create a network between EVM and host PC

  • The EVM will get an IP address using DHCP, so make sure to connect the other end of the cable to a network which has a DHCP server running.
  • To get started one can create a simple local network between the EVM and the host PC by using a home broadband/wifi router as shown below. Most such routers run a DHCP server

Local network between PC and EVM
  • To check the router connection with host PC, recommend to disconnect all other networking conenctions on the PC, sometimes you may need to disable firewall SW, and make sure the router is able to assign a IP address to your host PC
  • After we run the example on the EVM (next step), the EVM will similarly be assigned a IP address, and then host can communicate with the EVM using the assigned IP address.

Run the example

Attention
If you need to reload and run again, a CPU power-cycle is MUST
  • Launch a CCS debug session and run the example executable, see CCS Launch, Load and Run
  • You will see logs in the UART terminal as shown in the next section.
  • Note the IP address seen in the log, this is what we will use to communicate with the EVM.

Sample output for CPSW example

==========================
ENET LWIP App
==========================
Enabling clocks!
Starting lwIP, local interface IP is dhcp-enabled
EnetAppUtils_reduceCoreMacAllocation: Reduced Mac Address Allocation for CoreId:1 From 8 To 1
CPSW_3G Test on MAIN NAVSS
EnetPhy_bindDriver: PHY 0: OUI:080028 Model:23 Ver:01 <-> 'dp83867' : OK
PHY 0 is alive
Host MAC address: f4:84:4c:f9:4d:29
[LWIPIF_LWIP] CPSW has been started successfully
[LWIPIF_LWIP] NETIF INIT SUCCESS
status_callback==UP, local interface IP is 0.0.0.0
UDP server listening on port 5001
Cpsw_handleLinkUp: Port 1: Link up: 100-Mbps Full-Duplex
MAC Port 1: link up
link_callback==UP
status_callback==UP, local interface IP is 192.168.1.100

Sample output for ICSS example

==========================
ENET LWIP App
==========================
Enabling clocks!
Starting lwIP, local interface IP is dhcp-enabled
ICSSG Dual MAC Test
PHY 3 is alive
Host MAC address: 70:ff:76:1d:92:c1
[LWIPIF_LWIP] CPSW has been started successfully
[LWIPIF_LWIP] NETIF INIT SUCCESS
status_callback==UP, local interface IP is 0.0.0.0
UDP server listening on port 5001
EnetPhy_bindDriver: PHY 15: OUI:080028 Model:0f Ver:01 <-> 'dp83867' : OK
Icssg_handleLinkUp: icssg1-1: Port 1: Link up: 100-Mbps Full-Duplex
link_callback==UP
status_callback==UP, local interface IP is 192.168.1.101

Communicate with the EVM using ethernet

  • Firstly you can try to reach the EVM using ping as shown below, using a command shell on the host PC
      > ping 192.168.1.100
    
  • Next you can run iperf tests as shown below. Below steps have been tried with a Linux Ubuntu 18.04 host PC running bash shell
    • Install iperf if not installed by doing below
       > sudo apt install iperf
      
    • Invoke iperf to test TCP bi-directional RX+TX connection as shown below
      > iperf -c 192.168.1.100 -i 5 -t 20 -d

Troubleshooting issues

  • If you see MAC address as 00:00:00:00:00:00, likely you are using a very early Si sample which does not have MAC address "fused" in, in this case do below steps
    • Open file source\networking\enet\soc\j7x\am64x_am243x\enet_soc.c
    • Uncomment below line
      #define ENET_MAC_ADDR_HACK (TRUE)
    • Rebuild the libraries and examples (Using SDK with Makefiles)
  • If you see a valid, non-zero MAC address but IP address is 0.0.0.0 then
    • Make sure you see link_callback==UP message, if not check the ethernet cable
    • Check the local network and check if the DHCP server is indeed running as expected
    • When using a home broadband/wifi router, its possible to check the clients connected to the DHCP server via a web browser. Check your router user manual for more details.

See Also

Networking