1.21 TCP/IP WEB NET Server PPP
The TCP/IP WEB NET Server PPP configuration demonstrates creating an PPP interface (a network connection using a serial interface) and hosting an HTTP web server on a Microchip board. The Non-Volatile Memory (NVM) Microchip Proprietary File System (MPFS) is used for storing the web pages in the internal Flash.
The board is configured with dual network interfaces, which are Internal GMAC & PPP interface.
The Point-to-Point Protocol (PPP) provides a standard method for transporting multi-protocol datagrams over point-to-point links.
TCP/IP WEB NET Server PPP MCC Configuration
The following Project Graph diagram shows the Harmony components included in the WEB NET Server PPP application demonstration.
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 UART2 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.
Note: The PPP demo is designed to run on hardware that supports the Token Manager library. It won't run on a regular board.
The PPP source code is not available. It is distributed as a .a library only.
The file system component is required to select MPFS module. This is the below snapshot for the FS configuration.
TCP/IP Configuration
PIC32MZ EF Curiosity 2.0
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.
HTTPNET Server module is selected to run the web_server for the port number 80.
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(ethmac)
Internal ethernet driver(ethmac) is enabled with the external LAN8740 PHY driver library for the board. The MIIM Driver supports asynchronous read/write and scan operations for accessing the external PHY registers and notification when MIIM operations have completed.
PPP driver
The PPP MAC device driver provides a simple interface to manage the PPP peripheral.
PPP in the MAC layer is enabled with the asynchronous serial line UART peripheral library.
Refer below for the components selected in the Data Link Layer of the TCP/IP stack
The PPP configurations are as follows:
The UART1 configurations are as follows:
TCP/IP WEB NET Server PPP Hardware Configuration
This section describes the hardware configuration for PIC32MZ EF Curiosity 2.0 and one can be used for the respective application demonstration.
This section describes PIC32MZ EF Curiosity 2.0 custom hardware configuration which uses the on-board debugger and programmer with Internal ethmac & PPP interface for this application demonstration.
Refer to the PIC32MZ EF Curiosity 2.0 User Guide for the programming/debugging options supported & setting up the hardware.
Connect the micro USB cable from the computer to the DEBUG USB connector on the PIC32MZ EF Curiosity 2.0
Connect a serial FTDI connector to the board serial port that's configured for the PPP connection (this shows in the MCC PPP configuration).
Connect the other end of the cable (USB) to the test Linux machine running PPPd.
Establish a connection between the router/switch with the PIC32MZ EF Curiosity 2.0 through the RJ45 connector on LAN8740 PHY daughter board interface.
TCP/IP WEB NET Server PPP Running Application
This table list the name and location of the MPLAB X IDE project folder for the demonstration.
Project Name | Target Device | Target Development Board | Description |
---|---|---|---|
pic32mz_curiosity.X | PIC32MZ2048EFM144 | PIC32MZ EF Curiosity 2.0 (with LAN8740 PHY) | Demonstrates the WEB NET Server PPP on development board with PIC32MZ2048EFM144 device with LAN8740 PHY. The board has two interfaces (eth0 & ppp0 interface). This is a bare-metal (non-RTOS) implementation |
Running Demonstration Steps
Build and download the demonstration project on the target board.
PPP Daemon Setup:
To install PPP on a Linux machine (like Ubuntu, Debian, etc):
> sudo apt install ppp
Insert a USB to serial cable into a USB slot on the Linux machine. This will create a TTY USB device, let's say /dev/ttyUSB0
Allow the usage of the tty port by the PPP server:
>sudo chmod -R 777 /dev/ttyUSB0
start pppd:
We use the IP address 192.168.1.179 for the local machine (Linux) and 192.168.1.181 for the remote machine (the PIC32MZ board). Adjust based on your network configuration.
>sudo pppd /dev/ttyUSB0 115200 passive local noauth nocrtscts asyncmap ffffffff lcp-max-configure 1 persist 192.168.1.179:192.168.1.181
Start the application on the PIC32MZ side.
After start up, using the command 'netinfo' you should see that the interface 'ppp0' is present. The connection to the Linux server should be done and the PPP interface on the test board should have an IP address: 192.168.1.181 in our example.
At this point the PPP interface is configured.
You can use it as a regular interface: to ping to/from the Linux box, to access the on board web server from the Linux box, etc.
The Linux /var/log/syslog or /var/log/messages, /var/log/debug will contain details about the PPP occurring events.
At any time, if you need to stop the Linux PPP daemon, use:
> ps -e | grep pppd > kill -15 pppp_process_id
Other Linux PPP options are explained in the /etc/ppp/options.
Execution :
Start the demo. Check that the PPP interface gets an IP address
You can use the PPP interface as a regular network interface now.
Demo Test:
To test the web server functionality, refer TCP/IP WEB NET Server NVM MPFS demo.