Programming Hex-code on an Attiny85 with the Arduino

To get a HEX-code in your Attiny85 it is possible to use the Arduino as a programmer, but as you cannot load hexcode  in your IDE, it involves using avrdude.

First of all, we need to get the Attiny85 clocked to 8Mhz.

Open up your Arduino software and upload the ArduinoISP sketch to your board.

Disconnect the board from  your computer and attach the Attiny as shown  here. Also make sure you download and install the Attiny core files as described in that article

Connect your Arduino board in again and choose these settings.

Tools – Board – Attiny85 @ 8Mhz (internal oscillator; BOD disabled)
Tools – Programmer – Arduino as ISP
Tools – Serial Port – COMx (x being the com port that your arduino is connected to)

Then select

Tools – Burn Bootloader.

Just to clarify, you are not burning a bootloader here. You are resetting the fuses in the Attiny to clock it at 8Mhz.

Next, get the firmware into the chip. With that I mean the hex file you want in your chip

We do that by using the arduino as a programmer.  You should still still have the ArduinoISP sketch loaded on your Arduino.

Make sure your Attiny is still attached to your Arduino as described here and open a command prompt.  (In your windows start menu type cmd or chose the terminal in Linux/Ubuntu).



This will bring up a list of options explaining what everything does.
Screenshot from 2013-12-11 14:09:55

Only need a few of those commands.

This is what to type in cmd (on 1 line)

avrdude -c avrisp -p t85 -P comX -b 9600 –U flash:w:example_attiny85.hex:i

What does all that mean?

Avrdude… This calls the program-c avrisp…  This tells avrdude which programmer you are using.  The Arduino shows up as avrisp

-p t85… This is the avrdude code for Attiny85.

-P comX… This is the com port your programmer is attached to.  (Change the X to suit your programmer.)

-b 9600… This is the baud rate (Use what is specified in the sketch loaded onto your Arduino.) .

-U flash:w:example_attiny85.hex:i   This tells avrdude you want to write (w) the firmware (example_attiny85.hex) to flash memory (flash).  The ‘i’ is at the end to tell avrdude what format it is writing in.

Avrdude should now read your chip, write to your chip, then read your chip.

If all goes well, you should get:    avrdude done.

Also check here:  Programming an Attiny with an Arduino Nano.


37 thoughts on “Programming Hex-code on an Attiny85 with the Arduino”

  1. When programming the ATtiny85 with 8Mhz you say to Make sure your firmware is in the right place . Could you tell me what is the correct firmware and what is the correct place to put it.

  2. The correct firmware is the program you want to put in the chip.

    You will see where, when you open a command prompt) and type:


  3. Hi
    The option in ” Tools – Board – Attiny85 @ 8Mhz” will be available when the arduino will be programmed as ISP? Cause now that nothing is plugged in I can see only Arduino type devices available on the menu “Boards”.

    1. Babbiz tnx for yr comment. In all honesty now i read the article i wonder myself what i was trying to achieve as it seems the article is incomplete. In order to program the attiny u need to install an attiny core. At the bottom of the article u will see a link to an article about using an arduino nano for programming. That article describes the cores to use

  4. Hi there! Great post, it led me in the right direction, albeit I had to do some tweaking. The last avrdude command did not work due to an out of sync error. If found this thread:,111853.0.html where it says that you have to change the baud rate from 9600 to 19200, which solved my problem. Just wanted to point it out, maybe my case is special. Thanks again.

      1. Thanks for your reply, I think the link with the fusecalc will help. In your steps describing how to use an arduino for programming, you have provided and example for the use of avrdude as;
        “avrdude -c avrisp -p t85 -P comX -b 9600 –U flash:w:example_attiny85.hex:i”
        From the fusecalc page, I can see that it is possible to set fuses on the avrdude command line, so the new command may be something like the following (considering ATTiny25);
        “avrdude -c avrisp -p t85 -P comX -b 9600 -U lfuse:w:0×62:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m –U flash:w:example_attiny85.hex:i”.
        I’ll have a go as soon as I get my ATTiny for experimentation and report back. 🙂

      2. Thanks for your feedback. Good luck. Remember that if u set a fuse that alters the RST function of pin 1, u will need a high voltage programmer to reprogram it again

  5. Hello!
    I hope someone give me an answer.
    I tried the avrdude command but it writes: Please define PAGEL and BS2 signals for ATtiny45
    (Sorry fo my english)

    1. I don’t understand yr problem maybe.
      You ask me how to ignore something? Well, by ignoring it.

      Or do you mean that it won’t program because of that error?
      in that case:
      Are you sure it didnt program?
      Do you have the latest version of AVR dude?

      1. Its working!I just restarted my computer and it works.
        Thanks for the answer

  6. Great! would it be just as simple to only read the code from an already programmed attiny (4313-pu)?
    Maybe something simple i can do here: -U flash:w:example_attiny85.hex:i

    Maybe you can steer me in the right direction. Hope it’s kind of on topic still.

    Thank you.

    1. You can use AVRDude to read the flash memory and save it to a file. You could then use AVR Studio to disassemble the code and you could then look at the program in Assembly. I have never tried it myself though and trying to decipher the assembly code might take longer than just writing the code you need. Good luck

      1. Thank you. i already found this, it should work and construct a flash.bin file: avrdude -p t4313 -c avrisp -P /dev/cu.usbserial-A800eFAR -flash:r:flash.bin:r

        but it gives me a bunch of error messages: ” stk500_getsync() attempt 1 of 10: not in sync: resp=0x00 ” etc.
        And those leed me nowhere. i’m using an arduino duemilanove(ATmega328).

        maybe it is because the protection fuse is set on the attiny. or just a communication problem. (i do see a blinking led on the arduino).

        Will give it another try.. and probably best to bring it to another forum… maybe get a olimex avrisp!

      2. your error message could point to a faulty connection or that it is trying to read another chip than expected. But t4313 should be OK I think

      3. ah oke, i’ll let you know. also.. just to clarify, i only unloaded the arduinoisp sketch and set up the correct connections given here:

        Could it also have something to do with the 120ohm resistor i put between reset and vcc? maybe the attiny4314 is set to 8 MHz.. hmm.

        Do i need to connect a cap and resistor on the duemilanove?

        Will try the 0.1 uF capacitor between VCC and GND and 10 Kohm resistor between RESET and VCC.

        Thanks for helping me out!

      4. I have tried the cap as well as the resistor, but never both at the same time 🙂
        I forgot what value I used for the resistor, but the caps I used were 10 uF.
        So you can try the 10k+0.1uF as you describe, but also try the 10uF alone between reset and ground.
        I am sure you have read this blog: telling you to use a 120 Ohm resistor instead of the 10uF.
        the connections you made seem OK, but just make sure the wires connect. Are you using a breadboard?
        I have had many occasions where i got the not in sync error and several times it was through a wrong connection, eventhough I checked several times.
        The fact that the Attiny is 8Mhz should not make a difference. That is only important for the program you are going to run on it.
        for the programmer it is just a matter of setting fuses, and for that it first has to connect 🙂
        Good luck. please keep me posted

  7. Hi, thanks again.. i used a breadboard and the wires should be ok (checked continuity etc. 😉 )

    I tried about everything at this point, 120 ohms, 10k+0.1uF and 10uf, i also read people had some succes with this error by removing the capacitor. did that but without luck.

    Also got a nano clone from banggood but same error.

    I think i tried about everything ;), I tried different programmer names in the avrdude command line that gave some other errors. (that let me nowhere). also tried to read the fuses but i got the same error!

    anyways, i searched the web and could not find anyone that successfully burned this chip with the arduino, 2313 no problem tho.

    So i gave up, thanks again for your suggestions. I need an avrisp anyways so will go that route and see where it leeds me!


    1. Actually I found 1 or 2 who made it. Apparently someone succeeded with the 022 IDE, using the 2313 settings, altered to match the 4313, but I agree, many people have problems with it.

      As we seem to be in the same country and yr 4313 seems to not be doing anything soon, would you care to spend say 69 cts in postage and let me have a go? Will send it back to you, failed or succeeded. Send me the program that you want in there too, of course, only if you feel like it.

  8. Good morning, I am trying to load an .hex firmware to an attiny85 using an arduino uno as ISP on a MAC, when i run the command: avrdude -c avrisp -p t85 -P /dev/cu.usbmodem1411 -b 19200 –U flash:w:AVR-FirmwareV15.15-ATtiny85.hex

    I get this response:

    avrdude: AVR device initialized and ready to accept instructions

    Reading | ################################################## | 100% 0.02s

    avrdude: Device signature = 0x1e930b

    avrdude: safemode: Fuses OK (E:FF, H:DF, L:E2)

    avrdude done. Thank you.

    But he doesn’t seems to write the software after reading the fuses right? Intact when I try to use the chip seems not programmed!

    Any help is really appreciated!


    1. That is odd. At first glance it seems you have done everything right. Are you sure the chip is not programmed? could it be that your program is faulty and just doesnt do anything?
      Can I suggest you specify the format. If you are using intel hex then just add “:i” (without quotes after your filename

    1. No it is not. A makefile is a simple text file that organizes the code you want to compile.
      What i describe here is how to program a specific hex-file into an attiny

      1. Are you sure you have avrdude installed? it should be installed if you have the arduino IDE installed

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: