Introduction
The layer 2 cpsw example is dedicated to demonstrate usage of Enet CPSW3G peripheral operation.
On AM263X, we can do ethernet based communication using CPSW as HW mechanism
- CPSW is a standard ethernet switch + port HW
- It uses ethernet driver underneath with LwIP TCP/IP networking stack
- The appication as of now works with Port 1 only.
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 do below:
- 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 are 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
Parameter | Value |
CPU + OS | r5fss0-0_freertos |
Toolchain | ti-arm-clang |
Boards | am263x-cc, am263x-lp |
Example folder | source/networking/enet/core/examples/enet_layer2_cpsw/V1 |
Packet pool configuration
To change packet pool configuration from syscfg, please refer to Ethernet Packet Pool Allocation Guidelines
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.
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.
Colasoft Pkt Builder to generate and send packets.
Sample output for Multiport example
==========================
Layer 2 CPSW Test
==========================
Init all peripheral clocks
----------------------------------------------
Create RX tasks
----------------------------------------------
cpsw-3g: Create RX task
Open all peripherals
----------------------------------------------
cpsw-3g: Open enet
Init all configs
----------------------------------------------
cpsw-3g: init config
Link Status Changed. PHY: 0x0, state: up
Open MAC port 1
EnetPhy_bindDriver:1873
PHY 0 is alive
PHY 3 is alive
Attach core id 0 on all peripherals
----------------------------------------------
cpsw-3g: Attach core
cpsw-3g: Open DMA
initQs() txFreePktInfoQ initialized with 16 pkts
cpsw-3g: Waiting for link up...
Cpsw_handleLinkUp:1653
MAC Port 1: link up
cpsw-3g: MAC port addr: f4:84:4c:fc:34:fe
Enet L2 cpsw Menu:
's' - Print statistics
'r' - Reset statistics
'm' - Show allocated MAC addresses
'x' - Stop the test
Allocated MAC addresses
----------------------------------------------
cpsw-3g: f4:84:4c:fc:34:fe
s
Print statistics
----------------------------------------------
rxGoodFrames = 5
rxOctets = 340
txGoodFrames = 5
txBcastFrames = 5
txOctets = 320
octetsFrames64 = 5
octetsFrames65to127 = 5
netOctets = 660
txPri[0] = 5
txPriBcnt[0] = 320
cpsw-3g - Port 1 statistics
--------------------------------
rxGoodFrames = 5
rxBcastFrames = 5
rxOctets = 320
txGoodFrames = 5
txOctets = 340
octetsFrames64 = 5
octetsFrames65to127 = 5
netOctets = 660
aleUnknownBcast = 1
aleUnknownBcastBcnt = 64
txPri[0] = 5
txPriBcnt[0] = 340
- On Wireshark we can see the packets received:
Wireshark log for Layer 2 CPSW Example
See Also
Ethernet And Networking