By the way, in case anyone's interested, here's my git repo:
http://github.com/adamfeuer/WiShield
This was cloned from the asynclabs/WiShield repo, then I pushed my modifications to it.
By the way, in case anyone's interested, here's my git repo:
http://github.com/adamfeuer/WiShield
This was cloned from the asynclabs/WiShield repo, then I pushed my modifications to it.
I got the code to link correctly. There was a reference to memcpy_P and strlen_P in the WebServer.c code in the WebServer example sketch. Once I changed these to regular versions - memcpy and strlen - all was well.
The code won't fit in RAM, but it does all fit in flash.
The driver doesn't work, so now on to debugging. I plan to make a JTAG cable next. :-)
While the parts for that are coming, I'll try using the serial console...
wow this is very exciting! keep up the great work!
having worked with lwip a little bit now, Im wondering exactly how youre using uIP in your application? Is it timer based? Where a periodic tick fires the IP core handler? Or is it something else?
Excellent initiative and work Adam! Looks like you are making a ton of progress. Thank you very much!!
I just got my first Maple and I have to be able to get the WiShield working in order to base my project on the Maple. I sure hope I can get it working, everything about the Maple is more appealing than an Arduino Mega to me.
I just downloaded your branch, and tried compiling the SimpleServer example. I get this error message:
error: expected initializer before 'PROGMEM' In function 'boolean sendMyPage(char*)':
In function 'void setup()':
If there is anything I can do to help, please let me know. I don't have any experience porting hardware drivers, but I do have lots of experience porting software. Feel free to contact me direct: jeshua (at) 3DTOPO (dot) com.
Thanks again!
3DTOPO,
The drivers and uIP stack compile now, but don't actually work yet. I'm working on getting the ZG2100 driver SPI interface working right now. I'm still early in the process.
-adam
Status update:
I ordered parts to make a JTAG cable today, that should come later this week, and hopefully I will be able to put it together this coming weekend and do some debugging with OpenOCD.
*Leaf Labs folks - will you consider selling pre-made JTAG cables for Maple? This item won't be a money-maker, but will aid people making or porting Maple drivers.
In the meantime - I can now blink the WiShield LED from the C driver code. (Not very exciting, since the LED is connected directly to the Maple, and not via the ZG2100.)
I'm trying to set up some serial print statements from C so I can see where I am in the driver initialization code, but haven't got that working yet either.
cheers
adam
poslathian,
re: how I'm using uIP - the WiShield driver includes two different web server frameworks. I haven't looked too closely at them, but if you clone the repo above, you can see what they look like in the examples/ directory.
There are callbacks that can hit either C/C++ code, or code in a sketch. The uIP stack appears to be interrupt driven, so I think I can have a main loop that reads data from my sensors, saves to a buffer, and when a request comes from the network, the callback can send the buffered data to the network.
This is all theory, I haven't tried it extensively. On the Arduino it works, but is much too slow for my application, a wireless EEG that reads 2000 24-bit samples per second.
If uIP turns out to be too slow - when you come out with Maple Native, I may be able to port lwIP to that and use the same ZG2100 driver.
Does that answer your questions? What are your thoughts?
-adam
3dtopo - progmem is the standard decorator in arduino for creating read-only memory elements that are stored in flash. I have gotten this functionality to work on maple, but its not part of any current release (perhaps the next release...)
As I was digging through the source tree to offer you some advice on how to get this working, discovered some hooks for progmem already made it into the release (thanks iperry? bnewbold? hmm...wasnt me). In the file flash.ld, located in your hardware/leaflabs/cores/maple directory (or your libmaple checkout) notice we define a section ".USER_FLASH" (line 139).
This declaration allows us to statically locate structures in to rom. This only works when you are using maple in FLASH mode (select maple flash from the boards menu). To direct the compiler stash something in rom we do this:
uint8_t myAwesomeThing[18240] __attribute__ ((section (".USER_FLASH"))) = {element1, element2...};
In this example I have created an 18240 Byte buffer that would not fit in ram, and forced it in to flash. I cant write to this buffer, however. It is read only. That is why this decorator is always followed by an initialization. Ive used this trick to store images, wave tables, and other big chunks of things on Maple. There are only a few short Macro writing steps to go from here to progmem, but at least this gives you the functionality you need. When you see progmem, replace it with this attribute tag.
adam - When I have some time I'll dig into it and see if I cant get it running. Ill keep you posted. Thanks!
postlathian, 3DTopo,
I'm changing the PROGMEM directive to expand to "const char..." (or whatever type); that seems to work. It would be better coming out of program memory, but not needed.
-adam
Whoops. I mean, 'typedef const char prog_char;' ...
Status update:
While waiting for the JTAG cable parts, I hacked together a library to do printf-style debugging over the USB serial console in C. I also got the same functions working on the Arduino. Then I was able to compare SPI tx and rx data on Arduino to Maple.
After some work, I can now successfully reset the ZG2100 module, and also read the ChipInfo block to get the version number of the ZG2100 firmware.
This works most of the time... but occasionally it doesn't. There still seems to be some indeterminism in the SPI tx/rx, but I am not sure where it is coming from.
I am not using the spi.c's spi_tx_byte(); I am using my own version that also looks at SR_RXNE, as without that, I had unreliable receive from the ZG2100.
/**
* @brief SPI synchronous 8-bit write, blocking.
* @param spi_num which spi to send on
* @return data shifted back from the slave
*/
uint8 zg_spi_tx_byte(uint32 spi_num, uint8 data) {
SPI *spi;
ASSERT(spi_num == 1 || spi_num == 2);
spi = (spi_num == 1) ? (SPI*)SPI1_BASE : (SPI*)SPI2_BASE;
spi->DR = data;
while ( !(spi->SR & SR_TXE) ||
!(spi->SR & SR_RXNE) ||
(spi->SR & SR_BSY))
;
return spi->DR;
}
I am not sure if this is the right thing to do, but I couldn't get it working any other way (so far).
With the ZG2100 resetting ok, it's on to the interrupts. I am trying to attach an ISR to pin D2, but the ZG2100 is either not signaling it correctly (due to improper set up or some other problem) or else the Maple isn't responding to it right.
The WiShield uses D2 for the ZG2100 interrupt. When I pull this low with a jumper wire, I do hit the ISR, but then the code hangs... perhaps I'm not re-enabling interrupts right?
That's the next mystery to unravel.
I have the parts for the JTAG cable but haven't put it together yet.
-adam
Hey adam,
To answer just the last part of your question, does the Maple enter a hard fault? A very useful debugging tool is the ASSERT() function which will start throbbing the blue status LED and spit out the file and line number over the Serial2 USART interface. You can sprinkle these in your ISRs to see which logic branch is being followed; this is hard with SerialUSB because the blocking/timeout delay time is non-trivial.
Messing with the peripheral interrupt routines is definitely tricky; they can preempt each other and status registers can change after the interrupt is already called, so operations should be "safe" and atomic.
bnewbold,
Well, I don't know whether it's in hard fault. How do I tell?
I will do what you suggest and use ASSERT() and the Serial2 USART. What would you suggest to read the USART on linux? A Bus Pirate? I don't have one of those yet; I do have an Arduino Diecimila though, but it runs at 5v. I also have an FTDI breakout, but that's at 5v too.
Time for some more equipment I guess. :-)
-adam
Hi adam,
I just ordered one of these and should have one by the end of this week or early next week. If you'd like to work with me let me know.
You must log in to post.