September 2017
« Jun    


Active supporter of WikiPedia
Support Wikipedia


Profile for uwezi

Hacking an AVR programmer

(see also my recent appendix to this topic: Hacking an AVR programmer II – especially if you have an ATmega88-based programmer!)

On eBay I recently purchased a set of cute small USB AVR programmers which I intend to use in the course 1TE663 Microcontroller Programming at Uppsala University.

MK-USBISP-V3.00 programmer in an aluminum shell on eBay.

After waiting for one month for the delivery from China the package finally arrived today. Unlike other programmers which I purchased before, these come with a sturdy aluminum shell and in happy colors.

However, connecting the first programmer to my PC brought me quickly back to earth – it was not recognized as an USBasp. OK, it would not be the first delivery from China with broken or counterfeit electronics, so I tested the second one…

At that time I got a bit confused, because the programmer registered as an HID unit on the USB with vid=0x03EB & pid=0xc8b4. Not as an USBasp with vid=0x16c0 & pid=0x05dc.

This is the point where I usually ask Google. So I did and I found some threads discussing the same issue and pointing out, that these programmers needed a different software and were not at all compatible with avrdude. BAD!

But of course, one should be able to reprogram the programmer using another programmer. At my home this is not a henn and egg problem, since I have accumulated several AVR programmers.

Ok, I downloaded the USBasp firmware from Thomas Fischl, flashed the programmer after inserting the self-programming jumper:

Self-programming jumper on the MK-USBISP-V3.00 AVR programmer.

Since the original firmware is protected by the lock-bit fuses, I had to fully erase the chip first, then set the fuses correctly to HFUSE=0xc9 LFUSE=0xef and then flash the .hex file. I tried first the 2009-firmware from Thomas Fischl and the first observation was that instead of the red LED which was on previously, now the programmer showed a blue light.

But: Windows would not at all recognize this device as any USB device. Nothing showed up. I got confused. I tried both WinXP and Win7 – to no avail. Well, perhaps this programmer was not hardware compatible to the USBasp? Let’s have a look…

AVR programmer MK-USBISP-V3.00: component side.

AVR programmer MK-USBISP-V3.00: solder side.

There are some tiny, yet important, differences to the original USBasp programmer: in the USBasp USB-D- is connected to pin PB0, USB-D+ to PB1 and PD2/INT0. Here also USB-D- was connected to a pin on port D: PD3/INT1. Well, this should not really make a difference, and I continued my search for differences. OK, for some reason, also the LEDs are connected in parallel to 2 port pins each – so what…

In despair I decided to look into the source code of the USBasp firmware. The header files: OK – pin assignments were as expected, nothing special here. But let’s wait, where is the definition of the utilization of port D? Well, it was in the main.c file:

int main(void) {
  uchar i, j;

  /* no pullups on USB and ISP pins */
  PORTD = 0;
  PORTB = 0;
  /* all outputs except PD2 = INT0 */
  DDRD = ~(1 << 2);

hey – wait a second? All pins of port D are defined as output, except for PD2/INT0? I always tell my students to only define pins as output, which are really used as output… And what happens here?

Since the modified design also connected USB-D- to PD3/INT1, the rather aggressive definition of output pins leads to a unsolvable conflict, when suddenly PD2 is driving against the USB signals from the host!

Changing this little piece of code solved the problem. Rather conservative I set all pins of port D as input (none of them is currently used as output!):

int main(void) {
  uchar i, j;

  /* no pullups on USB and ISP pins */
  PORTD = 0;
  PORTB = 0;
  /* all PDx input */
  /* MK-USBISP v3.0 */
  DDRD = 0x00;

I compiled the code, flashed it onto the AVR programmer using another AVR programmer
…and behold: it works!

I will contact Thomas Fischl and tell him about this observation – perhaps the modification will be implemented in the distributed firmware on his homepage.

Here is a .zip-archive of the modified firmware. The .hex file for use with an ATmega8 is found in the default subdirectory.
Download ZIP archive: 20130212_mega8_usbisp

154 comments to Hacking an AVR programmer

  • Matari

    I’m kinda new about microcontroller knowledge.
    I’m searching an alternate ISP due to hard to find msp430’s chips (shipping from nearest supplier takes a whopping $40, too high when I want to buy only several(<10) for testing, buying the launchpad itself is cheaper :D)

    So, Can I reprogram the firmware without any external programmer? Because you mentioned 'self-programming jumper'.
    Or actually this can be solved with changing the HID? like this web:

    • uwezi

      “self programming” may be a bit misguiding and actually leads to a chicken-and-egg problem. You need another working programmer to reprogram the programmer.

      However, you can get a variety of AVR programmers on eBay where you do not need to do anything – these just work out of the box (or envelope when shipped from China). It’s only that this particular programmer has a nice aluminum shell which also protects it from short-circuits – essential if you want to give it to students in a project course 😎

      Look for a programmer which either directly states that it is compatible with avrdude or one which is explicitly called USBasp. If you plan to use it yourself but want to protect it better then you can easily encase it with a strip of heat-shrink tubing to protect it from being short circuited by loose wires from your breadboard or alike.

      The original firmware (HID) on the aluminum-cased programmer appears to be only supported by the Chinese software which you can download from the seller’s site. This has nothing to do with the driver for the USBasp which you will need additionally anyway.

      • korvin

        In my case, I’ve bought two USBasps (same as in the article) and utilized Progisp (the Chinese software) to reprogram one another, using 1p-1p female to female wires. Now they work perfectly with avrdude too. Progisp is pretty simple to use, however, an english manual for it could be found here:
        (*There is also a support for AVR_FIGHTER, but I haven’t tried it.)

      • Matari

        Thanks for the answer.
        I figured out the external programmer necessity after taking a little walk with Mr.Google and ended up ordering USBasp v2 by LCsoft which has 3.3/5v option (jumper setting).

        I’ll see if I can tackle this hen-and-egg problem with these 2 as the lcsoft need a firmware upgrade too 😀

        • uwezi

          Program the aluminum-cased one first, then you can program the other one. I have done this procedure myself a couple of times now, because most of the USBasp clones from China are shipped with an old Firmware which does not allow the SCK speed setting from avrdude.

          Don’t give up if you at first get a message about a problem which might be caused by the speed setting – in my experience with the old firmware you will succeed in about every third attempt at the default high SCK speed.

          • Matari

            Thank you very much for everything!!
            Because of you, it’s very easy. The hardest part was searching the correct jumper/wire diameter. In the end, I plucked several cores from stranded wires.

            I also recommend this video for beginner as eepe is very easy if you’re not familiar with avrdude cmd line,
            Just plug both end, follow the video instruction, and it’s done. No hassle at all.

          • uwezi

            Actually I normally use AVR Bunr-o-mat – even less command lining, since also the target device type is chosen from a drop-down menu.

  • d0nut

    Works perfectly, thank you for the tutorial!

  • Tahan Prahara

    Need Help…
    How to set this programmer for low SCK? I need to set the fuse bit for New Chip/IC

    What for M on the board? is this to set the mode?

  • Anon

    Thanks, I had already thrown the programmer in a corner marked as useless. It was quite a bummer when I found out that this programmer didn’t work with avrdude.

  • Jason

    Hey just found this tutorial and I was also able to reprogram mine from USBHid to USBasp. (Red light to blue light!)


  • Felix

    Thank you very much for the .hex! Works with a device labled MX-USBISP-V3.00 2012-05-20.

  • hiduino

    I found that you can reprogram these with the unmodified usbasp.atmega8.2009-02-28.hex or usbasp.atmega8.2011-05-28.hex firmware and they seem to work as far as I can tell.

    The only change is on the back of the pcb have three solder bridges that need to be removed. These look kind of like a fork shaped solder bridges. Once these are removed then it should show up in Windows as a standard USBasp device, of course with one of the images loaded.

    See my post at,149668.msg1138408.html#msg1138408
    for more details.

    • uwezi

      Actually: just modifying the source code once and then flashing the modified firmware is much faster than if I had to remove the solder bridges on all programmers for my students…

    • uwezi

      You are probably right as these bridges seem to make the connections to PORT D…


  • Andrea

    thanks a lot, I got it working last week compiling it myself.
    THe only problem I have is that while it can correctly program an atmega328P, it seems it cannot program a an atmega328 (without P). The problem is not the usual signature issue (i.e. I run avrdude with -F). [I can programm the atmega328 with ArduinoISP, so the problem is not the chip]
    I’d like to try the slow sck of aspusb, and I was wondering if you figured out where the SLOW SCK jumper should go in this “equivalent” programmer.

    • Andrea

      did you also get it working on attiny?
      I just did an out of the box test on attiny45 and doesn’t seem to work… tried different -B options…

      • uwezi

        Hej Andrea,

        I haven’t tested it on any ATtiny so far, but why should it not

        Just quickly connected an ATtiny85 to the programmer, wrote a small
        “blinky” program, flashed it with “-B 10” and it works…

        According to the verbose output of avrdude, the “-B 10” option results in an SCK frequency of 93750 Hz. I also tested with “-B 5” (187500 Hz), still works – my ATtiny runs on the internal 8 MHz oscillator at full speed.

        Is your ATtiny possibly set for the internal 128 kHz oscillator? In that case you need to use an SCK frequency below 32kHz, e.g. “-B 30” or higher.


    • uwezi

      Hej Andrea,

      I have already used it quite a lot to program ATmega16 and
      ATmega168/328 without “P”. This version of the firmware actually
      should support a software-setting of SCK rather than a jumper (I don’t
      know if it still supports the jumper at all).

      Try to use the -B option of avrdude, like “-B 10” to start with. My
      standard setting is “-B 2”:

      -B bitclock

      Specify the bit clock period for the JTAG interface or the ISP clock (JTAG ICE only). The value is a floating-point number in microseconds. The default value of the JTAG ICE results in about 1 microsecond bit clock period, suitable for target MCUs running at 4 MHz clock and above. Unlike certain parameters in the STK500, the JTAG ICE resets all its parameters to default values when the programming software signs off from the ICE, so for MCUs running at lower clock speeds, this parameter must be specified on the command-line. It can also be set in the configuration file by using the ’default_bitclock’ keyword.

  • Andrea

    nice work.
    I got the same programmer, could you post the hex file of the final firmware you flashed?


  • Yuabi

    I can’t compile the firmware, give me tutorial please.
    what the compiler are you use.?

Leave a Reply




You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>