Home / Arduino / How to Flash Arduino Bootloader without a Programmer

How to Flash Arduino Bootloader without a Programmer

If you have an Arduino Uno R3, then you don’t need any programmer to flash a bootloader into ATMEGA328P.

How does it work: There are two microcontrollers on the Arduino board: ATMEGA328P (328P) and ATMEGA16U2 (16U2). You can update firmware of 16U2 to become AVRISP MKII programmer and then use Atmel Studio to flash 328P.

I started with kosakalab website, but I had some issues and the steps didn’t work very well for me (especially the part of flashing bootloader through Arduino Software). There were more problems and therefore I decided to put the whole process on my blog, so other people can save their time.

Install Atmel FLIP Software

You will need Atmel FLIP software to update the firmware inside 16U2.
1. Go to http://www.atmel.com/tools/FLIP.aspx and download FLIP.
2. Install it. You should not have any problems, just follow the installation wizard.
3. Take your Arduino board, disconnect it from Power and USB. Fit a Link on ICSP1 header, pins 5-6 (this will keep 16U2 RESET in Low).

4. Connect Arduino to USB.
5. Unfit the Link ICSP1 (5-6). At this moment, 16U2 goes into DFU mode. A new USB device should be recognized.
6. If driver is not installed automatically, install it from “c:\Program Files\Atmel\Flip 3.4.7\usb\”
7. Go to Device manager (Win+Pause -> (Hardware) -> Device Manager) and check if you can see the driver installed correctly. It will be located under Atmel USB Devices -> ATmega16U2

Flash AVRISP MKII firmware into ATmega16U2

We are ready to re-flash the firmware inside 16U2.
1. Download AVRISP MKII hex file here. If you would like to know how to compile it, have a look at Compile LUFA AVRISP MKII Project. The file is based on LUFA project.
2. Disconnect your Arduino from USB cable and Power.
3. Fit a Link on ICSP1 pins 5-6.
4. Connect Arduino to USB.
5. Unfit the Link on ICSP1 pins 5-6.
6. Start FLIP Software: Go to Start -> All Programs -> Flip -> Flip.
7. Go to Settings -> Communication -> USB.
8. Press “Open”.
9. Go to File -> Load HEX file and select LUFA-BOTH-AVRISP-MKII.hex
11. Press “Run”.

12. ATMEGA16U2 is now AVRISP MKII and it runs in Atmel Studio Mode. Important: Your “Arduino AVRISP MKII” can run in two modes: Atmel Studio or Avrdude. Below I only will be speaking about Atmel Studio mode as I had a lot of problems with Avrdude mode.

Install Atmel Studio

1. Download and Install Atmel Studio (including drivers) from http://www.atmel.com/microsite/atmel_studio6/
2. After the installation, connect your Arduino to the USB cable. Both LEDs (RX&TX) should blink two times (that means, 16U2 is in “Atmel Studio” mode,). A new device will be recognized.
3. Install drivers. If they are not recognized automatically, you will find them in “c:\Program Files\Atmel\Atmel USB Drivers\”
4. Go to Device Manager (press Win+Pause -> (Hardware) -> Device Manager ) and check if you can see the driver properly installed. It will be under Jungo Connectivity -> AVRISP mkII

5. You are ready to flash ATMEGA328P. Go to the next point.

Flashing Arduino bootloader into ATMEGA328P through ATMEGA16U2

1. This is the hard part :) You will need to solder down some wires. Basically, we need to connect:
ICSP1 MISO2.Pin.1 <-> ICSP MISO.Pin.1
ICSP1 SCK2.Pin.3 <-> ICSP SCK.Pin.3
ICSP1 MOSI2.Pin.4 <-> ICSP MOSI.Pin.4
JP2 PB4.Pin.1 <-> ICSP RESET.Pin.5
See this nice picture at kosakalab post (thank you Kimio):

2. Connect your Arduino board to USB cable. The RX&TX LEDs should blink two times. Drivers should be correctly recognized (Jungo Connectivity -> AVRISP mkII)
3. Start Atmel Studio. Go to Start -> All Programs -> Atmel -> Atmel Studio.
4. Go to: Tools -> Device Programming
5. Select: “Tool” -> AVRISP mkII; “Device” -> ATmega328P; “Interface” -> ISP; and press “Apply” button.
6. Set ISP clock to 16.1kHHz. Press “Set” button.
Note: Programming will not work if you set a very low ISP clock speed. You will get error: “ispProgramMem: Error status received: Got 0x81, expected 0x00 (RDY/nBSY pin sampling timed out)”. However, the maximum ISP speed is also limited and it can not be more than 1/4 frequency of the device.

7. Go to: “Device signature” and click on “Read” button. You should see the correct “Device signature”: 0x1E950F
8. Click on “Memories” and find the Arduino bootloader hex file. It is located in “C:\Program Files\Arduino\hardware\arduino\bootloaders\optiboot\optiboot_atmega328.hex”
9. Press “Program” button
IMPORTANT NOTE: If you use a brand new unprogrammed ATMEGA328P, you also must program FUSES. Go to Fuses and use following values: low_fuses=0xff; high_fuses=0xde; extended_fuses=0x05

10. You have successfully programmed 328P with Arduino bootloader. In the next step, we will put back the original 16U2 firmware.

Re-flash ATMEGA16U2 to the original Arduino software

Almost done. We need to put back the original software into the ATMEGA16U2.
1. Disconnect your Arduino from Power and USB.
2. Put a Link on the ICSP1 and short pins 5-6.
3. Connect USB cable.
4. Remove the ICSP1 5-6 Link.
5. Start FLIP software. Go to: Start -> All Programs -> Flip -> Flip.
6. Go to: Settings -> Communication -> USB.
7. Click to “Open”.
8. Go to: File -> Load HEX file. Select this file “c:\Program Files\Arduino\hardware\arduino\firmwares\atmegaxxu2\arduino-usbserial\Arduino-usbserial-atmega16u2-Uno-Rev3.hex”
9. Press “Run”.
10. Disconnect USB cable and connect it again. A new USB device should be recognized. If driver is not installed automatically, you will find it in “c:\Program Files\Arduino\drivers\”.
11. Go to Device manager (Win+Pause -> (Hardware) -> Device manager) and check if the driver was loaded correctly. You should see it under Ports -> Arduino Uno

12. Great! We can now test a Blink example. Start Arduino software (Start -> Arduino).
13. Click on the “Open” icon (arrow Up) -> 01.Basics -> Blink.
14. Select COM Port: Tools -> Serial Port -> COM(select the port where the board was recognized).
15. Click to “Upload” icon (arrow Right).
16. The user LED should start blinking :)
17. Done! You have successfully re-programmed ATMEGA328P without using any external Programmer.

Learn to Design Your Own Boards Online – Based on Arduino

After this course, you will design your own Arduino like board. This course is for everyone who has never designed any board before and would like to try it.

How to register for this online course?

Step 1: Register & Login at FEDEVEL Academy website – Click here
Step 2: Select your course (you will need to be logged in) – Click here

Find out more about this course in this short introduction video


Learn Advanced PCB Layout ONLINE

You will learn how to do Advanced PCB Layout (DDR3, PCIE, SATA, Ethernet, etc.).

How to register for this online course?

Step 1: Register & Login at FEDEVEL Academy website – Click here
Step 2: Select your course (you will need to be logged in) – Click here

Find out more about this course in this short introduction video


Learn Advanced Hardware Design ONLINE
Starting next week. Don’t miss. Register here >>
Special offer THIS WEEK ONLY: Sign up for Advanced Hardware Design Course and Get FREE Altium Essentials Online Course Register here >>

This course will show you how you can design boards more effectively and produce professional results. It provides you tips and tricks to help you to design boards that work the first time.

The course is practically based and will teach you everything by actually doing it. Anyone who is interested can work on his/her own project during the course. By the end of the course you will have learnt how to create professional manufacturing output which you can then use to build your own board.

How to register for this online course?

Step 1: Register & Login at FEDEVEL Academy website – Click here
Step 2: Select your course (you will need to be logged in) – Click here

Find out more about this course in this short (2 minutes) introduction video

  • Pingback: 14 Tips to improve Arduino Schematic and PCB - (FEDEVEL)()

  • Luis Delgado Cortés

    Thanks a lot, it worked just fine. Thought I had to buy a new ATMega.

    • http://www.fedevel.com Robert Feranec

      Perfect :) I am very happy that this post helped you. Thank you for leaving your comment.

  • OVIDIU

    it worked just fine
    Thanks very very much
    it took a while but all done nicely
    thx for share it with us

    • http://www.fedevel.com Robert Feranec

      Thank you Ovidiu. I am very glad you found it useful.

      • OVIDIU

        Hello again. I’ve made a Mini CNC Machine Plotter from dvd floppy drives stepper motors, Ive regulated the drivers for the motors Pololu a4988 to vref= 20
        All work great..controling the machine through grbl controller and universalgcode sender with the arrows keys..but i have a problem..i can’t make it work draw by sending gcode to it..it responds, but it doesnt draw well ..its frustrating cause i dont know whats seems to be the problem. I even put right codes in the command line with $$ and i dont know what else to do ..if i am missing something or what.can yo help me up ..give me an ideea.to see it well i have a link to my youtube channel were you can see function it and some of the drawings that ive made….here is the link:
        https://youtu.be/lZ-y1UnB9z4
        Any help will be appreciated
        Thx in advance
        I forgot to tell you what boards i am using
        I use an arduino uno r3 that i just fixed with your tutorial thx again
        A gshield cnc protoneer version 3.oo red
        3 pololu drivers a4988 red as well ..
        Thx again

        • http://www.fedevel.com Robert Feranec

          maybe someone can help you. I normally do not work with arduino nor with 3d printers :(

          • OVIDIU

            Thx, i solved the mistery..it was all about calibration ..and configuring the grbl.i already post some videos on my youtube channel on how its drawing
            I am very pleased with the results and now i can pass through the next level of doing things: my prusa i3 mendel einstein.
            Thx again for your quick response

          • http://www.fedevel.com Robert Feranec

            AWESOME!

  • OVIDIU

    nice steps .nice comments and all perfect..the only problem i had was with

    an error before setting the clock that i fixed with replacing a driver with zadig, here is a link of the error & solution : https://www.olimex.com/forum/index.php?topic=4065.0

    worked ok for me to continue with the flashing

  • Leland Clayton

    Didn’t work for me. I wonder if it’s because I had to use Atmel Studio 7 and force Windows to use a unsigned driver. When I try to setup the AVR in Atmel Studio it will disconnect and ends up with a error.

    • http://www.fedevel.com Robert Feranec

      It should work even with unsigned driver. The only issue is, you need to be very careful about using the correct driver for the correct Arduino mode and for the correct software (Atmel Studio or Arduino environment). Only one combination will work.

  • mirion

    How can you put in DFU mode an Arduino Mega 2650 R3 ?? Thank you !

    • http://www.fedevel.com Robert Feranec

      Hello, I am not really sure. I din’t try that board, but if the Microcontroller supports DFU, you should be able to find in datasheet which pin has to be controlled.

  • محمد الأغر

    after pressing apply i got error “Unable to connect to tool AVRISP mkII (000200212345)” please help !

    • http://www.fedevel.com Robert Feranec

      It should work. Maybe wrong driver? Or something with cable / board? Try also switch off / on AVR studio.

  • Amanpreet Singh

    Nice article, really helpful !!

    • http://www.fedevel.com Robert Feranec

      :) thank you

  • Natà

    Hi, I just tried to do these few steps and everything seems to work fine until this step :

    5. Select: “Tool” -> AVRISP mkII; “Device” -> ATmega328P; “Interface” -> ISP; and press “Apply” button.

    I’ve got an error which says : Unable to connect to tool AVRISP mkII (000200212345)
    What do you think it could be ?

    As I said, everything seems fine, I can see the device in the device manager, as Jungo Connectivity -> AVRISP mk II, the two LED’s are blinking twice when I plug the board into USB and I checked my wires almost 10 time, always the same issue, can’t connect !

    I also tried the other way, by the arduino software, after flashing the correct hex file, and idem.

    PS: Sorry for my English, Corsican guy. 😉

    • http://www.fedevel.com Robert Feranec

      Hmm, it should work.

      • Natà

        I know ! ^^
        I really don’t understand what i am doing wrong…
        I tried with another computer without solving the problem.

        But, i noticed when I turn my board in DFU mode with Atmel Studio, I can see it in Device Programming in the tool list as “Atmel Mega DFU”, I choose the right device and press “Apply”, I can see these informations in “Tool information” tab.

        Atmel Mega DFU

        Debug host 127.0.0.1
        Debug port 60413
        Connection com.atmel.avrdbg.connection.libusb0
        Bootloader version 1.32

        But, when I try to read the device signature, I’ve got an error;

        Unable to enter programming mode. The read device ID does not match the selected device or any other supported devices.

        And if I expand details;

        Unexpected signature 0x00940000 (expected 0x001e9489).

        Does the problem could come from there ?

        • http://www.fedevel.com Robert Feranec

          Don’t worry. Even I spent couple of days going through something similar. That is exactly the reason why I created this page, so other people don’t have to. I am just not sure why your board doesn’t work. Be sure you have the eFUSES set correctly, comunication speed is set right, you use the right drivers, AVR/Arduino mode is selected correctly and double check the wiring. Then it should work.

          • Natà

            Well, I think I’m gonna wait to receive my preloaded 328 chip ! 😀
            Anyway, thank you for your advices, and even if I didn’t solve the problem, I learned a lot, so thanks again and have a nice day. :)

          • http://www.fedevel.com Robert Feranec

            :)

  • kamal

    thanks for your support , i have a probleme with my arduino board , i can’t load the program in my chip , the message from arduino ide says :

    avrdude: verification error, first mismatch at byte 0x0000
    0x62 != 0x0c
    avrdude: verification error; content mismatch

    i’m tryring to figure out what’s happening because after this error the chip was acceting strange like auto-reseting , and after this i was trying change the program but this error come out , pleaze help me . (and sorry for my english)
    thanks

  • gunjan paul

    Hi! I have just bought an arduino uno r3 from an online store. This is my first arduino board(rather my first microcontroller). First of all, whenever I plug the board into my Windows 8 32 bit pc, it says “USB Device not recognised.” In the device manager, it is showing it as “Unknown Device.” According to the Arduino instructions, I tried to install the arduino drivers that came with the IDE. But it says “Windows has stopped this device as it has reported problems(Code 43).The device is not registering itself as a COM Port device. Hence, it is not being detected by IDE. Tried hundreds of things, but got no success. Then, I came across this post.
    After installing flip, whenever I try to install the driver manually(it is not installing automatically) , it displays the same message(Code 43). The device is not being recognised by FLIP and hence I cannot load the hex.
    I am now in serious trouble as I have to us it for a school project within a week. Please help me.

    • http://www.fedevel.com Robert Feranec

      Did you try to use a different USB cable?

  • eshan

    windows couldnt find any drivers :/