Skip to main content
Topic: MicroChip demo pages functionality (Read 13270 times) previous topic - next topic

MicroChip demo pages functionality

My dangerous prototypical web platform finally arrived from SeeedStudio this week... and it was even smaller than I thought!

I guess I should preface what follows by noting that this is my first experience with any microcontoller. The last time I dabbled in electronics was when I built an rs232 interface for the user port of a Commodore Vic-20 circa 1983 using a bunch of discrete line driver chips so that I could run a BBS from it. There, I'm dated :)

Anyway, I fired up my web platform, loaded the MC demo pages, and once the initial euphoria that it all worked wore off, started by re-compiling the firmware to fix:

(1) _FICD(JTAGEN_OFF & ICS_PGD1); //Not 0b11 in HardwareProfile.h lest I get bitten by it later;
(2) ENC_SPICON1bits.CKE = 0;      // Changed 1 -> 0 in ENC28J60.c to make the system stay up.

So far so good. Then I discovered that the email demo didn't work. Unlike, say, the snmp demo which has a nice banner noting that the relevant module was not compiled in. From a quick look at the MC code, something similar should have happened for the smtp client, but didn't for whatever reason. So, after adding
Code: [Select]
#define STACK_USE_SMTP_CLIENT
to TCPIPConfig.h, recompiling and uploading, email... worked.

Why not fix the authentication demo too? It might come in handy when (only a matter of time) I put the web platform up on the net :) So, add
Code: [Select]
#define HTTP_USE_AUTHENTICATION
to TCPIPConfig.h, recompile and test... it works.

On a roll now. The file upload md5 demo doesn't work. Must be another define. Sure enough, adding
Code: [Select]
#define STACK_USE_HTTP_MD5_DEMO
to our new friend TCPIPConfig.h fixes that too.

Skipping the Dynamic DNS demo as I have a static IP address for my domain, that just leaves one more to fix: Network Configuration. Could be handy as I think I read that each web platform comes with the same MAC address (?). Must just be a simple define in our old friend. Nope. It's already defined. If you change the IP or MAC address and disable DHCP from the form, it says it's successful, it does reboot, but nothing has changed as it still requests a DHCP address and the MAC is unchanged.

Question time: Too good to last.. you just knew there was going to be a question, huh? Right. I better not disappoint. Is this behaviour due to the fact the we're not using the MicroChip "Internet Bootloader" ? The network reconfig is supposed to write the info to the EEPROM and it looks like the MicroChip bootloader reads that when it resets.

Ok, back to email. If I expose it to the net, I can't sensibly leave the email form exposed. So let's move it to the protect directory and take advantage of authentication now it's working.

1. Edit header.inc to change the email form link from /email/index.htm to /protect/email/index.htm.
2. Move email/index.htm to the protect directory.
3. Edit /protect/email/index.htm to change the reference to "/email/index.htm" to "/protect/index.htm".
4. Run the convert-WebPages-to-MPFS.bat to recreate the file system.
5. Upload the new bin file with the web browser via /mpfsupload (typing any non-existent url will get you to here).

Now there must be a reference in the code somewhere that needs changing... sure enough, there two spots in CustomHTTPApp.c - note that the first omits the leading slash. Fix and recompile, and... nothing! It doesn't work. Hmmm. It turns out there's a limit on the pathname somwehere in the MC stack because if I relocate /protect/email/index.htm to /protect/email.htm it does work (yes, you need to make all the file changes as already noted to refer to this new location).

Not finished. I can't access the web platform from the net because I already run webservers on both my DSL conenctions and my DSL routers don't allow forwarding an incoming port to other than that port. easy solution, find the HTTP_PORT define in http2.h and change it from 80 to 81. Recompile and, with port forwading rule in place, the web platform is now on the net! No, we're not finished, we better change the defailt username and password while we're about it - see the HTTPCheckAuth function in CustomHTTPApp.c to chnage these.

All done... my telnet server addition will have to wait until next time.

Re: MicroChip demo pages functionality

Reply #1
Hey Trev,

Thanks for the great writeup. Good information on working with the Microchip TCPIP stack.

To answer your question, I don't think so. Different Microchip dev-board may use different bootloaders, but as I understand it only the 18F67j60 family (the chip in the #twatch with an integrated ethernet mac/PHY) work with the internet bootloader. I could be wrong, and there could also be new bootloaders released, that would be really cool and open a lot of possibilities.
Got a question? Please ask in the forum for the fastest answers.

Re: MicroChip demo pages functionality

Reply #2
Another day another challenge. The network reconfiguration on the fly looks insoluble without using the Microchip Internet bootloader, so time to move on to... the SD card server which promises more possibilities than the restricted EEPROM storage.

Ok, so off to download the dangerously prototypical SD card firmware archive. With the initial changes made to HardwareProfile.h and ENC28J60.c (you see, I use a new copy of the stack source for each project to keep any changes for a particular project isolated), the source is compiled and uploaded to the web platform, the 4Gb Kingston SD card freshly purchased (no need to format :) has the simple website files copied, the web platform is powered up and... well, yes, it works, but is hardly exciting.

Time to copy over the Microchip MDD demo web pages. So, goodbye unexciting pages, hello exciting web pages. Let's just copy them over to the SD card and re-power the web platform... ahem. Exciting is not quite the word. Only part of the home page is drawn, sometimes not even that or it looks like the stylesheet has gone missing, and those variables aren't being substituted. Ok, so I remember reading about this, I need to copy those pesky DynRcrd.bin and FileRcrd.bin files over to the SD card. No problem. Now to try again... yes! It works... and then just as suddenly, no it doesn't. The home page displayed beautifully the very first time and then, well, garbage. But worse was to come. The web platform locked up - no heartbeat LED at all.

Yes, I know, I had read how this would happen http://shadow.sentry.org:81/ and seems to now be just as stable as the  EEPROM version. Y'all welcome to download TeraTerm to test its speed for though I live in the land of DSL ISPs who count downloads, uploads are not counted and your download is my upload :)

Addendum My fix for the substituted variable page corruption issue only fixed the web platform lockup, not the failure to instantiate all the variables or return the whole page :(

Re: MicroChip demo pages functionality

Reply #3
I get only about 2.3 kB/s download speed.

Re: MicroChip demo pages functionality

Reply #4
I did say "locally" ... my upstream DSL bandwidth is 997000 bps. A test from the university where I work gives a more respectable:

Quote
trev@freshwater [/home/trev] $ fetch http://shadow.sentry.org:81/dl/demo.zip
fetch: http://shadow.sentry.org:81/dl/demo.zip: size of remote file is not known
demo.zip                                               921 kB   13 kBps

while on my local LAN:

Quote
trev@centurion [/home/trev] $ fetch http://192.168.1.1:81/dl/demo.zip
fetch: http://192.168.1.1:81/dl/demo.zip: size of remote file is not known
demo.zip                                               921 kB   84 kBps

and upping the tx and rx buffers to 2000 bytes produces:

Quote
trev@centurion [/home/trev] $ fetch http://192.168.1.1:81/dl/demo.zip
fetch: http://192.168.1.1:81/dl/demo.zip: size of remote file is not known
demo.zip                                               921 kB   104 kBps

Re: MicroChip demo pages functionality

Reply #5
Trev, do you have a zip or listing of all the steps to get this up?  I just fixed the crystal, and I was thinking of trying to get things up.  I am not sure if the best bet is the microchip sd demo, or the UIp port, but I have had these board long enough I need to get them up doing something.

Re: MicroChip demo pages functionality

Reply #6
The latest source from SVN is attached. There are some (minor) directions for SVN and compiling PIC projects on the wiki:
http://dangerousprototypes.com/docs/Com ... C_projects
http://dangerousprototypes.com/docs/Using_SVN
Got a question? Please ask in the forum for the fastest answers.

Re: MicroChip demo pages functionality

Reply #7
[quote author="rhyde"]
Trev, do you have a zip or listing of all the steps to get this up?  I just fixed the crystal, and I was thinking of trying to get things up.  I am not sure if the best bet is the microchip sd demo, or the UIp port, but I have had these board long enough I need to get them up doing something.
[/quote]

The original post above contains the step-by-step process that I followed. I think you'll find the SD demo (everything available in the MCHP stack) is considerably further along than the UIp port which is still a work in progress (ping, telnet are working, reading some SD cards also works). I used the ZIP from the google code page and followed the instructions therein to merge it with the MCHP files.

My current version of the SD demo has a few more enhancements but mainly for debugging (eg it outputs the current page being accessed to the UART/USB) and is to control a bunch of relays in preparation for its intended use as a remotely accessible device to turn on/off the power from my UPSes to various servers/routers/switches  (assuming one of my two ISP links is still functioning).

PM me if you want more... :)

Re: MicroChip demo pages functionality

Reply #8
when i enable
#define STACK_USE_SMTP_CLIENT
#define STACK_USE_HTTP_EMAIL_DEMO
i get the build error



Objects - TCPIP MDD Demo App-C30CustomHTTPApp.o(.text+0x51c): In function `HTTPExecutePost':
C:Microchip SolutionsTCPIP MDD Demo AppCustomHTTPApp.c:391: undefined reference to `HTTPPostDDNSConfig'
Objects - TCPIP MDD Demo App-C30CustomHTTPApp.o(.text+0x51e):C:Microchip SolutionsTCPIP MDD Demo AppCustomHTTPApp.c: undefined reference to `HTTPPostDDNSConfig'
Link step failed.

it builds fine if i comment out these two lines what do i need to edit to get this working ?

Re: MicroChip demo pages functionality

Reply #9
Strange - when I build the SD server, DDNS is not enabled. Are you using TCP/IP stack v5.20b ?

Re: MicroChip demo pages functionality

Reply #10
Nice, I got my web platform working.
Was a bit tricky as the Microchips documentation pertains to there development platform. so far...MD5, EMAIL, DYNDNS i got working.

The new TCP stack seems to not lock up either...
http://wan1.satanslilchild.com:888/

 

Re: MicroChip demo pages functionality

Reply #11
@tmdrake - thanks for the report, glad to hear it's working well!
Got a question? Please ask in the forum for the fastest answers.