Encrypted USB stick with atxmega128a3u

Stephan Bärwolf's AVR stick is a wonderful device to play with: it is a breakout of sorts for ATMEL's atxmega128a3u chip, and I like how it is designed:

I wanted to make the AVR stick into an encrypted mass storage stick. At the moment I don't have any extra storage attached to it (no microSD or dataflash), so I only use the xmega's flash space as storage. This is really not a good way of doing things, since atmel chips' flash has a really limited number of writes (on the order of thousands), and of course it's small (for a mass storage device).

Nevertheless, I've succeeded. Firmware/sources here, using avr-gcc. The stick enumerates as a composite (Serial+MassStorage) device. Upon connecting to the Serial, one can enter a passphrase, which is then used for decrypting the 64kB image, which then appears as an ordinary Mass Storage to the PC.

The whole thing is possible only because Stephan has written a great bootloader for the xmega, which allows to write to xmega's flash from the firmware itself (this is normally not possible, and writing to flash can be done only from the bootloader, during regular flashing of a new firmware). More info about this is on Stephan's AVR stick page, look for "apipage example".

The USB communication uses the wonderful LUFA library.

The next step is to attach a microSD card to the AVR stick and use it for storage, instead of xmega's flash.