Building it, firmware

Ok, so the inner workings are as complex, but in the end the complete device is just 2 8-pin ICs with some wires in between, and a JTAG/serial connector. I built my device exactly like that:

That's a header, 2 ICs, a resistor and a capacitor. So, the hardware is nice and tiny. That, however, means the ATTiny85s firmware will need to do the heavy lifting to get it all to work. I've divided the firmware in a few parts: the flash driver, a software UART, an XMODEM driver, the JTAG driver and the XSVF interpreter.

Ofcourse, the most important things here are the XSVF interpreter and the JTAG driver. The XSVF interpreter will read a stream of instructions from the flash, but these instructions are all fairly heavy: you get instructions like 'Move the JTAG state machine to SHIFT-DR and clock in these 10 bits'. The AVR still needs to know how to do the 'move to SHIFT-DR'-part by wiggling the right pins; this is implemented in the JTAG driver. If you want to read more about JTAG: when I was developing the firmware this article on OpenSchemes.org proved to be a big help.

But what if the device is plugged into a serial port, for updating the JTAG bitstream? In that case, the JTAG routine will fail and the program will fall through. It will initialize a serial port at 38400 baud and listen for xmodem packets. Now, you can just send the new bitstream using an xmodem program and the device will flash it into the flashchip.

For debugging, the AVR also keeps a log in it's internal EEPROM, storing what went wrong the last few times it tried to execute the XSVF instructions. You can send an 'l' over the line to read out the log.

« Prev 3 Next »

© 2006-2016 Sprite_tm - Contact