Enet Layer 2 CPSW Example
Introduction
The layer 2 cpsw example is dedicated to demonstrate usage of Enet CPSW3G peripheral operation.
This example also demonstrates Rx Scatter-Gather, the buffer size on Rx is kept to 512 bytes. Send packets greater than 512 bytes to exercise scatter-gather on Rx.
This example does the following:
Target-side application running on a Cortex R5F core.
Target-side application running on a Cortex R5F core.
- Application receives the packet, copies the payload into a new packet which is then sent back.
- The application has a menu to enable/disable features, such as getting MAC address and stats. This menu along with application logs is implemented via UART.
Host-side functionality
Software applications like Colasoft Pkt Builder or packETH tool could be used to generate and send packets, Wireshark can be used to receive and verify packet contents
The data path enabled in this example is as follows:
Host side (PC) application sends a packet to MAC port.
Target side application receives the packet, updates the MAC addresses in the Layer-2 header and sends the packet back.
Application like Wireshark (PC) receives the packet and can be seen in the capture window.
Supported Combinations
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
AM64X-EVM
For CPSW based example
Connect a ethernet cable to the EVM from host PC as shown below
\imageStyle{am64x_evm_lwip_example_00.png,width:30%} \image html am64x_evm_lwip_example_00.png Ethernet cable for CPSW based ethernet
AM64X-SK
For CPSW based example
Connect a ethernet cable to the CPSW RGMII 1 port in AM64X-SK from host PC as shown below
\imageStyle{am64x_sk_cpsw_example_00.png,width:40%} \image html am64x_sk_cpsw_example_00.png Ethernet cable for CPSW based ethernet
AM62X-SK
For CPSW based example
Connect a ethernet cable to the EVM from host PC as shown below

AM243X-EVM
For CPSW based example
Connect a ethernet cable to the EVM from host PC as shown below
\imageStyle{am64x_evm_lwip_example_00.png,width:30%} \image html am64x_evm_lwip_example_00.png Ethernet cable for CPSW based ethernet
AM243X-LP
Note
AM243X-LP has two ethernet Ports which can be configured as both CPSW/ICSS ports.
For CPSW based examples
Connect a ethernet cable to the AM243X-LP from host PC as shown below
\imageStyle{am243x_lp_lwip_example_00.png,width:30%} \image html am243x_lp_lwip_example_00.png Ethernet cable for CPSW based ethernet
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.
We can start sending unicast packets from Colasoft Pkt Builder or packETH tool.
In the Colasoft Pkt Builder, click on Add icon , select any layer2 Packet and click ok.
Edit the source and destination address in the decode editor.
Click on send icon and select the ethernet adapater.
Click start, packets will be send to the target.
Capture the packets in Wireshark.

Sample output for Multiport example
==========================
Layer 2 CPSW Test
==========================
Init Enet's OSAL and utils to use defaults
Init memory utils
Create clock and task for periodic tick
Create periodic tick task
Create periodic tick clock
Open Main UDMA driver
Init all peripheral clocks
----------------------------------------------
Enabling clocks!
Init all configs
----------------------------------------------
cpsw-3g: init config
Create RX tasks
----------------------------------------------
cpsw-3g: Create RX task
Open all peripherals
----------------------------------------------
cpsw-3g: Open enet
Attach core id 1 on all peripherals
----------------------------------------------
cpsw-3g: Attach core
cpsw-3g: Open port 1
cpsw-3g: Open port 1 link
cpsw-3g: Open DMA
initQs() txFreePktInfoQ initialized with 16 pkts
cpsw-3g: Waiting for link up...
MAC Port 1: link up
cpsw-3g: Port 1 link is up
cpsw-3g: MAC port addr: f4:84:4c:f9:88:c4
Enet L2 cpsw Menu:
's' - Print statistics
'r' - Reset statistics
'm' - Show allocated MAC addresses
'x' - Stop the test
m
Allocated MAC addresses
----------------------------------------------
cpsw-3g: f4:84:4c:f9:88:c4
s
Print statistics
----------------------------------------------
rxGoodFrames = 92
rxOctets = 9156
txGoodFrames = 92
txBcastFrames = 4
txMcastFrames = 88
txOctets = 9156
octetsFrames64 = 24
octetsFrames65to127 = 134
octetsFrames128to255 = 24
octetsFrames256to511 = 2
netOctets = 18312
txPri[0] = 92
txPriBcnt[0] = 9156
On Wireshark we can see the packets received:
