Sunday, September 27, 2009

Bootloading the Arduino over XBee ZB

I was playing with the XBee and Arduino again, and reading a lot of posts about how to bootload the Arduino wirelessly over the XBee. It was a fairly intricate process, involving among other things a custom bootloader. Now, it should be said that most of these posts were fairly dated, so there may be something that's changed. Because when I tried it, it worked on first try, with the default bootloader.. Mysteriously.

Setup: XBee Coordinator on XBee USB Explorer on COM5, XBee EndDevice on Arduino Mega.

(BTW, if you read my previous post, this will not work with the rerouted Serial. Put both jumpers to 'XBEE' on the XBee Shield)

Anyway, here's how I did it.

  • Set up both XBee's to use 57600 baud.
  • Upload .hex-file using AVRdude. Here is my cmdline:
 avrdude -Uflash:w:ledXBee.cpp.hex:i -cstk500v1 -P \\.\com5 -pm1280 -b 57600 -D
  • At the precise moment you hit Enter, also press the reset-button on the Arduino. You may have to try a couple of times. Basically, methinks its because DTR isn't transmitted to the Arduino wirelessly, so you have to perform that duty yourself. I have an idea on how to fix it, but it requires some soldering..
  • Done.

A screenshot may be in order:

Ok, so that works like a charm. I must explain that the XBee's are 4 inches apart, and the binary is less than 3K. I don't know if it'll scale in size or distance.

So, over to that last pesky bit, having to hit reset manually.. But that will have to wait to another day.

4 comments:

  1. I have been trying this and I get close to getting it to work.

    avrdude: Device signature = 0x1e950f
    avrdude: stk500_cmd(): protocol error

    Any ideas?

    ReplyDelete
  2. Missed the rest of it

    avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xfc
    avrdude: AVR device initialized and ready to accept instructions

    Reading | ################################################## | 100% 0.02s

    avrdude: Device signature = 0x1e950f
    avrdude: stk500_cmd(): protocol error

    ReplyDelete
  3. I haven't played with it since I wrote the post, but I vaguely remember seeing similar; I think the avrdude binary shipped with the Arduino GUI has been patched, try using that one rather than a "stock" AVRdude from other sources

    ReplyDelete
  4. How is it possibile the communication? You are sending file through port connected to usb explorer not to arduino mega? How is it possibile that it's work? Can u explain

    ReplyDelete