Flashing the bootloader with USBtinyISP/avrdude

First make sure the chip sits on the PCB properly and the quartz with load capacitors is on there too. Then connect to the board with the 6pin header. Pin 1 is marked by the red wire. Make sure it is aligned with pin 1 on the PCB.

In contrast to what is shown in the picture, REMOVE the 3 jumpers on the right. This disconnects everything connected to the SPI lines and avoids interference with the programming process. When you’re done with flashing the bootloader/code, put the jumpers back on.

Flashing the bootloader with USBtinyISP / avrdude

To check if USBtinyISP/avrdude see the chip use this:

1
2
3
4
5
6
7
8
9
10
11
avrdude -p m168 -c usbtiny
 
avrdude: AVR device initialized and ready to accept instructions
 
Reading | ################################################## | 100% 0.01s
 
avrdude: Device signature = 0x1e9406
 
avrdude: safemode: Fuses OK
 
avrdude done.  Thank you

Unlocking the chip and writing the fuses on a blank chip. The fuse settings were taken from the bootloader Makefile of Arduino-IDE V15 and are for the ATmega168 chip.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
avrdude -p m168 -c usbtiny -e -u -U lock:w:0x3f:m -U efuse:w:0x00:m -U hfuse:w:0xDD:m -U lfuse:w:0xFF:m
 
avrdude: AVR device initialized and ready to accept instructions
 
Reading | ################################################## | 100% 0.01s
 
avrdude: Device signature = 0x1e9406
avrdude: erasing chip
avrdude: reading input file "0x3f"
avrdude: writing lock (1 bytes):
 
Writing | ################################################## | 100% 0.00s
 
avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3f:
avrdude: load data lock data from input file 0x3f:
avrdude: input file 0x3f contains 1 bytes
avrdude: reading on-chip lock data:
 
Reading | ################################################## | 100% 0.00s
 
avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: reading input file "0x00"
avrdude: writing efuse (1 bytes):
 
Writing | ################################################## | 100% 0.02s
 
avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0x00:
avrdude: load data efuse data from input file 0x00:
avrdude: input file 0x00 contains 1 bytes
avrdude: reading on-chip efuse data:
 
Reading | ################################################## | 100% 0.00s
 
avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0xDD"
avrdude: writing hfuse (1 bytes):
 
Writing | ################################################## | 100% 0.02s
 
avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xDD:
avrdude: load data hfuse data from input file 0xDD:
avrdude: input file 0xDD contains 1 bytes
avrdude: reading on-chip hfuse data:
 
Reading | ################################################## | 100% 0.00s
 
avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xFF"
avrdude: writing lfuse (1 bytes):
 
Writing | ################################################## | 100% 0.02s
 
avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xFF:
avrdude: load data lfuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip lfuse data:
 
Reading | ################################################## | 100% 0.00s
 
avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
 
avrdude done.  Thank you.

Flashing the bootloader and locking the chip:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
avrdude -p m168 -c usbtiny -U flash:w:ATmegaBOOT_168_diecimila.hex -U lock:w:0x0f:m
 
avrdude: AVR device initialized and ready to accept instructions
 
Reading | ################################################## | 100% 0.02s
 
avrdude: Device signature = 0x1e9406
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "ATmegaBOOT_168_diecimila.hex"
avrdude: input file ATmegaBOOT_168_diecimila.hex auto detected as Intel Hex
avrdude: writing flash (16294 bytes):
 
Writing | ################################################## | 100% 51.78s
 
avrdude: 16294 bytes of flash written
avrdude: verifying flash memory against ATmegaBOOT_168_diecimila.hex:
avrdude: load data flash data from input file ATmegaBOOT_168_diecimila.hex:
avrdude: input file ATmegaBOOT_168_diecimila.hex auto detected as Intel Hex
avrdude: input file ATmegaBOOT_168_diecimila.hex contains 16294 bytes
avrdude: reading on-chip flash data:
 
Reading | ################################################## | 100% 29.46s
 
avrdude: verifying ...
avrdude: 16294 bytes of flash verified
avrdude: reading input file "0x0f"
avrdude: writing lock (1 bytes):
 
Writing | ################################################## | 100% 0.02s
 
avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x0f:
avrdude: load data lock data from input file 0x0f:
avrdude: input file 0x0f contains 1 bytes
avrdude: reading on-chip lock data:
 
Reading | ################################################## | 100% 0.00s
 
avrdude: verifying ...
avrdude: 1 bytes of lock verified
 
avrdude: safemode: Fuses OK
 
avrdude done.  Thank you.

Alternatively you can use the Arduino IDE and just select Tools–>Burn Bootloader–>w/ USBtinyISP

A tutorial for USBtinyISP by ladyada. Has helped me a lot.

In case you get timeout errors you can try setting the bitclock avrdude uses to a slower speed. Try something like “-B 20″ for a start. Increasing the number makes it slower. If avrdude doesn’t seem to want to talk to the chip at all, make sure your wiring is OK and that you have a crystal or other suitable clock source connected to the chip. Chips from factory “should” run with the internal oscillator, but so far I’ve had to use a crystal with every single one I got. If the chip doesn’t get the clock source it is configured to use (by the ominous fuse settings), it won’t work as the chip is halted.

Please also have a look at my projects page.

Related posts:

  1. Jyetech AVR digital oscilloscope DIY KIT — trying to fix it – part 2
  2. Jyetech AVR digital oscilloscope DIY KIT — Firmware upgrade odyssey
  3. V3 prototypes for sale
  4. Showing live video on my 64-pixel display
  5. Nitelite upgrade — another RGB thingy

This entry was posted in Arduino., Electronics. and tagged , , , , . Bookmark the permalink.

3 Responses to Flashing the bootloader with USBtinyISP/avrdude

  1. robert says:

    Hmmm. I didn’t put the FTDI-chip onto the boards, so you’d have to build an adapter board that holds the chip and connect that to the ICSP header. The ICSP header on my boards is exactly the same as on the Arduino.

    So I think it should work if you build an FTDI-chip-board for it.

    Edit:

    Such an adapter already exists ! The X3 connector on the Diecimila uses the CTS,DSR,DCD and RI lines of the FTDI chip. These are all available on this breakout board. So you could turn it into an USB/TTL cable for normal upload and a bitbang programmer.

  2. Pingback: My 2µF » Getting auto reset to work with FTDI cables on Linux (MAC)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">