My hardware configuration:
ATmega644P w/ modified Sanguino bootloader (see below). WiFly GSX connected to AVR. AVR TX line has 10k/10k voltage divider to WiFly (as it is a sensitive 3.3v device), AVR RX NOT upshifted from WiFly. Make sure your AVR receives a logic one @ 3.3v. See respective data sheet.
- Modify bootloader to use higher baud rate. In my case, with external 16Mhz ceramic resonator I was able to achieve very reliable 57600 w/ not so reliable comms @ higher rates. You want your bootloader baud rate to match your application (aka sketch) baud rate so you don't have to reconfigure the WiFly. Compile and upload (FWIW, I use FTDI bit bang to burn bootloaders w/ avrdude +serjtag). Another tip, if your bootloader uses the ADA watchdog fast reset mods, undef them to give yourself more time to start the upload and to accommodate the > 800ms WiFly time to accept a TCP connection. If you can't or don't want to modify and burn a new bootloader, then figure out what baud rate your current bootloader uses and set your sketch and WiFly to that rate. I've seen Arduino/Sanguino bootloaders using 19.2k and 38.4k. This may work though I have not tested it.
- Configure the WiFly. Initially, I placed the force AdHoc pull-up jumper on GPIO 9 (see datasheet). I should state quickly here that the RN-131 datashseet says that when GPIO 9 is pulled up at boot, AdHoc mode will be entered and the WiFly will have an IP address of 169.254.1.1. It entered AdHoc mode, but it had a different IP address. As an aside, my WiFly (bought from SparkFun) seemed to have a configuration set reasonably different than the stated defaults from Roving Network. YMMV. Quickly I found the IP (you can write an IP detector w/ ping and bash in 2 seconds) and was able to configure it thusly (see datasheet for more info):
- Enter configuration mode '$$$'
- Set baud rate to match my bootloader (which matched my sketch/App). 'set u b 57600'
- Set the print level to 0. 'set sys printlvl 0'
- Disable comms messages. These are the '*HELLO*', '*OPEN*', and '*CLOS*' messages sent to the host UART and socket connections by the WiFly when a network connection is made. They are useless anyway as they often fire 1+ seconds _after_ connections come and go). You need to get rid of these so that the bootloader and avrdude aren't confused by them when they establish a connection.
Code: Select all
set comm close 0 set comm open 0 set comm remote 0
- Save the default config 'save'
- Exit configuration mode 'exit', be sure to reset the device to force the configuration reload.
- Test comms. Use whatever technique you currently use to upload sketches to your chip to send up the standard serial 'echo' program (You do have one of these, don't you?). Make sure it uses the same baud rate as your bootloader and the WiFly. Reset your AVR, telnet to the WiFly on appropriate port (default should be 2000). Type stuff, hit enter and it should be echoed back. Note that telnet is a carriage return buffered interface so no data gets sent over the socket until you hit enter. If you don't see your input echoed back, stop and fix the problem because the next step(s) just won't work.
- Upload sketch with avrdude! I was prepared to write a socket interface to avrdude but reading the manual revealed it already existed (hurray!). You utilize this by setting the port to a network socket. The '-P' argument specified the port and the network socket definition is 'net:host:port'. The Arduino/Sanguino bootloader emulates the 'avrisp' programmer type included in avrdude. There is no need to supply the baud rate via '-b' (sockets have no baud) but you will need to supply the '-F' to force upload despite a failed chip ident. reply. So, the upload avrdude command line (for me w/ the ATmega644P) looks like:
Code: Select allMake sure you hit reset before slapping return on that command. Then sit back and watch your AVR get a sketch uploaded to it over WiFi.
avrdude -c avrisp -p m644p -P net:169.254.1.1:2000 -F -U flash:w:mySketch.hex:i