0
\$\begingroup\$

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?

\$\endgroup\$
7
  • \$\begingroup\$ Uhhh, to use the ICSP header, you need a dedicated programmer. If you're using an Arduino as a programmer, the relevant pins are not the ICSP pins, and it's definitely not the USB-serial converters ICSP pins. \$\endgroup\$ Commented Aug 21, 2014 at 10:17
  • \$\begingroup\$ While you probably can do it in the way you propose, the normal well supported "Arduino as ISP" method uses the atmega328p to do the programming. It does not particularly depend on the Arduino IDE - the actual programming of the target, as well as getting the ISP sketch program into the `328p, is done by avrdude - either manually by you, or under the direction of the IDE. The one place the IDE might be handy is to build the ISP sketch to a hex file, but you can do that one and save it, or get it from someone else, or even build it with a makefile instead. \$\endgroup\$ Commented Aug 21, 2014 at 15:41
  • \$\begingroup\$ @ChrisStratton I don't mind using the 328p chip as an ISP, however I haven't found any information on using the command line to access/write (eg, what to set the -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\$
    – tgun926
    Commented Aug 21, 2014 at 21:39
  • \$\begingroup\$ To some extent the most effective route may be to do it once with the IDE while set to display the avrdude command it is using. I think I use something like this: $(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\$ Commented Aug 21, 2014 at 21:47
  • \$\begingroup\$ I think I see what's going on here. You seem to have misunderstood how the arduino programming system works. The ATmega16U2 is not acting like a USBASP. It's purely a usb-serial converter. The actual programming is accomplished by a bootloader already programmed onto the 328P. You can reflash the ATmega16U2 (it supports the DFU bootloader), but you'd have to port the firmware for the USBASP or similar over to it yourself. \$\endgroup\$ Commented Aug 21, 2014 at 23:15

2 Answers 2

1
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ Well that explains it, thanks. Do you know any ways of burning a hex file onto an attiny using Arduino? \$\endgroup\$
    – tgun926
    Commented 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\$ Commented Aug 21, 2014 at 15:39
0
\$\begingroup\$

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

\$\endgroup\$
8
  • \$\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
    Commented 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\$ Commented 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\$ Commented 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\$ Commented 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\$ Commented Aug 21, 2014 at 23:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.