As I mentioned in my last post, the standard Arduino only has 32KiB of program memory, and with all of the networking features I want compiled into the library I'm using, I was already at 33KiB. But now with a spacious 256KiB (What will I ever do with it all!) I can add in features until my heart's content! (DNS and DHCP oh my!) Other than the extra memory (and extra I/O pins) It is identical to the regular Arduinos. Or so I thought... (cue the misery.)
Getting a blinking LED sketch (Arduino speak for program) running on it from the Arduino IDE was easy enough. But replicating it inside my Code::Blocks setup was not so easy. It took further modification of my command line scripts for which there was little to no documentation to base it off of. After lots of groping around in the dark, trial and error, and some guess work, I got it there. Though the auto-reset was not working, so I have to time a physical reset of the board with the compile button in the IDE to get the programs to upload. *annoying*. This took a few hours... but it gets worse.
Then began the real pain. You see, the trouble starts with the fact that the wonderful WiFi board that I use (the WiShield, made by AsyncLabs) is no longer in production. In fact, in March of this year, AsyncLabs shuttered their little studio completely. Which is a real bummer because they are the ONLY mature, drop-in WiFi solution for Arduino
With AsyncLabs out of the picture, development on its library and support in its forums has all but ceased. With the Mega2560 being a relatively new board, its fair to say that support will never be added for it in the WiShield's code. Now you might ask, but Adam! You said the Mega was pretty much identical to other Arduinos! Why would support need to be added at all! And it's because it's NOT identical. There is a small difference that turned out to be vitally important.
You see the Arduino's are based on an AVR type chip manufactured by Atmel. Atmel makes a variety of these chips under the ATmega line.
These ATmega chips provide a nice little piece of hardware/software functionality called SPI or Serial Protocol Interface. I won't go into the details, but it's critical to the functioning of the WiShield.
This is where the problem lies. Arduino's based on the ATmega168 or the ATmega328, have their SPI pins on 11, 12, 13.
But Arduino's based on the ATmega1280 or the ATmega2560, have their SPI pins on 51, 52, 53. <- these pins don't even exist on the original Arduinos!
This was a deep rabbit hole the wasn't helped by my ignorance of underlying hardware. Most Ardunio hobbyists never need to get this deep into the micro-controller at the heart of the Arduino, so I initially wasn't trying to learn all about it, I was just trying to solve the problem. And I wasted a *lot* of hours going down this vein. After two days of researching the problem, banging my head against a wall, investigating other WiFi chips and even other micro-controllers entirely, the project was in real danger. But I finally had a break through. I pieced together a solution from many different forum posts and a deeper understanding of the hardware and the problem at large.
It ended up being both a hardware and a software fix. And I had to mutilate my beloved WiFi board a little
This was not a fun excursion. But I hope it clears the the path for some smoother sailing. Next I'm going to try to make the Arduino keep time using NTP (Network Time Protocol) for synchronization. And after that work on pulling events from a Google Calendar. So stay tuned, and I hope to keep these posts shorter