Monday, July 19, 2010

Building the TCP/IP Demo for the PICNet1


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

The PICNet1 PIC18 Development Board lets you populate the U1 (40-pin) or U2 (28-pin) microcontroller sockets with various PIC18F devices, such as PIC18F2620 or PIC18F4685. Also on the U3 socket you can install different serial EEPROM such as the Microchip 25LC256 or 25LC1024 or any equivalent including FLASH memories that have the same pin out. The Ethernet controller on board is always a Microchip ENC28J60.

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 PICNet1 board.

+- PN1_Demo-vX.Y        PICNet1 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 PN1_Demo-v2.0 (current version)
  - PICNET1.mcp         MPLAB IDE Project file to build image for PICNet1
  - MPFSImg2.bin        MPFS Image for HTTP v2 server demo pages
  - README.TXT          This file

- Directory bin         Precompiled firmware images (Intel hex format)
   - PICNET1_2620.hex   Demo firmware compiled for PIC18F2620 (*)
   - PICNET1_2680.hex   Demo firmware compiled for PIC18F2680 (*)
   - PICNET1_2682.hex   Demo firmware compiled for PIC18F2682
   - PICNET1_2685.hex   Demo firmware compiled for PIC18F2685
   - PICNET1_4620.hex   Demo firmware compiled for PIC18F4620 (*)
   - PICNET1_4680.hex   Demo firmware compiled for PIC18F4680 (*)
   - PICNET1_4682.hex   Demo firmware compiled for PIC18F4682
   - PICNET1_4685.hex   Demo firmware compiled for PIC18F4685

   (*) Given the program memory required for the Microchip TCP/IP Stack
       demo, these images have been compiled with all optimziations enabled

   All images have been compiled with support for a 25LC256 serial EEPROM.

- Directory include
  - picnet1.h           Hardware configuration definitions for PICNet1
  - 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
   - main.c             Source code for the main demo application
   - misc.c             Source code for miscelaneous support functions

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 PICNet1 Demo Application Firmware.

The project file PICNET1.mcp includes the required files on the project file lists.

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 PN1_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 PICNET1.mcp project file, on the top menu bar select to build the "Release" version of the code, and select the proper target device that is installed on the PICNet1 MCU U1 or U2 sockets.

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/4620 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 has been tested or compiled for the PICNet1 Board, some of these modules may require additional customization to work on this board.

After compiling and programming the binary image on the target device, if you connected a terminal or computer running a terminal emulator to the RS-232 interface (default configuration is 19200bps, N, 8, 1), after RESET you should see a series of informational messages like these:

PICNET1 Hardware Initialized, HW Config Ver.1.0, MCU = PIC18F4620
MPFS Initialized, Ver.2.1
PICNET1 Config loaded
Microchip TCP/IP Stack Ver.v5.25
MAC Address = 00:04:A3:00:00:20, IP Address = 169.254.1.1
PICNET1 Ready, FW Ver.2.0, Built Jul 19 2010-09:11:22
New IP Address = 169.254.1.1
New IP Address = 10.0.2.102

For additional information and documentation about the Microchip TCP/IP Stack refer to the Help file included in the Microchip Applications Libraries distribution, and for latest information and up to date instructions  about how to build the demo firmware for the PICNEt1 board visit the product page at http://www.ljcv.net/picnet1/

Happy Networking
Jorge

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
Jorge


Sunday, July 4, 2010

Project pages and new Blogs

Over the past few years I've published several pages about some of my experiences trying to put together different projects related to electronics, particularly using microcontrolles and one of my hobbies: retrocomputing.

I've been always convinced that sharing and teaching what you learn is a way to keep learning, to find others with common interest and exchange experiences, ideas. No doubt, being an Internet pioneer, I always loved to use the network for that purpose, in the old days it was just electronic mail and FTP, later we had archie, gopher, WAIS, the noisy USENET News, but the big bang was "The Web".

Maintaining several sites in the old fashion way was becoming a big time consuming effort, time that I'd prefer to use to develop and publish new projects and comments about what I learn or find interesting in this constantly evolving field of digital electronics, microcontrollers and networking.

So then, I decided to upgrade myself to Web 2.0+.

The old plain HTML project pages do not exist anymore, I'm gradually moving all the content and in the process updating it to Blogger, but to facilitate indexing and keep my brain organized I'm splitting the content in three different blogs:

  • Electronics Projects, Reviews and Gossip
    The "official" LJCV Electronics Blog, for products and services I develop through LJCV, and general comments, reviews and news in the electronics industry.
    I'll also post here announcements if I publish something new somewhere else.
  • eProjects
    For all detailed electronic projects related to microcontrollers, embedded networking, mods, etc.
  • ReTr0ByTeS
    Dedicated to retrocomputing experiences, old computers, calculators, instruments, components, etc.
I hope you find the new format and content useful, and as always if you have comments or suggestions feel free to drop me a line.

Best Wishes
Jorge