Jonathan Thomson's web journal

Project Ouroboros — Reflashing a betemcu USBasp Programmer August 18, 2011

Filed under: Electronics — jethomson @ 11:40 pm

*** Major update of article and code in 2019 ***

 

Introduction
USBasp is a free, open source firmware and reference design for implementing a USB AVR programmer. It uses simple circuitry and an ATmega8 or ATmega*8 for interfacing with the USB host. A variety of inexpensive boards (~$1.50 US in 2019) based on the USBasp project can be purchased from aliexpress and eBay. Re-programming one of these boards can often be an effective solution for a one-off project where the cost of a full development board or the time consumed designing and assembling a custom board is prohibitive. They can even be made to work with Arduino. This article focuses on the betemcu.cn board pictured here. Note that there are at least two versions of this board.

 

Terminology
V-USB — a firmware-only implementation of a low-speed USB device for Atmel AVR microcontrollers.
in-circuit programmer — a device for burning code and changing fuse settings on a microcontroller which remains in its application circuit.
USBasp – a USB in-circuit programmer for Atmel AVR microcontrollers that utilizes V-USB.
bootloader — a bit of firmware capable of burning code onto the same microcontroller on which it resides. A bootloader allows new code to be uploaded to a microcontroller without an external programmer.
USBaspLoader – a USB bootloader that follows the USBasp protocol.

It’s possible to erase the USBasp firmware and load a new program onto the betemcu.cn board via the 10 pin header. First insert a jumper wire into J2 (the two holes circled in yellow in the picture above). Doing this connects RST on the 10 pin header to PC6 (RESET). Now you can use a second programmer to burn the code. However if you put USBaspLoader onto the betemcu.cn board you can use AVRDUDE or Arduino to upload programs directly over USB without having to use an external programmer. Once you have the USBaspLoader on the board there is still enough room left to re-upload the USBasp firmware so that the betemcu.cn board can function as an external programmer again. I call this Project Ouroboros because it’s a play on the word asp and the seeming recursiveness of using USBaspLoader to put USBasp onto a USBasp programmer.

 

Getting started
First you’ll need a betemcu.cn USBasp programmer (hereafter betemcu board) and a second, external programmer (hereafter primary programmer) capable of programming AVR microcontrollers over SPI. Next you should test out your betemcu board to make sure it’s not defective. Before you load new code onto your betemcu board you should use the primary programmer and AVRDUDE to attempt to save the betemcu board’s factory installed firmware to your computer and discover its original fuse settings. Doing this will allow you test whether the device is still functional by attempting to restore it to a known good state by writing back the original firmware and fuse settings. The following command will try to save the betemcu board’s firmware and display its fuse settings. The -c programmer-id option is the ID of the primary programmer. If the betemcu board’s lock bits are programmed to prevent reading off the firmware then factory_firmware.hex will be filled with junk data. There are a variety of these USBasp programmers created by different groups, and not all of them lock the boards so it’s worth trying to save the factory firmware.


avrdude -p atmega8 -c programmer-id -v -U flash:r:factory_firmware.hex:i


factory_firmware.hex junk data:
:2000000000000101020203030404050506060707080809090A0A0B0B0C0C0D0D0E0E0F0FF0
:2000200010101111121213131414151516161717181819191A1A1B1B1C1C1D1D1E1E1F1FD0
:2000400020202121222223232424252526262727282829292A2A2B2B2C2C2D2D2E2E2F2FB0
:2000600030303131323233333434353536363737383839393A3A3B3B3C3C3D3D3E3E3F3F90
:2000800040404141424243434444454546464747484849494A4A4B4B4C4C4D4D4E4E4F4F70
:2000A00050505151525253535454555556565757585859595A5A5B5B5C5C5D5D5E5E5F5F50
:2000C00060606161626263636464656566666767686869696A6A6B6B6C6C6D6D6E6E6F6F30
:2000E00070707171727273737474757576767777787879797A7A7B7B7C7C7D7D7E7E7F7F10
:2001000080808181828283838484858586868787888889898A8A8B8B8C8C8D8D8E8E8F8FEF
:2001200090909191929293939494959596969797989899999A9A9B9B9C9C9D9D9E9E9F9FCF
:20014000A0A0A1A1A2A2A3A3A4A4A5A5A6A6A7A7A8A8A9A9AAAAABABACACADADAEAEAFAFAF
:20016000B0B0B1B1B2B2B3B3B4B4B5B5B6B6B7B7B8B8B9B9BABABBBBBCBCBDBDBEBEBFBF8F
:20018000C0C0C1C1C2C2C3C3C4C4C5C5C6C6C7C7C8C8C9C9CACACBCBCCCCCDCDCECECFCF6F
:2001A000D0D0D1D1D2D2D3D3D4D4D5D5D6D6D7D7D8D8D9D9DADADBDBDCDCDDDDDEDEDFDF4F
:2001C000E0E0E1E1E2E2E3E3E4E4E5E5E6E6E7E7E8E8E9E9EAEAEBEBECECEDEDEEEEEFEF2F
:2001E000F0F0F1F1F2F2F3F3F4F4F5F5F6F6F7F7F8F8F9F9FAFAFBFBFCFCFDFDFEFEFFFF0F
...

 

Fuse settings for burning code to the betemcu board with an external programmer
If you are unfamiliar with microcontroller configuration fuses, then please visit the relevant articles in the Links section to learn more about them. You should also use a fuse calculator to double check fuse settings before applying them. The original settings for my betemcu board were hfuse = 0xD9 and lfuse = 0xFF but these leave CKOPT unprogrammed which should be set for crystals faster than 8 MHz. The makefile for USBasp uses hfuse = 0xC9 and lfuse = 0xEF but these settings didn’t work for me because the start-up delay isn’t long enough, in fact they (recoverably) bricked the betemcu board. Setting the fuses to hfuse = 0xC1 and lfuse = 0xBF sets a proper start-up delay and enables CKOPT. These also set a brown-out detection level of 2.7 V which is necessary if you want to use the onboard 3.3 V regulator for power. From here on I use a fuse setting that sets the brown-out detection level appropriate for a 3.3V board, if your board is 5V this fuse setting won’t hurt your board, but it won’t properly detect a brown-out condition.


high fuse: 0xC1
low fuse: 0xBF (3.3V board)
low fuse: 0x3F (5V board)


avrdude -p atmega8 -c programmer-id -U hfuse:w:0xC1:m -U lfuse:w:0xBF:m
avrdude -p atmega8 -c programmer-id -v -U flash:w:betemcu_blink.hex

 

To restore the original factory firmware (make sure factory_firmware.hex isn’t junk data!):

avrdude -p atmega8 -c programmer-id -v -U flash:w:factory_firmware.hex

 

If you don’t have the original factory firmware you can substitute it with a precompiled hex from the Fischl USBasp package, although it will not be exactly the same as the original firmware (see the Nota Bene section below):

avrdude -p atmega8 -c programmer-id -v -U flash:w:usbasp.atmega8.2011-05-28.hex

 

Hardware modifications required to run vanilla USBaspLoader on the betemcu board
The unmodified version of USBaspLoader connects PD2 and PD4 to the USB data plus and data minus lines. However the betemcu board connects PB1 and PD2 to USB data plus and PB0 to USB data minus. Therefore the USBaspLoader code needs to be changed to use the same pins. Here’s a snippet of bootloaderconfig.h with the changes already made.


#define USB_CFG_IOPORTNAME B
/* This is the port where the USB bus is connected. When you configure it to
* "B", the registers PORTB, PINB and DDRB will be used.
*/
#define USB_CFG_DMINUS_BIT 0
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
* This may be any bit in the port.
*/
#define USB_CFG_DPLUS_BIT 1
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
* This may be any bit in the port. Please note that D+ must also be connected
* to interrupt pin INT0!
*/

Vanilla USBaspLoader is set up so that it will only enter self-programming mode (i.e. listen for a program being uploaded and write it to the flash) if PD7 is held low after pulling the reset pin low (i.e. an external reset) occurs. Therefore you will have to make a couple of modifications to the betemcu board. First you’ll want to add a normally open pushbutton connected to the reset pin and ground for producing an external reset. Soldering the pushbutton connection at the reset pin’s pull-up resistor is easier than soldering it directly to the pin.

 

For the second modification you’ll have to determine how you want to signal the bootloader to wait for a program. The typical method is to use a jumper to connect PD7 to ground. The NC (not connected) pin of the 10 pin header is conveniently located 0.1″ from one of the header’s ground pins so running a mod wire from PD7 to NC is a simple way to add a jumper header. However, if you plan on interfacing the betemcu board with another circuit through the 10 pin header by using a 10 pin IDC you will want to add the jumper header somewhere else on the board because of the difficulty of inserting and removing the 10 pin IDC while the USB connector is plugged in. Using a pushbutton connected to PD7 and ground instead of a jumper is also an option, but you’ll have to keep the pushbutton pressed until AVRDUDE has finished.

Here’s a picture of my modified board. At first I was using a jumper to connect PC2 (orange wire to NC) to ground, but later I decided to add a second pushbutton to signal the bootloader to wait for a program to be uploaded. The brown and blue wires are for I2C and not a necessary modification.

 

The pin used to signal the bootloader can be easily changed by modifying bootloaderconfig.h. If you want to use a different pin make certain it’s not already being used for another function by consulting USBasp schematic and by carefully examining the betemcu board. Keep in mind that pins at the corners of the ATmega8’s package are easier to solder to.

Compiling a new hex file from the USBaspLoader source also requires a few changes to the Makefile. I’ve created a package of the vanilla version of USBaspLoader preconfigured to work with the betemcu board. I’ve also included a pre-compiled hex in case you have difficulty compiling. You can download these files from the GitHub repo at the end of this article.

 

Alternate version of USBaspLoader
I wasn’t happy with using a jumper (or pressing and holding a pushbutton) to signal the bootloader to enter self-programming mode (SPM). So I’ve made some changes to the vanilla version and packaged them as an alternate version of USBaspLoader. ***I added an option that compiles the bootloader so that it always enters SPM after every power cycle or reset and uses a timeout to exit the bootloader, which makes hardware modifications to the board unnecessary.*** The alternate version can also be configured so that you can enter self-programming mode by pressing and releasing a pushbutton, which is a more typical method used by other USB development boards with microcontrollers that have a HWB pin. I made a few more modifications to the code to utilize the betemcu board’s LEDs. Here’s a sample of some of the changes I made (look at bootloaderconfig.h and main.c to view all the changes):


#define TIMEOUT_ENABLED 1
/* If TIMEOUT_ENABLED is defined to 1 then the bootloader will always load
* and stay active until the programmer closes the connection or the time
* out period has elapsed. Since the bootloader always loads there is no
* need for a jumper on the bootLoaderCondition() pin. Costs ~108 bytes.
*/
#define TIMEOUT_DURATION 5
/* The number of seconds the bootloader waits before exiting if no activity
* has occurred during the timeout interval. If TIMEOUT_ENABLED is defined
* to 0 this define will be ignored. Maximum value is 255 seconds.
*/
#define POWER_ON_RESET_LOAD 1
/* If POWER_ON_RESET_LOAD is defined as 1, then the bootloader will load
* when an external reset or a power on reset is detected. When this option
* is paired with TIMEOUT_ENABLED defined as 1 then zero hardware
* modifications to the board are required. If POWER_ON_RESET_LOAD is defined
* as 0 then the bootloader only loads if an external reset is detected, but
* this requires adding a reset button to the board. Costs ~6 bytes.
*/
#define USING_PUSHBUTTON 1
/* If USING_PUSHBUTTON is defined to 1, then a press and release of a
* pushbutton on the bootLoaderCondition() pin can be used to signal that
* you wish to enter the bootloader. If USING_PUSHBUTTON is defined to 0,
* then you must use a jumper or the pushbutton must be pressed and held
* for the duration of the programming (failing to do so will result in
* the bootloader exiting prematurely).
*/

 

If you’d like to add a reset button without making a modification to the board, you can easily do so by soldering a pushbutton to a female header. To use it put the female headers onto the RST and GND header pins and insert a jumper wire in J2.

 

Fuse settings for burning USBaspLoader to the betemcu board with an external programmer
The USBaspLoader hex file for an ATmega8 at 12 MHz is around 1900 bytes so the 2 kB (1024 words) bootloader section is required. These fuses set a boot flash section size of 1024 words (2048 bytes) and a start-up delay of 64 ms.


high fuse: 0xC0
low fuse: 0xBF (3.3V board)
low fuse: 0x3F (5V board)


avrdude -p atmega8 -c programmer-id -U hfuse:w:0xC0:m -U lfuse:w:0xBF:m
avrdude -p atmega8 -c programmer-id -v -U flash:w:alternate_USBaspLoader_2019-02-18_mega8_12MHz_betemcu_pushbutton.hex

 

If you don’t want to add a SPM jumper or button, you can use the timeout bootloader.

avrdude -p atmega8 -c programmer-id -U hfuse:w:0xC0:m -U lfuse:w:0xBF:m
avrdude -p atmega8 -c programmer-id -v -U flash:w:alternate_USBaspLoader_2019-02-18_mega8_12MHz_betemcu_timeout.hex

 

Flashing a program with USBaspLoader
Now that you have the alternate USBaspLoader on your betemcu board you can flash new programs to it directly over USB. To instruct your board to enter self-programming mode, start by pressing and holding the program button, next press and release the reset button, then release the program button. The green LED should turn on indicating the board is ready for a program upload. The bootloader doesn’t run when the board is powered on; it needs a reset to run. Upload vusb_mouse_example.hex found in my GitHub repo by using the following command. If the upload is successful you should see the mouse cursor move in a circle.


avrdude -p atmega8 -c usbasp -v -U flash:w:vusb_mouse_example.hex

 

You can also upload the original USBasp firmware onto the board to through the bootloader to restore its ability to program other AVR microcontrollers.

 

Arduino
With USBaspLoader on the board it is now compatible with the Arduino programming environment. You must add some entries to boards.txt to be able to upload a sketch within the Arduino IDE. Follow this link for an explanation of the variables used in boards.txt. Put the following at the top of boards.txt:


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

usbasploader_board.name=USBaspLoader w/ ATmega8 at 12MHz

usbasploader_board.vid.0=0x16c0
usbasploader_board.pid.0=0x05dc

usbasploader_board.upload.tool=avrdude
usbasploader_board.upload.protocol=usbasp

usbasploader_board.bootloader.tool=avrdude
usbasploader_board.bootloader.unlock_bits=0x3F
usbasploader_board.bootloader.lock_bits=0x0F

usbasploader_board.build.f_cpu=12000000L
usbasploader_board.build.board=AVR_USBASPLOADER_BOARD
usbasploader_board.build.core=arduino
usbasploader_board.build.variant=standard

usbasploader_board.menu.cpu.atmega8=ATmega8

usbasploader_board.menu.cpu.atmega8.upload.maximum_size=6144
#usbasploader_board.menu.cpu.atmega8.upload.maximum_data_size=
usbasploader_board.menu.cpu.atmega8.upload.speed=115200
usbasploader_board.upload.disable_flushing=true

usbasploader_board.menu.cpu.atmega8.bootloader.low_fuses=0xBF
usbasploader_board.menu.cpu.atmega8.bootloader.high_fuses=0xC0
usbasploader_board.menu.cpu.atmega8.bootloader.extended_fuses=0
#usbasploader_board.menu.cpu.atmega8.bootloader.file=

usbasploader_board.menu.cpu.atmega8.build.mcu=atmega8

 

Then under Tools->Board select "USBaspLoader w/ ATmega8 at 12MHz". It is normal to get this message: "avrdude: warning: cannot set sck period. please check for usbasp firmware update." Note that you’ll need to connect a USB to serial adapter to RX and TX if you want to send data over the UART (i.e. Serial.print()). Also note that the ATmega8 is missing some of the features the ATmega*8 series of chips have. For example, the ATmega8 doesn’t have PWM capability on Timer0. Therefore, this board won’t work with some Arduino sketches.

You may also need to a pins_arduino.h to your Arduino files for it to work with your board properly. The file tinyusbboard-betemcu/pins_arduino.h found in this file archive might be useful to you, but I haven’t tried it out.

 

You can also upload the sketch from the command line with the following command. Notice that you don’t need to set any fuses, in fact the bootloader is incapable of changing fuses.


avrdude -p atmega8 -c usbasp -v -U flash:w:betemcu_blink.ino.hex

 

Summary of Methods to Enter Programming Mode
External programmer: connect the holes of J2 together for the duration of the program upload.
Vanilla USBaspLoader: connect PD7 to ground, bring the reset pin low, upload program, disconnect PD7 from ground.
Alternate USBaspLoader: 1) cycle the power or bring the reset pin low then upload program before bootloader times out. 2) press and hold PD7 pushbutton, reset, release PD7 pushbutton, upload program

 

Nota Bene
A note on the error message: “avrdude: warning: cannot set sck period. please check for usbasp firmware update.”
If you are using a hardware USBasp programmer and you receive that error message then it indicates you are using an older version of the USBasp firmware that can’t automatically set the sck period. This doesn’t necessarily mean you should overwrite the firmware that came with your board with the newest version of USBasp. Since the firmwares on these boards are customized by the board makers some users have found that overwriting the original firmware resulted in a board that lost some of its capabilities. Follow this link for a discussion on this topic. As a result of that discussion some updated firmwares were created that address some of the flaws in the official Fischl USBasp firmware

If you are using USBaspLoader then you should ignore that error message since a bootloader is incapable of setting the sck period; indeed, it doesn’t make sense for it to even try to.

 

Code
Project Ouroboros on GitHub

 

Links
AVR Fuses HOWTO Guide
LadyAda’s AVR Tutorial — Fuses
A very helpful fuse calculator
I used the original USBaspLoader code, but here is a fork that might be useful to you

 

57 Responses to “Project Ouroboros — Reflashing a betemcu USBasp Programmer”

  1. […] a betemcu USBasp Programmer – [Link] Tags: Arduino, USB, USBasp, USBaspLoader Filed in Mcu | 1 views No Comments […]

  2. […] build he’s been working on that turns an inexpensive AVR programmer into a development board. The build is based on the very affordable USBasp programmer that’s based on an ATmega8. With hundreds […]

  3. Alessandro Ancillotti Says:

    So basically you need two of these things so with one you can re-program the other?

    • jethomson Says:

      Yes, you need a second programmer to re-flash the USBasp programmer. I’ve used a buspirate and a second USBasp programmer to do that. However, once you have USBaspLoader on the board you can put new programs (including the USBasp firmware) on it directly over USB without a second programmer. So you could just borrow the second programmer temporarily; however I like to have two: one for 3.3V and one for 5V.

  4. Did I understand it correctly that neither pin nor pushbutton is needed with this one? Except, I assume, for the first flashing since its still running the factiry firmware then?

  5. peter Says:

    Hello!

    Great work, but links to firmwares are not working (as well as other links on this page).

    Can you do something about this, please? 🙂

    Best regards,
    peter

  6. Karl Says:

    Jonathan,

    really nice work!
    I’m also playing with this cheap USBASP (and others) – I like to (ab)use stuff for other purposes than originally designed.

    I’d like to have a look at your files as well, but the links/server doesn’t work (again).

    BTW: another nice thing to (ab)use is this: http://www.jyetech.com/Products/CapMeter/e060.php
    Uses ATmega48 (so all *8 fit on the Board) and it sells as a Kit around $10

    Rgds
    – Karl

  7. beastmaster Says:

    I’m running avrdude-5.11-Patch7610-win32 with a DASA serial programmer (from adafruit) on a Windows 7 machine. I had to make a couple of minor changes to the commands to get things going.

    backup flash. intel hex format (:i at the end) otherwise it fails writing the file:
    avrdude -p atmega8 -c dasa -P com1 -v -U flash:r:betemcu_factory_firmware.hex:i

    set fuses (high 0xC9, low 0xFF). have to -F (force), otherwise fails:
    avrdude -p atmega8 -c dasa -P com1 -F -U hfuse:w:0xC9:m -U lfuse:w:0xFF:m

    it looks like the links you have to your hex files are broken. any chance you could check on this?

    • jethomson Says:

      Well for me, avrdude auto-detects the file format, but it is probably best to be explicit and add the :i. Avrdude also automatically finds what port the programmer is on sometimes. Honestly, I’m not even sure what to put as the port for a usbasp programmer; avrdude just finds it. I think you might be having to use -F option because you have the lock bits set. I’m sorry the hex file links are down. They are hosted on a site owned by my friend. I can’t bring them back up right now. I think I’m just going to move everything to github.

      • jethomson Says:

        I just mirrored each of the files.

      • beastmaster Says:

        Thanks for the mirror.

        As it turns out, I was getting all sorts of verification errors trying to program the betemcu board with my DASA programmer in Windows 7. I’m getting better results using Ubuntu and running avrdude commands through the terminal. Go figure.

    • Slack Says:

      I was having this same problem with writing the file using avrdude version 5.11-Patch#7610 under Win 7 & XP Using the “:i” solved my issue also.

  8. mrx23dot Says:

    I don’t understand how can this programmer use its HW SPI if I
    connect Mega8’s MOSI to target’s MOSI? both pins are for transmitting.

    A valid connection would be:
    MOSI – MISO
    MISO – MOSI
    SCK – SCK

    Anyone noticed this?

    • jethomson Says:

      You should read more about SPI. SPI uses a master/slave mode of communication. The Master Output pin connects to the Slave Input pin. So you connect MOSI to MOSI. As a side note, if I recall correctly, the programmer’s SS pin is connected to the header pin that has the silkscreen label RESET. Jumpering J2 connects the programmer’s actual reset pin to the pin labelled RESET allowing it to become a slave.

  9. cptJackH Says:

    Can anyone share original betemcu factory firmware? Thanks in advance!

  10. mrx23dot Says:

    Do you also get this error while trying to program anything with Khazama (using this ebay programmer)?
    Error setting USBasp ISP Clock… it’s very annoying. How can I get rid of this?
    I can program with it, but still..

    Thanks,

  11. segu Says:

    When you say ARDUINO IDE is it valid for the new ARDUINO 1.0 IDE? if I do the same modifications it will work with the arduino 1.0 version?
    Thank you

  12. mrx23dot Says:

    Is there an STK500 firmware adaption for the USBASP?

    This would be compatible with AVRstudio, and it requires only COM (virtual COM), so software USB could be used.

    One implementation with M8 & FT232:
    AvrUsb500v2
    http://tuxgraphics.org/electronics/200705/article07052.shtml

    • jethomson Says:

      I think AVR-Doper might be what you are looking for. The webpage says “AVR-Doper is an STK500 compatible In-System Programmer” and “Firmware can be compiled to run on metaboard hardware and USBasp hardware.” I’ve never tried it though. Please report back with your results.

      http://www.obdev.at/products/vusb/avrdoper.html

      • ajd4096 Says:

        I can confirm the usbasp runs AVR-Doper just fine; and the HID mode works without needing any driver on windows. (Yay!)

        To use an AVR-Doper from the IDE you need the following patch:

        diff –git a/app/src/processing/app/debug/AvrdudeUploader.java b/app/src/processing/app/debug/AvrdudeUploader.java
        index 408a9a6..98129e0 100755
        — a/app/src/processing/app/debug/AvrdudeUploader.java
        +++ b/app/src/processing/app/debug/AvrdudeUploader.java
        @@ -114,6 +114,8 @@ public class AvrdudeUploader extends Uploader {
        if (programmerPreferences.get(“speed”) != null) {
        params.add(“-b” + Integer.parseInt(programmerPreferences.get(“speed”)));
        }
        + } else if (“avrdoper”.equals(programmerPreferences.get(“communication”))) {
        + params.add(“-Pavrdoper”);
        }
        // XXX: add support for specifying the port address for parallel
        // programmers, although avrdude has a default that works in most cases.
        diff –git a/hardware/arduino/programmers.txt b/hardware/arduino/programmers.txt
        index c34b88c..f2bdba3 100644
        — a/hardware/arduino/programmers.txt
        +++ b/hardware/arduino/programmers.txt
        @@ -24,3 +24,8 @@ arduinoisp.name=Arduino as ISP
        arduinoisp.communication=serial
        arduinoisp.protocol=stk500v1
        arduinoisp.speed=19200
        +
        +# AVR-Doper using HID
        +avrdoper.name=AVR-Doper
        +avrdoper.communication=avrdoper
        +avrdoper.protocol=stk500v2

  13. mrx23dot Says:

    I have flashed “alternate_USBaspLoader_betemcu_timeout.hex” with the correct fuses.
    But the bootloader only starts after I reset the MCU (with rst pin). I doesn’t start automatically after I connect to the USB port, is this normal?
    Thanks,

    • Ggaljoen Says:

      Hello Wagner,
      Mine does the same as yours, only after contecting RST and GND (harware reset) the bootloader gets activated.
      Can you share what other bootloader is working?
      Thanks, Ggaljoen

      • Slack Says:

        Ggaljoen,

        I was having the same problem. I was expecting to go into bootloader mode immediately after plugging it in and then timeout and execute whatever was in flash. I could not get my betemcu recognized until I saw your post. Thanks!

        I was able to load (via programmer) several of the exampled and get them working, but could not get my Win 7 & XP machines to recognize the betemcu as an USBASP. I also tried loading my original firmware and could not get that to work. Though, I never tried it in the first place. I was so excited to try the new bootloader, that I immediately copied the flash and attempted to load the new bootloader.

    • jethomson Says:

      That was the normal behavior for the old alternate version, but I updated it in 2019 to start the bootloader after a reset or a power cycle.

  14. cptJackH Says:

    Ok, I’ve got another one from eBay and I’ve found that that Chinese firmware locked using fuse bits lb1 and lb2. So when I thought I’ve made a backup – it was a garbage. So be aware of that.

  15. Wagne Says:

    Oh, forgot to ask for some good soul to email me the original betemcu.cn miniprog firmware, since I erase it from this unit, and the other two seems to be locked. I like the idea to have an automatic clock speed that increase speed according to performance. Thanks. registroATustrDOTnet

  16. Rich Says:

    I purchased one of the betemcu.cn programmers on ebay., The unit looks like the one pictured here. The seller directed me to ” http://www.fischl.de” for documentation. My issue is the schematic on the fischi.de site does not match this device. Does anyone have a schematic for the betmcu.cn programmer.??

  17. Slack Says:

    Thanks works great. I am going to assume that since my “backup” of the firmware didn’t work, that the lock bits must have been set.

  18. Slack Says:

    Thanks jethomson for a great writeup. Also thanks Ggaljoen and WMLex for providing answers that solved issues that I was having.

    BTW, I programmed my betemcu using the following:

    Bus Pirate, 6.1 firmware (Sparkfun version of BP)
    avrdude, 5.11-Patch#7610
    Win 7 & XP

  19. […] article explains about the USBASP, which is totally free as well as open source. It is also a reference design that was used to […]

  20. gerardwr Says:

    I used this procedure to reflash my LCSOFT STUDIO V2.0 programmer. The BLINK program worked fine! THANKS!

  21. Alan69 Says:

    Just a note, at the beginning of the article I’d mention anyone buying a new programmer off Ebay etc should get the LCSoft type instead. Largely the same, probably won’t have the R8 r-pack problem some betemcu ones have, and most important for using this way, have Tx/Rx on pins 4 and 6 instead of all to ground. Easy enough to change these too, just get a little more utility out of the LCSoft without having to rewire the extra if you’re ordering fresh programmers.

  22. Maikel Says:

    I just received my betemcu-board as a replacement for my broken programmer. Since I got some errors when trying to use it, I Googled a bit and found this article. It sounds nice to be able to update the firmware directly without the use of a second programmer. It’s just a bit unclear to me which modifications are needed to do so? Do I need to solder multiple wires? I’m not very keen on soldering to the SMD microcontroller.

    And with a second programmer, no soldering is needed at all?

  23. Alan69 Says:

    Maikel, the buttons etc are for signalling the bootloader. It originally comes with USBASP only on the chip, you have to have some other programmer at least once, to get the bootloader onto the chip that first time. Then you don’t need another programmer. You have to have at least some kind of programmer once.

    Google search “avr programmer parallel port” and click images, notice some are only 4 resistors on the parallel port. Short J2 on this programmer, hook up that simple programmer to this one through the ISP port and program the bootloader with it. Then undo J2 and you have the bootloader on this programmer. Probably easiest to just use an older PC with parallel port and older windows to do the parallel port programming..

  24. marcel nijssen Says:

    Hello i have a problem , when i want to comp. he says such directory do not exists , hardware/arduino/cores/arduino/arduino.h.

    for boards i use usbasploader
    programmer : usbasploader

    what i am doing wrong here

    regards marcel nijssen

  25. […] reworked the code and the article for Project Ouroboros. You can see the update by clicking here. When I originally wrote the article in 2011 a USBasp programmer was around $6 on eBay, but now you […]


Leave a reply to USBasp Programmer | HACKOLOG - Amazing Hacks and Mods Cancel reply