Introduction
The layer 2 cpsw example is dedicated to demonstrate usage of Enet CPSW3G peripheral operation.
On AM263PX, 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 2 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, r5fss0-1_freertos |
Toolchain | ti-arm-clang |
Boards | am263px-cc, am263px-lp, am263px-cc-addon-auto |
Example folder | source/networking/enet/core/examples/enet_layer2_cpsw/V1 |
For support on am263px-cc-addon-auto, please refer Ethernet Add-on Boards
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 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:
Wireshark log for Layer 2 CPSW Example
See Also
Ethernet And Networking