Skip to main content
Topic: Fixes for Microchip MDD Demo TCPIP Stack 5.31 (Read 24073 times) previous topic - next topic

Fixes for Microchip MDD Demo TCPIP Stack 5.31

Hi guys,

I have managed to get the webserver working with the latest Microchip stack and using the SD memory card.
Most of the bugs I've found were due to either closing files with null pointers or freeing memory with a null pointer. To fix it, make the following mods to HTTP2_MDD.c  (the line numbers refer to before-changes values):

lines 1273,1356 - change :
free(directoryPtr);
to:
if (directoryPtr != NULL)
{
  free(directoryPtr);
}

lines 1413, 1627 - change :
FileClose(DynVarRcrdFilePtr);
to :
if (DynVarRcrdFilePtr != NULL)
{
  FileClose(DynVarRcrdFilePtr);
}

line 1625 - change :
FileClose(curHTTP.offsets);
to :
if (curHTTP.offsets != NULL)
{
 FileClose(curHTTP.offsets);
}

These fixes will enable the simple web file to work and also fix a bug when the URL cannot  be found. They are a simple workaround until I can work out why these pointers are NULL - probably because these lines shouldn't be called when using the SD card.
That's as far as I've got so far - I haven't tried it with variable data in the web page yet, so there may be more.

Re: Fixes for Microchip MDD Demo TCPIP Stack 5.31

Reply #1
Thanks Jeff,

I added a link to the demo on the wiki. Another member, serenavv, is also working on a step-by-step guide to getting it going on TCPIP stack v5.31. When we work out the kinks I'll package up a new demo that should work "out of the box" with v5.31.

Quote
Used:
MPLAB ide v8.63
C30 v3.23 (with C30 v3.25 it doesn't work!!!)
Microchip Applications Libraries (with TCP/IP Stack 5.31)
SDFormatter v2.0
MCHPDetect


1) Replace original files of microchip stack 5.31: Maindemo.c, maindemo.h, HardwareProfile.h, TCPIPConfig.h, TCPIP MDD SD Card Demo App-C30.mcw/.mcp as reported on readme.txt into the Microchip MDD HTTP demo directory (C:Microchip SolutionsTCPIP MDD Demo App by default)
2) Open workspace TCPIP MDD SD Card Demo App-C30.mcw with MPLAB
3) Change on file "ENC28J60.c" ENC_SPICON1bits.CKE = 1; to ENC_SPICON1bits.CKE = 0; (on line 223 and 229)
4) Change in file "MainDemo.h" #define SaveAppConfig() NOP to #define SaveAppConfig(a) Nop()
5) Remove one of the two "{TCP_PURPOSE_HTTP_SERVER, TCP_ETH_RAM, 200, 200},"
5) Compiling it now, it returns "BUILD SUCCEEDED"

6) Upgrade Webplatform firmware with "TCPIP MDD SD Card Demo App-C30.hex" using ds30 Loader
7) Format MicroSD using SDFormatter
8) Put all files of folder WebPages2 into MicroSD (C:Microchip SolutionsTCPIP MDD Demo AppWebPages2)
9) Run MPFS2.EXE (you find it in C:Microchip SolutionsMicrochipTCPIP StackUtilities).
9.1) Set your webpages folder (default folder is C:Microchip SolutionsTCPIP MDD Demo AppWebPages2)
9.2) Set MDD in Processing Options and choose your output folder
9.3) Click on generate
9.4) Copy to MicroSd also the files 'DynRcrd.bin' and 'FileRcrd.bin' that you find in your output folder
10) Put MicroSD in WebPlatform and connect lan cable
11) Use MCHPDetect (you find it in C:Microchip SolutionsMicrochipTCPIP StackUtilities) to know IP address of the board
12) Power on the webplatform (or press reset key)

This evening I try theese istructions (during writing) but there are some problems:

is not possible to send email or use authentication or upload files :(

I try also to add to TCPIPConfig.h following lines but it doesn't work!:
   #define STACK_USE_SMTP_CLIENT
   #define STACK_USE_HTTP_EMAIL_DEMO
   #define STACK_USE_DYNAMICDNS_CLIENT
   #define HTTP_USE_AUTHENTICATION
   #define STACK_USE_HTTP_MD5_DEMO
Got a question? Please ask in the forum for the fastest answers.

Re: Fixes for Microchip MDD Demo TCPIP Stack 5.31

Reply #2
Please, someone can tell me where is the c30 v3.23. I've downloaded the c30 v3.25 from microchip main web. But the version 3.23 I don't know where is. Thanks a lot.

Re: Fixes for Microchip MDD Demo TCPIP Stack 5.31

Reply #3
See PM.

Re: Fixes for Microchip MDD Demo TCPIP Stack 5.31

Reply #4
thanks a lot again, it seems running so well, I'll try touch it inside... and it checks the code to learn the program structure.

Re: Fixes for Microchip MDD Demo TCPIP Stack 5.31

Reply #5
Just thought I'd let you guys know what I have found when using the SD card with variables etc.

The most important thing to know is this:

The Microchip library does not implement the conversion of long filenames to the short filename format (8.3) used by FAT32 etc (because of Microsoft's patent requiring licensing), and any web references are limited to the FAT 8.3 format.

In other words, if you have a file called longfilename.html which you have stored on the SD card with a USB MMD card writer/reader (which is licensed to Microsoft and therefore can use long filenames), then you have to use LONGFI~1.HTM in any reference to the file, or else the web server will not find it and will see the long filename reference as invalid.

But there is one problem with this - the tilde character is not allowed in the web page because the web server uses it to insert variables (eg. ~my_variable~).

To overcome this problem, I used an include file approach, as the included file is not parsed for variables and hence can contain tilde characters without causing any problems.

To do this you will need something like the following:

If you want to use a ref like this - <a href="LONGFI~1.HTM">My web page[/url] then put this line in another file with a short filename and .inc extension (eg test.inc).

Then, refer to this include file in the original web page like this:

<div id="test">~inc:test.inc~</div>

That's it. Now when the web server fetches the included file, it will not parse out any tilde characters and will simply pass the reference through with the short filename format including the tilde.

You may think this can be avoided by simply using small filenames, but there are some situations which require it to be in 8.3 format (eg .jnlp webstart links and also .html extensions which use a 4 character extension field which needs to be truncated to 3 characters).

So that's about it. I have written a very simple JavaFX WebStart stand-alone app which reads the status of the LEDs on the board every 500mS and it works pretty well. Now I want to make some cool GUI JavaFX apps to read real time data from my web server and run outside the browser as desktop applications or even on my mobile phone.

Hope this helps anybody having problems using the SD card.

Jeff

Re: Fixes for Microchip MDD Demo TCPIP Stack 5.31

Reply #6
I'd like to note I had success with the SD memory card using the latest Microchip stack (v5.31) as well.  I'm using MPLAB X on Ubuntu (C30 v3.24) - I only ran into an issue where I needed Windows to run MPFS2.exe...  doesn't work w/Mono, insists on appending a slash to end of output directory and complains directory does not exist when executing, tried escaping it without much luck - other then that everything is pretty good.

I do have one question - when running MPFS2, it seems it needs to be run twice.  Once processing as MDD to create the FileRcrd.bin and DynRcrd.bin and another time as BIN/MPFS2 to generate the MPFS2IMG2.bin, HTTPPrint.h and HTTPPrint.idx files.  The BINs are copied to the SD card while the HTTPPrint.{h,idx} are needed for the firmware compile.  Is this correct?

I'll love to see the step-by-step gude that serenavv is working on once finished and see if any specific items need to be addressed under MPLAB X.

Re: Fixes for Microchip MDD Demo TCPIP Stack 5.31

Reply #7
[quote author="taintedkernel"]I do have one question - when running MPFS2, it seems it needs to be run twice.  Once processing as MDD to create the FileRcrd.bin and DynRcrd.bin and another time as BIN/MPFS2 to generate the MPFS2IMG2.bin, HTTPPrint.h and HTTPPrint.idx files. 
[/quote]

I've only ever needed to run it once - but that is with the now superseded v5.20b stack version. I also need to manually delete the HTTPPrint.{h,idx} files as they weren't overwritten.

Quote
The BINs are copied to the SD card while the HTTPPrint.{h,idx} are needed for the firmware compile.  Is this correct?

Correct.

Re: Fixes for Microchip MDD Demo TCPIP Stack 5.31

Reply #8
Great, thanks for the info Trev.

Re: Fixes for Microchip MDD Demo TCPIP Stack 5.31

Reply #9
[quote author="javielbuba"]Please, someone can tell me where is the c30 v3.23. I've downloaded the c30 v3.25 from microchip main web. But the version 3.23 I don't know where is. Thanks a lot.[/quote]

the same problem, If someone can send 3.23 version to my email erzzzz@inbox.lv it would be very helpfull.

Re: Fixes for Microchip MDD Demo TCPIP Stack 5.31

Reply #10
See PM :)

Re: Fixes for Microchip MDD Demo TCPIP Stack 5.31

Reply #11
I fixed the code however the bug persists the URL cannot be found. If I change the C30 version v3.25 to v3.23 will the problem be solved? If is true, someone can send 3.23 version to my email.

Re: Fixes for Microchip MDD Demo TCPIP Stack 5.31

Reply #12
No it won't solve URL cannot be found. It solves PIC crashes - no heartbeat etc. Start a _new_ thread and describe exactly what you did to create the code and what happens - warnings, error messages etc.

 

Re: Fixes for Microchip MDD Demo TCPIP Stack 5.31

Reply #13
Thanks for return, I found the problem, in TCPIPConfig.h was so:

#define MDD_ROOT_DIR_PATH   "\WWW\"

but this define doesn't work! So I changed to:

#define MDD_ROOT_DIR_PATH   "\"

Now, it's ok!