1.18 TCP/IP WEB & FTP Server with USB FATFS

The Web FTP Server USB Flash drive FATFS configuration demonstrates creating an application where HTTPNET server and FTP server will use MSD Host Client Driver to write a file to a USB Flash drive.

The application uses the USB Host Layer, USB Full Speed Driver, MSD Client Driver and the File System to enumerate a USB Flash drive and to write a file to it.

The FAT FS File System is used for reading and writing files to and from the storage media .

TCP/IP WEB & FTP Server with USB FATFS MCC Configuration

The following Project Graph diagram shows the Harmony components included in the WEB & FTP Server with USB FATFS 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

    WolfSSL component is selected for secure connection which supports TLS and WolfSSL-Crypto component is selected for MD5 and SHA authentication.

    The USB MSD Host Client Driver in the MPLAB Harmony USB Host Stack allows USB Host Applications to support and interact with Mass Storage Class USB devices (USB Flash drive).

    FILE SYSTEM is added to read and write from the USB Flash drive with FAT file system, which is configured as shown below-

    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.

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

    DNS Client provides DNS resolution capabilities to the stack.

    FTP SERVER facilitates the uploading of files to, and downloading of files from, a network device.

    • FTP server use the FAT FS to access files from USB media.

      tcpip_same54_project

    HTTPNET Server module is selected to run the web_server for the port number 80.

    • HTTPNET server with Web directory Mount path and port number configuration:

      tcpip_same54_project

    NBNS NetBIOS Name Service protocol associates host names with IP addresses. This assign of human-name host names to access boards on the same subnet.

    SMTP CLIENT let applications send e-mails to any recipient worldwide.

    SNTP Simple Network Time Protocol updates its internal time periodically using a pool of public global time servers.

  • 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 WEB & FTP Server with USB FATFS 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.

    • Use "TARGET USB" port on the board to connect the USB Device to the USB Host. A USB micro B to type A USB Host receptacle converter will be needed to connect the device.

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

      required_hardware

TCP/IP WEB & FTP Server with USB FATFS 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 WEB & FTP Server with USB FATFS 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 WEB & FTP Server with USB FATFS on development board with ATSAME54P20A device and KSZ8091 PHY daughter board. This implementation is based on FreeRTOS.
  • Ensure USB Flash device is loaded with the web pages provided within the /net_apps_sam_e5x/apps/web_ftp_server_usb_fatfs/firmware/src/web_pages directory and also with some other files in order to test the FTP functionality of the application.

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 :

    After the successful board bring up, the console output becomes

    tcpip_same54_project
  4. HTTP Server Output -

    An HTTP server is hosted by the demonstration application. Open a web browser and direct it to the board running the HTTP server by typing the URL in the address bar (for example, https://mchpboard_c or https://< ip-address as shown in the console > ), and then pressing Enter.

    tcpip_same54_project

    The demonstration application features following:

    1. Dynamic Variables and Real-time Hardware Control - On the Overview page the LEDs can be clicked to toggle the LEDs on the Microchip hardware development board. The SWITCHes on the Microchip hardware development board can be pressed to toggle the Buttons on the web page. The dynamic variables can be updated in real-time on the HTTP server.

    2. Form Processing - Input can be handled from the client by using the GET and POST methods (this functionality controls the on-board LEDs and is operational only on the Explorer 16 Development Board)

    3. Authentication - Shows an example of the commonly used restricted access feature

    4. Cookies - Shows an example of storing small text strings on the client side

    5. Server Side Includes - An example of how SSI can be used to support dynamic content

    6. File Uploads - Shows an example of a file upload using the POST method. The HTTP server can_accept_a user-defined MPFS/MPFS2 image file for web pages.

    7. Send E-mail - Shows simple SMTP POST methods

    8. Dynamic DNS - Exercises Dynamic DNS capabilities

    9. Network Configuration - The MAC address, host name, and IP address of the evaluation kit can be viewed in the Network Configuration page and some configurations can be updated

    10. MPFS Upload - A new set of web pages can be uploaded to the web server using this feature, which is accessed through http://mchpboard_c/mpfsupload

    Notes:

    • For the LED and SWITCH functionality portion of the demonstration, configure the GPIOs connected to LEDs and Switches on Microchip hardware development board, through the Pin Configuration manager in MPLAB® Code Configurator (MCC).
  5. FTP Server output -

  • Open the windows command prompt (i.e., cmd).

  • First check if the board is available by pinging (i.e., ping < ip address of board >), the response obtained is shown in the below screenshot.

  • Enter the command ftp < ip address of board >, the response obtained is shown in the below screenshot.

  • Users must use ftp login credentials to connect to the ftp server.

  • The File transfer to and from the user’s computer is shown below.

    tcpip_same54_project