What exactly Olimex modify to adapt the tcp ip stack to their own board ?

Started by dualvsta, January 30, 2013, 03:12:26 PM

Previous topic - Next topic

dualvsta

Hello :)

I would like to know what are the modifications exactly made by Olimex to adapt the Microchip TCP IP stack to the PIC-WEB rev C board.

In other words, what I have to do with the original TCP IP stack to make it work with the PIC-WEB by Olimex

I'm a beginner in C language so I don't understand all yet but I'm curious.
The modified TCP IP stack by Olimex works very well, it's just for my curiosity.


I have other questions :

- In the "Configs" folder, we have two files who configure the hardware and the software TCP IP stack if i understand well. But, where those files are used in the mplab project ? I don't see anywhere a reference to those file ?

- The PIC-WEB rev C use an atmel SPI flash memory but in the hardware definition file, we can see that it is the eeprom who is configured.
Can you explain why ?

Thank you very much for your help :)

LubOlimex

Hi, Dualvsta

Quote1. In the "Configs" folder, we have two files who configure the hardware and the software TCP IP stack if i understand well. But, where those files are used in the mplab project ? I don't see anywhere a reference to those file ?


The basic Microchip TCP/IP stack has two major configuration header files named: HardwareProfile.h and TCPIPConfig.h where the user could include his own header. In the original stack applications in the HardwareProfile.h you can see:

-----------------------------------------------------------------------------------
57.      .....
58.      #if defined(YOUR_BOARD)
59.         #include "Configs/HWP YOUR_BOARD.h"
60.      #elif defined(CFG_INCLUDE_INTERNET_RADIO)
61.      .....
-----------------------------------------------------------------------------------

In the original file "TCPIP Stack Version.txt" it's described:

-----------------------------------------------------------------------------------
   Change boards by changing the defined macro (Project -> Build Options... ->
   Project -> MPLAB Cxx -> Add macro).  When moving to custom hardware, add an 
   appropriate profile to Compiler.h.  YOUR_BOARD is present as a placeholder.
-----------------------------------------------------------------------------------

The idea is simple if you decide to use the stack application for custom board you have to place your own header instead "HWP YOUR_BOARD.h". In my case I've renamed the macro and the header file using the board name. And the same code fragment in my "HardwareProfile.h" looks like:

57.      .....
58.      #if defined (OLIMEX)
59.         #ifdef OLIMEX_PIC_WEB
60.            #include "Configs/HWP OLIMEX_PIC-WEB.h"
61.         #endif
62.      #elif defined(CFG_INCLUDE_INTERNET_RADIO)
63.      ......

Here the board macro is OLIMEX_PIC_WEB defining the PIC-WEB board. The OLIMEX macro is used in most of projects.
The same ideae is used in the other file "TCPIPConfig.h"

-----------------------------------------------------------------------------------
149.   ....
150.   #elif   defined(OLIMEX)
151.         #ifdef OLIMEX_PIC_WEB
152.            #include "Configs/TCPIP OLIMEX_PIC-WEB.h"
153.         #endif
154.   #else
155.         #error Missing project macro definition to select proper TCPIPConfig.h
156.   #endif
157.   ....
-----------------------------------------------------------------------------------

Quote2. The PIC-WEB rev C use an atmel SPI flash memory but in the hardware definition file, we can see that it is the eeprom who is configured. Can you explain why ?

The original TCPIP stack uses EEPROM memory. But when the board (PIC-WEB) was designed the EEPROM memory was replaced with the Atmel SPI flash memory that you mention. But the original "SPIEEPROM.c" file is patched to use flash (I suppose this is what confuse you). So, despite the names of the functions has a prefix "XEE" (This maybe confuse you as well :-) ) , the functions are actually using the memory as flash. You can see on the top of the file "SPIEEPROM.c":

-----------------------------------------------------------------------------------
59.      ....
60.      #if defined(OLIMEX_HW)
61.         #define   USE_ATMEL_FLASH
62.      ....

-----------------------------------------------------------------------------------

And the functions are branched using preprocessor directive #if #else #endif. For example in line 211:

-----------------------------------------------------------------------------------
XEE_RESULT XEEBeginRead(DWORD address)
{
#if defined(USE_ATMEL_FLASH)
   FLASHAddress = address;
   FLASHBufferPtr = FLASHBuffer + FLASH_BUFFER_SIZE;
   return XEE_SUCCESS;

#else
   // Save the address and emptry the contents of our local buffer
   EEPROMAddress = address;
   EEPROMBufferPtr = EEPROMBuffer + EEPROM_BUFFER_SIZE;
   return XEE_SUCCESS;
#endif
}

-----------------------------------------------------------------------------------
So it looks like we are using it like EEPROM but in fact it's flash :-)

Regards,
Stanimir/Olimex
Lub/Olimex

Technical support and documentation manager at Olimex

dualvsta


Andrew

Hi!

MC's TCP/IP stack has got a "feature" (or weakness?). The StackTask() call (tcp stack's uppermost wrapper) will block the execution in case DHCP lease time is elapsed, and DHCP server does not answer on lease renewal request.

Is that "feature" still present in Olimex's freetos lib too (for pic32-maxi-web)?