AM261x MCU+ SDK: USB NCM Example

| AM261x MCU+ SDK 26.00.00 |

USB NCM Example

# Introduction

- This examples demonstrates the use of TinyUSB NCM DEV Class driver. Its implements all the necessary callbacks that are required by TinyUSB NCM DEV class driver.

- Network Control Model (NCM) is a USB standard protocol that facilitates the transfer of Ethernet frames over a USB connection, enabling devices to function as network adapters. For more details, refer to the NCM Specification.

  NCM Example Block diagram
- This example integrates LWIP HTTPD webserver running on r5fss0-0 core with TinyUSB NCM class dirver. The class driver's job is to collect the ethernet frames comming over USB and forward it to the Lwip web server and vice versa.

Note
  In this example we receive one ethernet packet at a time from NCM class driver and forward it to Lwip webeserver. This is a simplified design to demonstrate the use of NCM net class driver thus to achive better throughput, further optimizations are required.

- This example also implements a DHCP server which will provide a static ip address to HTTPD web server.Moreover it allocates ip address to the NCM Host PC as well.
- Refer Enet LwIP HTTP Server On Bare Metal (No-RTOS) to know more about http web server using lwip( TCP/IP) stack.
- Once NCM device enumearation is successful, AM261x-LP will be recognised as a separate network interface. The Network interface driver on the Host side will convert and transfer the ethernet traffic Via USB bus as per NCM protocol specification.
- To enable USB Logging for this example refer USB CDC Echo Example

# Supported Combinations

Parameter | Value
--- | ---
CPU + OS | r5fss0-0_nortos
r5fss0-0_freertos
Toolchain | ti-arm-clang
iar-arm
Boards | am261x-som, am261x-lp
Example folder | examples/usb/device/ncm

# 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 IAR EW projects to build, import the IAR EW workspace for the required combination and build it using the IAR EW project menu (see Using SDK with IAR Embedded Workbench Projects).
- When using makefiles to build, note the required combination and build using make command (see Using SDK with Makefiles)

## HW Setup

### AM261x-LP

- To test the application, one can use a Windows/Linux PC as a USB host.
- Connect the J10 on AM261x-LP to the USB host.

USB Micro B Device Connector

### AM261X-SOM

- To test the application, one can use a Windows/Linux PC as a USB host
- Connect the J7 on AM261x SOM to the USB host

USB Micro B Device Connector

## Run the example

- Launch a CCS or IAR EW debug session and run the executable, see CCS Launch, Load and Run or IAR Launch, Load and Run
- When application is running observe that ncm network device is detected by HOST PC ( Windows/linux)
- If the enumeration is successful the following should be displayed on console.

Windows

- Open command prompt and execute ipconfig. User should see a new network interface detected.

NCM Device Enumeration log

Note
  - NCM Windows driver might be readily available. Follow link to download and install the NCM host class driver for windows.

Linux

- Open terminal and execute dmesg command. User should see a new network interface over USB detected.

NCM Device Enumeration log.

#### NCM Download

- Open any web browser application and post following http request.

  http://192.168.7.1

Note
  - Note that this IP address to host PC and device running lwip webserver will be provided by the dhcp server running along with lwip httpd. Refer Introduction

When the http get request will be successful, following HTML page will be display.

HTTP Get request via USB( NCM ) successful

# See Also

USB