Putting HABL on an atmega168 MCU using USB in system programmer Install compiler and avrdude (on debian/ubuntu/mint style linux): apt-get install gcc-avr avr-libc binutils-avr avrdude To compile (optional): make Some HW will be needed. AVRISP MKII pin configuration. AVR ISP (In-System Programming) Pinouts 1 MISO 2 VTG 3 SCK 4 MOSI 5 RESET 6 GND Contact seen from below: +---+---+------- | 5 | 6 |------- [ 3 | 4 |------- | 1 | 2 |------- +---+---+------- red Pin one is the one marked red on flat cable. The test board used looked like this: ATMEGA328p 28pin DIL +------------+ reset ----| 1 | RxD ----| | TxD ----| | | | Resonator | | 20MHz | | +---+ VCC ----| 7 22 |------------- GND | 2|----- GND ----| 8 | | 1|---- XTAL1 ---| 9 20 |---- VCC ---- VTG | 3|---- XTAL2 ---| 10 19 |------------- SCK +---+ | 18 |------------- MISO | 17 |------------- MOSÍ | | | | +------------+ A decoupling capacitor (100nF) between pin 7 and 8 is not shown above. Connector J1 molex +-------++ | 1 VCC || | 2 RxD || | 3 TxD || | 4 GND || +-------++ Connector J2 molex +---------++ | 1 MOSI || | 2 MISO || | 3 SCK || | 4 VTG || | 5 Reset || | 6 GND || +---------++ Power: 7805 +-----+ batt+ ----diode>------------| |-------------- VCC | +-----+ | C1 === | === C2 | | | batt- -------------------------+----------------- GND C1,C2 = 100nF Used an adapter cable from J2 to AVRISP MKII connector. Used this to connect computer to J1: http://www.eit.se/opto_usb_uart Programming the device (using avrispmkII) Set read write properties on usb dev (or do this as root). Check that you have connection with your device avrdude -p m328p -P usb -c avrispmkII -U flash:r:flash.bin:r First the fuse bytes needs to be programmed. http://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega328p For boot loader reset. BOOTRST shall be 0 (programmed) For boot loader size 1024 words: BOOTSZ1 shall be 0 (programmed) BOOTSZ0 shall be 1 If you change here then you may neeed to adjust START_ADRESS_OF_BOOT_SECTION in Makefile also. If bootloder is 1024 it shall start at 0x3C00 I use a 16 MHz resonator so CKDIV8=1, CKOUT=1, SUT=10, CKSEL=1110 We have regulated 5V so brownout detection at 4.3 V avrdude -p m328p -P usb -c avrispmkII -U lfuse:w:0xFE:m -u -B 8 avrdude -p m328p -P usb -c avrispmkII -U hfuse:w:0xDA:m -u -B 8 avrdude -p m328p -P usb -c avrispmkII -U efuse:w:0xFC:m -u -B 8 When programming efuse I got "verification error... 0x04 != 0xfc". Seems we can ignore this error. Perhaps we want "Watchdog Timer Always On" WDTON, but thats a later problem. Downloading the boot loader program to flash write: avrdude -p m328p -P usb -c avrispmkII -U flash:w:habl.hex -B 8 Test device with some hello world program. Send the hello world binary using: sudo apt-get install cutecom lrzsz cutecom