How to configure the Atmel AVRISP MKii to work with Arduino IDE

Hello all, since I've been helped by so many knowledgeable and generous people here, I wanted to give back a little on what I've learned. After two days of searching literally hundreds of forums, blogs and spec sheets, I was finally able to get my Atmel AVRISP MKii to work with the Arduino IDE and upload sketches to my breadboarded Mega 328P IC. I found many threads with tips on doing this and that, but none had all the missing pieces nor helped walk a newcomer through all the little adjustments that had to be made in order to make this happen (at least for a newbie like myself).

So here goes; For this particular tutorial, I'm using a breadboarded Mega328P with the Atmel AVRISP MKii with Arduino IDE 0023 on a Windows 7 machine. If anyone spots an error, please let me know.

  1. DO NOT install the Atmel AVR Studio software suite. It installs the "Jungo USB" driver which is not compatible with AVRdude (which the Arduino IDE uses). You can either use one of the other, not both at the same time.

If by chance you had already installed AVR Studio and the Jungo Drivers, don't worry, I'll show you how to replace it further down.

  1. Download the LibUSB-Win32 driver and extract it somewhere temporary. It can be found at www.libusb.org, however, for some reason my machine did not like this version, so I found another version that appeared to be tailored specifically for the AVRISP MKii here: AVRISP mkII libusb drivers for Windows 7 / Vista x64 | MightyOhm

  2. Now if you haven't installed the Jungo USB drivers, then you can simply plug in your AVRISP MKii, but when it asks whether you wish to install the drivers for it automatically or manually, choose MANUAL. If your did like mine and went ahead automatically and installed the stinkin Jungo USB drivers anyway, then you'll need to do the follow:

How to replace the Jungo USB drivers:
A. Go into your Device Manager and expand the tree under "Jungo". If you see "AVRISP mkII" there, then you'll need to replace that driver with the LibUSB-Win32 driver. Right-Click and select "Update Driver Software" and then choose "Browse my computer for driver software". Then simply navigate to where you extracted your LibUSB-Win32 drivers and let it do it's thing. If it refuses to replace it or says that Windows deems the current driver the latest, then you'll need to find a better/newer copy of the LibUSB driver. You can also try uninstalling the Jungo driver first, but my smartass PC kept reinstalling it automatically everytime I plugged the AVRISP MKii back in---regardless of me manually clicking cancel!

  1. If the LibUSB-Win32 driver installed correctly, the AVRISP MKii should now appear under "LibUSB-Win32 Devices" instead of the Jungo tree. This is important to make sure of because the Arduino IDE will NOT work with it as long as it appears under Jungo.

  2. Now, to get the Mega328p to work with IDE 0023, you'll need to edit the /hardware/boards.txt << within your Arduino install folder and add the following to the very bottom:

###############################################

atmega328bb.name=AVRISP mkII w/ ATmega328
atmega328bb.upload.using=arduino:avrispmkii
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600
atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05
atmega328bb.bootloader.path=arduino:atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F
atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino
atmega328bb.build.variant=standard

###############################################

Keep in mind the above is for the Mega328P (the "P" being the "Pico" version of the chip). You'll need to make some minor adjustments for the non-pico version).

  1. Now locate /lib/preferences.txt file and find the line "upload.using=bootloader" and replace it with, "upload.using=avrispmkii" (we're just replacing the bootloader with the avrispmkii)

  2. DONE! You're now ready to begin using your new AVRISP MKii!!! When you first open up the Arduino IDE (I'm using 0023) go to Tools > Boards > and you'll see a new entry for "AVRSIP MKII w/ ATMega328" > choose this one if you're that's the chip you're using like I am. After that, I'd suggest you try out a simple sketch like the Blink LED in the examples folder and make sure it all works.

Some closing tips. If you're hooking up the MKii to your breadboard, be sure you have the cable's pinouts correctly. I found so much confusing and contradictory pinout information for the AVRISP MKii on the web it was rediculous. It all comes down to locating PIN 1 -- which is always located on the side of the ribbon with the stripe. Now since two pinholes line up with the ribbon stripe, look carefully for a triangle symbol. The triangle will point you to PIN 1, and thereafter you can make out the orientation of all the other pins.

I really hope this helps out other people and saves you all the headaches I had to go through to get this thing working. I swear at one point I was ready to hang the MKii on a post outside and put a bullet through it!

great work

Is it also true or not that the Atmel AVRISP MKii will not provide power to the target? I have a USBtiny programmer that does provide such +5vdc power for the target if you have a jumper clip in the correct position, but thought I read that some programmers don't offer that selection option?

Lefty

retrolefty:
Is it also true or not that the Atmel AVRISP MKii will not provide power to the target? I have a USBtiny programmer that does provide such +5vdc power for the target if you have a jumper clip in the correct position, but thought I read that some programmers don't offer that selection option?

Lefty

It will not provide power (at least from my experience with a Mega328p on breadboard setup). I had to hook up an external +5v to the breadboard rails and then hook up the MKii's +5v and GND leads to the +5V & GND rails in order for it to program correctly. The MKii will power up itself via USB, but I found that it checks to verify you have power to the Chip you're programming.

great work, but how do you make it work on arduino version 1.0

@retrolefty

As velocity101 said, it will not provide power. From reading the user guide

The Atmel AVRISP mkII supports target voltages from 1.8V up to 5.5V.

Note
VCC must be connected to the target board in order to get correct operation and voltages on the ISP/PDI lines. VCC does not draw any power from the target.

In fact, the AVRISP mkII will not detect the target until it (the target) is powered. Also (I can't find the quote right now), I read somewhere in the user manual that the programmer senses the target voltage and adjusts its self by level shifting to the correct voltage. I do know when you enter the programming dialog it displays the current target voltage.

Hope this info helps.

BTW I was here a few days ago and found a thread on how to get the Arduino core to work under Atmel Studio 6. I followed the instructions and it worked! For me anyway. But after messing around a bit, I'm having some minor troubles. So, I need to find that thread (that's what I was doing when I came upon this thread) and follow the steps again. It's really cool 8) having all those libraries playing nicely with a full featured IDE with debugging capabilities. :smiley:

So, I'm off to search...
DigitalJohnson

hdmafukidze:
great work, but how do you make it work on arduino version 1.0

Yes I wondered the same . why not swap to the latest Arduino and configure it for that . How many people still run V0023 ?

I know this is ancient thread, but i had to register just to thank you for this post. This helped me to recover my arduino mega2560 from forever upload loop that many people experience. I borowed avr isp mk2, followed your instructions, burned new bootloader and now it works. Thanks again, cheers!
Tom

Hi all - The AVRISP MKii is a great device that comes with no directions; I'm trying to use it with Arduino IDE to program an ATTINY85. Velocity101's post is the closest on the web to do this, but I need more instruction particularly in step 5.

I tried the AVR fuse bit calculator http://www.engbedded.com/fusecalc but had not luck. I am using the ATTINY85V-10SU, the summary data sheet is here: http://www.atmel.com/Images/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet-Summary.pdf

I have measured my board supply voltage at 5VDC being supplied to the Vcc pin of the chip. Note this microprocessor runs at 10MHz (not 8MHz as listed in the above fuse bit calculator).

I sure other users would like to use the AVRISP MKii to couple to other ATEML chips, as well. Please provide more instruction on how to get over this fuse bit hurdle. Thanks!

I really really hate to grave dig, but none of this worked for me... If you need to replace the Jungo driver and windows still won't let you although you've uninstalled all of Atmel Studio (like me). It's easy to get it working... Don't fight Jungo, trick it.

  1. Navigate to your Windows Directory
  2. Go to "System32"
  3. Go to "drivers"
  4. rename "windrvr6.sys" to "windrvr6.sys.bak"
  5. paste in the libusb0.sys file
  6. rename it to "windrvr6.sys"
  7. The Arduino IDE should be able to find the mkii

To revert just delete the "windrvr6.sys" file, and rename "windrvr6.sys.bak" to "windrvr6.sys"

i got round this by going into avrsisp properties and update driver which you have downloaded and manual change it using libusb driver

http://www.visualmicro.com/post/2014/01/17/AvrIsp-MkII-Usb-Driver-for-Arduino.aspx

Mark

Extremely helpful. Great job!

I also wanted to add. Some AVR ISP programmers implement the mkII protocol, but these are shown as a Serial device rather than USB. If this is the case no driver changes are needed and it works with both AVR studio and Arduino.

For the arduino the following changes are needed:

Open up the programmers.txt file

arduino-1.0.6\hardware\arduino\programmers.txt

Add the following line to the Programers.txt file:

avrisp.name=AVR_ISP_MK2
avrisp.communication=serial
avrisp.protocol=stk500v2

Close all open IDE windows and re-open the IDE.

Select Tools -> Programmer -> AVR_ISP_MK2

Select the COM port for the programmer in Tools -> Serial Port.

To Upload hit File -> Upload Using Programmer

Done.

Not worked for me, it regonizes as a AVRISP mkii device but it always says, USB error and timed out error.

Programming:
Not worked for me, it regonizes as a AVRISP mkii device but it always says, USB error and timed out error.

You have to be a bit more specific on that... What shows up on the device manager for example.

Hello,

I have been trying to get this to work. I have the same setup as the OP but when i modify the text files and try to upload using your recommended coding changes I receive a new error.

My new error is this..

Arduino: 1.6.5 (Windows 7), Board: "AVRISP mkII w/ ATmega328"

Sketch uses 20,968 bytes (68%) of program storage space. Maximum is 30,720 bytes.

Global variables use 1,300 bytes of dynamic memory.

Error while uploading: missing 'upload.tool' configuration parameter

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

Any help would be greatly appreciated!!

-LukasC

As per last post a device manager print showing the programmer would be helpful as there are different mkII versions. Also post the full contents of the upload tool file.

Arduino 1.6.4 Board description

###############################################

atmega328bb.name=AVRISP mkII w/ ATmega328
atmega328bb.upload.using=arduino:avrispmkii

atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600
atmega328bb.upload.tool=avrdude

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDE
atmega328bb.bootloader.extended_fuses=0x05
atmega328bb.bootloader.path=arduino:atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F
atmega328bb.build.mcu=atmega328
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino
atmega328bb.build.variant=standard

###############################################

Thanks you very much to share this.

Had to change upload.using to upload.tool