Thursday, July 15, 2010

Building the TCP/IP Demo for the eIP-10

This article will show how to build the eIP-10/eIP-10+ demo application firmware based on the Microchip TCP/IP Stack (v5.25).

There are no major differences between the eIP-10 and eIP-10+ boards, in fact the printed circuit board is exactly the same one, the only differences are that on the eIP-10+ board the microcontroller is a PIC18F2685 instead of a PIC18F2620 and the serial EEPROM a 25LC1024 instead of a 25LC256; but you still need to separate projects to define the target device for each different microcontroller.

Given that the Microchip Software License Agreement does not allow the redistribution of the TCP/IP Stack source code, you MUST obtain your own copy directly from Microchip and accept the terms of the applicable License Agreement.

There are some specific files from the Microchip TCP/IP Stack source code that need to be customized for this particular hardware configuration and application.

I arrived to an agreement with Microchip where I can distribute the modified files in a separate directory leaving the original files untouched in their original directories. Those files that are a modified or customized version of the original files from the Microchip TCP/IP Stack distribution will include the following legend and a brief explanation about what has been modified from the original version.

This module is part of the original distribution of the Microchip TCP/IP Stack, and this modified local copy is included only to let you build a binary image for this specific hardware. To be able to create the binary image you MUST download the Microchip TCP/IP Stack directly from Microchip's website and accept the terms of the applicable License Agreement. By using this file you implicitly accept the terms of Microchip's License Agreement which by no means gives you the right to redistribute this particular file in its source code form. For additional information refer to the Microchip License Agreement and if you have any questions please write to Microchip Technology Inc., 2355 W. Chandler Blvd., Chandler, AZ 85224-6199 USA. ATTN: Marketing.

Then before we start, here is the list of items you will need to be able to build the demo application firmware:

Directory Structure and files

The Microchip Applications Library gets normally installed in the directory named "Microchip Solutions", under this directory you will find many subdirectories that include the source code for different application library modules and demos.

The tree structure below, only shows the directories related to the TCP/IP Stack and its generic Demo Application.

 Microchip Solutions    Applications Library install directory
 +- Microchip           Main directory for Microchip Libraries source code
 |  |
 |  +-- Help            Help files for Library modules and demos
 |  +-- Include         General include headers files
 |  |   +-- TCIP Stack  Header files for TCP/IP Stack
 |  |
 |  +-- TCP IP Stack    TCP/IP Stack source code
 +- TCPIP Demo App      Generic TCP/IP Stack Demo application source
                        code, configuration and project files

The structure below shows the directory tree of the files distributed by LJCV to build the binary image for the Demo Application for the eIP10 and eIP10+ boards.

+- EIP10_Demo-vX.Y      eIP10 Demo application main directory with
    |                   MPLAB project files
    +-- bin             Output directory for binary images
    +-- include         Demo application header and configuration files
    +-- obj             Temporary directory for objects
    +-- src             Demo application source code
        +-- TCIP Stack  Microchip TCP/IP modified modules source code

Here is the list and description of each of the files on each directory:

- Directory EIP10_Demo-v2.0 (current version)
  - EIP10.mcp           MPLAB IDE Project file to build image for eIP10
  - EIP10P.mcp          MPLAB IDE Project file to build image for eIP10+
  - MPFS2.bin           MPFS Image for HTTP v2 server demo pages
  - MPFS.bin            MPFS Image for legacy HTTP server demo pages
  - README.TXT          Instructions to build the demo application

- Directory bin         Precompiled firmware images (Intel hex format)
   - EIP10.hex          Demo firmware compiled for the eIP10 with optimization
                        supporting the new HTTP2 server module
   - EIP10_MPFS1.hex    Demo firmware compiled for the eIP10 without
                        optimization and supporting the legacy HTTP and
                        FTP server
   - EIP10P.hex         Demo firmware compiled for the eIP10+ without
                        optimization and supporting the new HTTP2 server

- Directory include
  - eip10.h             Hardware config definitions for eIP10 and eIP10+
  - HardwareProfile.h   Hardware configuration general definitions
  - HTTPPrint.h         Callback headers for custom HTTP application functions
  - main.h              Global definitions and variables
  - mib.h               Original headers for custom SNMP application
  - misc.h              Header file for miscelaneous support functions
  - TCPIPConfig.h       Customized TCP/IP Stack configuration headers

 - Directory src
   - CustomHTTPApp.c    Customized source code for the HTTP v2 server demo
   - LegacyHTTPApp.c    Customized source code for legacy HTTP server demo
   - CustomSNMPApp.c    Original source code for the SNMP application demo
   - main.c             Source code for the main demo application
   - misc.c             Source code for miscelaneous support functions

 - Subdirectory src/TCPIP Stack
   - SPIEPROM.c         Customized version for the serial EEPROM driver code
   - UART2TCPBridge.c   Customized version for the UART to TCP Bridge code

Building the demo application

Once you have the Microchip Application Libraries and the development tools properly installed you can add the directories and files needed to build the eIP10 or eIP10+ Demo Application Firmware.

The main differences between the image generated for the eIP10 and the eIP10+ boards are, support for a different microcontroller, PIC18F2620 for the eIP10 and PIC18F2685 for the eIP10+, and support for the serial EEPROM driver 25LC256 for the eIP10 and 25LC1024 for the eIP10+.

Most of the base code for both boards is the same, then a separate distribution for each board is not required and instead the code includes a macro definition EIP10P on the MPLAB IDE project file for the eIP10+.

The two project files EIP10.mcp and EIP10P.mcp, include the required files on the project file lists and define the macro for conditional compilation accordingly.

Given that on the project files and options references to include headers and TCP/IP library modules are done using the "..\Microchip\xyz" path, the EIP10_Demo-vX.Y must be copied to the same directory level as the "TCPIP Demo App" directory, under the "Microchip Solutions" directory or whatever directory was used to install the Microchip Application Libraries.

Once you have copied the files to the proper directory, on MPLAB IDE you must open the EIP10.mcp or EIP10P.mcp project file depending on the board you are using, on the top menu bar select to build the "Release" version of the code, and verify that you have selected the proper target device, PIC18F2620 for the eIP10 and PIC18F2685 for the eIP10+.

Take in account that because of the increase in size of the latest versions of the Microchip TCP/IP library, to be able to compile a version of code that includes the latest HTTP 2 server module, you will most probably need to enable the compiler optimizations to generate a binary image that fits on the PIC18F2620 program memory.

Also double check that you are using "overlay" storage class and large code and data models (Project->Build Options->MPLAB C18), and that MPLAB IDE on the Directories tab the Library Search Path is set to the correct directory where the c018 libraries are located.

Be aware that not all the modules included with the original TCP/IP Stack Demo Application have been tested or compiled for the eIP10 or eIP10+ boards, some of these modules may require additional customization to work on these boards.

For additional information and documentation about the Microchip TCP/IP Stack refer to the Help file included in the Microchip Applications Libraries distribution.

Happy Networking


Anonymous said...

How about an update for the latest stack and MPLABX ?

Anonymous said...

Just a note..I got Stack version 5.36.4 compiling and loaded on a EIP10+ using MPLABX