Archive for August, 2011

Building an AVR m0dul for the CCC r0ket

Friday, August 26th, 2011


Thanks to penma, ISP methods are implemented, check:
this commit on github


The CCC r0ket, handed out at the Chaos Communication Camp 2011, is a slick ARM based developing board, featuring a battery, a display, 5-way jog dial button, RF and an USB mountable dataflash.

More information can be found here:

The most intresting feature though is the m0dbus, which enables the eager tinkerer to build his own m0duls (addons), to bring new features to the r0ket. The wiki shows some m0duls like “the flame”, which is an LED with acrylic art.

My idea now was to build a m0dul that features a low-power AVR, which is connected to the r0ket over SPI (available through the m0dbus connectors) and offers even more possibilities for m0duls because of the possible UART interface, the more pins, one can delegate tasks to the AVR and so on. Virtually, i’d be a m0dul-m0dul or simply: m0dul². Can you go deeper?


cccamp r0ket with an avr m0dul


Since ripping the AVR out of the circuit to update its firmware is not an option, as a first step i looked into programming the AVR serially via SPI by the ARM. That is possible with most AVR MCU’s featurung “ISP Programming”. This leads to the first feature of the m0dul², beeing an in-system programmer for AVR chips. How cool is that?

ISP Programming is described in the full Datasheet of each AVR and the AVR910 note. Also, there are two implementations mentioned in this thread:

My prototype features an ATTiny2313 (because it was the first i found) so i tried flashing some IntelHex file via SPI, but so far didnt manage to get beyond the flash erase cycle (which works great). The hexfile is read completely into RAM (because the dataflash also uses SPI, just like the display) and then the ISP magic should happen.

If you think you could help the project, please checkout my fork at

I am working with an application (because space is sparse, so the official firmware will be too big) called “avrisp”. To build the firmware, simply change to the firmware/ directory and call the makefile with

make APP=avrisp

The avrisp lib is located under firmware/avr and should be built automatically. The firmware then has to be flashed to the r0ket in ISP mode (hold left and power up). Im doing this via dd and a little helperscript ““.

Since the display cant be used while flashing via SPI (shared bus), the ISP routines feature no debug output. I created *_dry functions, which print to the display instead of talking to the SPI bus, in order to locate the problem.

Hooking up the AVR is straightforward. The repo contains hardware schematics, which show the needed pins on the m0dbus connector. Looking from on top, the right (m0dul A) connector has the following pinout:

VCC-        -BUSINT

SS2-          -SCL

SS1-          -SDA

SS0-          -GND

SCK-         -MOSI

MISO-        -3.3V

I connected SS0 with RESET on the AVR and used the 3.3V for the AVR’s VCC. MOSI, MISO and SCK get directly connected. One could put resistors in between, i didnt. I connected a LED between GND and a pin, so i could the the AVR’s firmware.

Since the ARM runs at 72Mhz, but the AVR is at 8Mhz tops, one needs to divide the SPI frequency before trying to talk to the AVR. This is done in the avrspi_select() routine. Constants for the project are located in the avr.h


  • decide which AVR to use, it should have low power consumption but many features (adc, uart, timer, ram/flash) and run at 3.3V
  • fix code to be able to program AVR through SPI
  • integrate avrisp lib into r0ket repo
  • draft schematics, route layout, print pcbs, make kits
  • write SPI communication code, which can be used in the AVR firmware to talk to the ARM
  • build a m0dul² that uses the newly gained features (one i have in mind is to interface the MCA-25 cam)

I unfortunately dont have the time, to continue this right now, so if you have some tips, patches, ideas, feel free to comment, contact me (im also in #r0ket on IRC) or directly send some github pull requests. I’d love to see this w0rking.