1.2 TCP/IP Berkeley TCP Server

The Berkeley TCP Server configuration demonstrates creating a creating a network server that uses the Berkeley API to create a TCP/IP echo server on port 9760.

TCP/IP Berkeley TCP Server MCC Configuration

The following Project Graph diagram shows the Harmony components included in the Berkeley TCP Server demonstration application.

  • MCC is launched by selecting Tools > Embedded > MPLAB® Code Configurator from the MPLAB X IDE and after opening the project, TCP/IP demo project is ready to be configured and regenerated.

  • TCP/IP Root Layer Project Graph

    The root layer project shows that SERCOM2 peripheral is selected to do read and write operation for TCP/IP commands.

    This is the basic configuration with SYS_CONSOLE, SYS_DEBUG and SYS_COMMAND modules. These modules are required for TCP/IP command execution.

    tcpip_same54_project

    NOTE - The above screenshot contains FreeRTOS component and that is required for RTOS application. For bare-metal(non-RTOS) FreeRTOS component shouldn't be selected.

  • TCP/IP Configuration

    • SAM E54 Xplained Pro
      tcpip_same54_project
  • TCP/IP Required Application

    TCP/IP demo use these application module components for this demo.

    Announce module to discover the Microchip devices within a local network.

    Berkeley API module provides the Berkeley_Socket_Distribution (BSD) wrapper to the native Microchip TCP/IP Stack APIs. During this component selection, the required transport and network modules are also selected.

    DHCP Client module to discover the IPv4 address from the nearest DHCP Server.

    DNS Client provides DNS resolution capabilities to the stack.

  • TCP/IP Data Link Layer

    Internal ethernet driver(gmac) is enabled with the external KSZ8091 PHY driver library. The MIIM Driver supports asynchronous read/write and scan operations for accessing the external PHY registers and notification when MIIM operations have completed.

TCP/IP Berkeley TCP Server Hardware Configuration

This is the following section describes the hardware configuration used for this application demonstration.

  • This section describes the required default hardware configuration use USB device as on board debugger and programmer for this application demonstration.
    • No hardware related configuration or jumper setting changes are necessary

    • Refer to the SAM E54 Xplained Pro User Guide

      required_hardware
    • Connect the micro USB cable from the computer to the DEBUG USB connector on the SAM E54 Xplained Pro.

    • Establish a connection between the router/switch with the SAM E54 Xplained Pro through the RJ45 connector

      required_hardware

TCP/IP Berkeley TCP Server Running Application

This table list the name and location of the MPLAB X IDE project folder for the demonstration.

Project NameTarget DeviceTarget Development BoardDescription
sam_e54_xpro.XATSAME54P20ASAM E54 Xplained ProDemonstrates the Berkeley TCP Server on development board with ATSAME54P20A device and KSZ8091 PHY daughter board. This implementation is based on bare-metal(non-RTOS).
sam_e54_xpro_freertos.XATSAME54P20ASAM E54 Xplained ProDemonstrates the Berkeley TCP Server on development board with ATSAME54P20A device and KSZ8091 PHY daughter board. This implementation is based on FreeRTOS.

Running Demonstration Steps

  1. Build and download the demonstration project on the target board.

  2. If the board has a SERCOM2 configuration:

    1. A virtual COM port will be detected on the computer, when the USB cable is connected to USB-UART connector.

    2. Open a standard terminal application on the computer (like Hyper-terminal or Tera Term) and configure the virtual COM port.

    3. Set the serial baud rate to 115200 baud in the terminal application.

    4. See that the initialization prints on the serial port terminal.

    5. When the DHCP client is enabled in the demonstration, wait for the DHCP server to assign an IP address for the development board. This will be printed on the serial port terminal.

      • Alternatively: Use the Announce service or ping to get the IP address of the board.

      • Run tcpip_discoverer.jar to discover the IPv4 and IPv6 address for the board.

  3. Execution :

    1. As soon as a valid IP address is assigned through the DHCP to the demonstration, it is ready to accept a TCP/IP connection on port 9760.

      tcpip_same54_project
    2. Send a TCP packet to the IP address of the hardware board using port 9760 from any TCP Client application running on the computer.

    3. The TCP Server demonstration running on the hardware board will echo back everything it receives along the connection.

      The expected output -

      tcpip_same54_project