I want to program an ATTiny microcontroller using an Arduino Uno board via AVRdude. According to the Arduino Uno schematic, there is a direct line from the USB controller to the ICSP1 header:
enter image description here
I connected the wires from the icsp header (also removed the ATMEGA328P chip) to my breadboard and then to the attiny chip, then ran this command:
$ ./avrdude -p t13 -c arduino -P com3
I also tried -c avrisp
However, there is no response. I'm sure the port is com3, because I can read the ATMEGA328P using com3 on avrdude.
Is there anything else I need to set to be able to program the attiny with avrdude?
2 Answers 2
You are correct; ICSP1 is connected to the ATmega16U2 which is serving as the USB to serial interface.
However, that ICSP1 is used to program the ATmega16U2.
AFAICT, the Arduino UNO's ATmega16U2 program does not contain any code to enable it be an ICS programmer, so the code on it will be for USB-to-serial and debugging.
You would need to reprogram the ATmega16U2 to have it act as a ICS programmer.
So you have a bit of an 'infinite loop'. You need a programmer to program the ATmega16U2, and if you had such a beast, you could program your ATtiny.
I believe it is possible to program an ATmega16U2 to be an ICS programmer (some less powerful ATtiny's do that). I am not aware of such a piece of sofwtare, but that doesn't stop it being found by a determined web search.
I searched for "programming attiny arduino uno".
Most links offered a solution, e.g.
http://www.instructables.com/id/How-to-program-attiny-using-arduino-uno/
http://www.instructables.com/id/Program-an-ATtiny-with-Arduino/
They use the Arduino IDE's "File -> Examples -> ArduinoISP" sketch, and wire up as shown by Connor Wolf.
-
\$\begingroup\$ Well that explains it, thanks. Do you know any ways of burning a hex file onto an attiny using Arduino? \$\endgroup\$tgun926– tgun9262014年08月21日 11:38:17 +00:00Commented Aug 21, 2014 at 11:38
-
\$\begingroup\$ I believe you can download a new firmware to the 16U2 over the USB, and that could potentially be one which drove the ISP pins to program an external target. But the normal way of accomplishing this task is to load an ISP sketch to the `328p. \$\endgroup\$Chris Stratton– Chris Stratton2014年08月21日 15:39:02 +00:00Commented Aug 21, 2014 at 15:39
You're hooking it up completely wrong. Where did you even get the idea you should use the ICSP pins for anything when trying to use the arduino as a ICSP programmer?
One of the dozens of results searching for "arduino ICSP attiny13": enter image description here
-
\$\begingroup\$ Well the USBasp board I previously used to program my attiny worked USB->Serial via the SPI lines, so I figured that's what the header was for. All the results I found (as well as your links) were for flashing sketches. I want to burn HEX files onto the attiny directly. \$\endgroup\$tgun926– tgun9262014年08月21日 10:36:34 +00:00Commented Aug 21, 2014 at 10:36
-
\$\begingroup\$ What the poster wants to do is not "completely wrong" and is probably quite workable. However, you are right that it is not the usual way of doing this. \$\endgroup\$Chris Stratton– Chris Stratton2014年08月21日 15:40:01 +00:00Commented Aug 21, 2014 at 15:40
-
\$\begingroup\$ @ChrisStratton - You cannot use the Atmega16U2 as a ICSP programmer without writing completely custom firmware for it. Full stop. You may be able to use the ICSP header for the ATmega328P with less modification, but that's not the ATmega16U2. My point is, whichever way you're going to do this, it's not going to use the ATmega16U2 pins. \$\endgroup\$Connor Wolf– Connor Wolf2014年08月21日 23:10:26 +00:00Commented Aug 21, 2014 at 23:10
-
\$\begingroup\$ AFICT, the OP is assuming that the ATmega16U2 is programming the ATmega328P over ICSP, rather then how it actually works (over serial, using a bootloader on the 328P). That assumption is completely wrong. \$\endgroup\$Connor Wolf– Connor Wolf2014年08月21日 23:11:42 +00:00Commented Aug 21, 2014 at 23:11
-
\$\begingroup\$ You can't use the ATmega328p as an ISP either, unless you load a specialized firmware to that. So it is basically the same requirement - either path should work, and I've freely pointed out which is more usual and supported by knowledge resources. The mistake in your answer is confusing tradition with possibility. \$\endgroup\$Chris Stratton– Chris Stratton2014年08月21日 23:36:42 +00:00Commented Aug 21, 2014 at 23:36
-c programmer
as). I burnt Arduino as ISP onto the board and connected the wires up as Conner shows, but with no connection. If you have any links on that it would be great \$\endgroup\$$(AVRBIN)/avrdude -C $(AVRBIN)/../etc/avrdude.conf -q -q -cstk500v1 -P$(TTY) -b19200 -p t13 -Uflash:w:something.hex
where the $ denotes system-specific variables. \$\endgroup\$