The ATmega32U2 microcontroller in ATUSB needs to be programmed before
the board can be used. I'm describing here what the process will
ultimately be like (the boot loader still needs a bit of work until
all this will be as planned).

The firmware consists of two parts: a DFU-capable boot loader and the
actual application. The application implements access to the
registers and memory of the AT86RF231 transceiver.

The ATmega32U2 apparently comes pre-programmed with Atmel's DFU-like
boot loader, but this one expects an 8 MHz crystal while what we have
is an external 1 MHz clock (provided by the transceiver). To obtain
the 8 MHz clock needed for operating the ATmega32U2, we first have to
send a command to the transceiver. This means we need to flash our
own firmware in any case.


The boot loader is flashed via the ICSP protocol using the atusb-pgm
adapter. The adapter is a ribbon cable with a UBB on one end and a
board with pogo pins on the other end:

http://downloads.qi-hardware.com/people/werner/wpan/tmp/atusb-pgm-20110203.jpg

The programming is done by plugging atusb-pgm into a Ben, pushing
the board on the ATUSB such that the pogo pins connect to the exposed
ICSP pads, and then running avrdude on the Ben:

http://downloads.qi-hardware.com/people/werner/wpan/tmp/atusb-programming.jpg

There is an orange LED on atusb-pgm that happily flickers to indicate
progress.


Once the boot loader has been loaded, the application can be flashed
over USB, with dfu-util. (This also tests USB connectivity.)


To build avrdude and the firmware, you need the following qi-hardware
projects: ben-blinkenlights and ben-wpan

avrdude should be built according to the instructions in
ben-blinkenlights/avrdude/README

This avrdude also includes a patch that makes it fast-forward over
Flash sections that are not being programmed. This way, programming
the boot loader, which is at the very end of the Flash, requires a
bit less patience.

The instructions end with scp commands to install avrdude on a Ben
with host name "jlime". Change as needed. Xiangfu has made an ipkg
with a recent version of the "enhanced" avrdude for the qi-hw OpenWRT
distribution.


The firmware requires very recent versions of the AVR
cross-compilation toolchain. ben-wpan/atusb/fw/README explains how
to build it.

After that, a simple "make" in ben-wpan/atusb/fw will generate the
boot loader (boot.hex) and the application (atusb.bin). I'll provide
pre-compiled versions when we approach production.


To upload the files to the Ben, run "make upload" if your Ben's host
name is "jlime". Otherwise, use "make HOST=name upload"

To run avrdude, first bring atusb-pgm into position, then run
make prog  or  make HOST=name prog

If the programming and verification is successful, the LED will
flicker for a few seconds and then avrdude will thank you for using
it. Otherwise, you'll see an error message and have to try again.


The application will be downloaded by plugging atusb into a PC and
running  make dfu  (if an application has already been flashed,
i.e., if this is an upgrade and not the first programming, then the
make dfu  has to be issued within two seconds after plugging the
atusb into the PC.)


For (non-production) direct flashing of the application, without
using a boot loader, use  make prog-app

- Werner

_______________________________________________
Qi Hardware Discussion List
Mail to list (members only): [email protected]
Subscribe or Unsubscribe: 
http://lists.en.qi-hardware.com/mailman/listinfo/discussion

Reply via email to