Program an Arduino using USBasp

Hey there, I got an USBasp programmer. I know that to upload sketch to arduino board , not necessary I have to use USB cable. I can also use this USBasp programmer right ? So, if I wanted to use this programmer to program my arduino atmega 328, do I need to do any modiciation ? Or I simply just plug in the 6 pins header and click File--> Upload using programmer ?

This method apply to any AVR chips? with or without bootloader in it ?

Thank you for the help

My USBasp programmer came with a 10-pin ICSP cable. You'll need a 10-pin to 6-pin adapter.

If you use a factory fresh AVR chip in your Arduino it will, by default, run at 1 MHz instead of 16 MHz. To set the fuses correctly for the 16 MHz crystal/resonator you will want to burn the bootloader:

Tools->Board->Arduino UNO (or whatever Arduino board you are programming)
Tools->Programmer->USBasp
Tools->Burn Bootloader

Then you can upload sketches with:

Tools->Board->Arduino UNO (or whatever Arduino board you are programming)
Tools->Programmer->USBasp
File->Upload Using Programmer

Yea, I have the 10 pins to 6 pins adapter. So, means every AVR chip that I want to program using arduino IDE I must burn bootloader ? Burning bootlader means that I can program my chip using arduino language and not those from AVR studio ?

Hey, help. Suddenly I cant progrram my arduino. Why ??? Please help me.

Thank you

vick5821:
Hey, help. Suddenly I cant progrram my arduino. Why ??? Please help me.

Thank you

Do you remember which direction you hooked the 6-pin cable to the ICSP? There is a pin 1 designated with a little dot on the UNO. The colored wire (Red or Black) on the ribbon will tell you which side pin 1 is on the connector.

After that, check if it will upload via programmer (Try a slow clock, if you have a jumper for it). If not, re-burn your bootloader through the Arduino IDE.

I do have the same problem,
If I upload a sketch by Uspasp from the IDE (v1.0.1), the sketchs work fine.
But I can't upload sketches anymore by the arduino ide.
I think the bootloader is over writen.
Burning a new bootloader, solves the problem.
[edit]
If you upload by extrenal programmer, you erase the flash memory, and then uploud the sketch.
(so you loose the bootloader). Is there a option to prevent that ?

teding:
I do have the same problem,
If I upload a sketch by Uspasp from the IDE (v1.0.1), the sketchs work fine.
But I can't upload sketches anymore by the arduino ide.
I think the bootloader is over writen.
Burning a new bootloader, solves the problem.
[edit]
If you upload by extrenal programmer, you erase the flash memory, and then uploud the sketch.
(so you loose the bootloader). Is there a option to prevent that ?

It sounds like you are saying: "When I burn a fresh bootloader it only works once through USB." That is a symptom of the auto-reset circuit not working. Fix the auto-reset and you should get the bootloader to work more than once.

vick5821:

Hey, help. Suddenly I cant progrram my arduino. Why ??? Please help me.

Thank you

uhen uploading the program GOTO File>Upload Using Programmer.

Very useful post, my USBasp is now running perfectly after pointers from here. Thanks

ey guys!

I am trying a USBasp that I got following the information on this post.

first:

Tools->Board->Arduino Mega
Tools->Programmer->USBasp
Tools->Burn Bootloader

It says "done burning bootloader", but also says "avrdude: warning: cannot set sck period. please check for usbasp firmware update." Arduino´s led start to blink

second, I try to upload "blink":

Tools->Board->Arduino Mega
Tools->Programmer->USBasp
File->Upload Using Programmer

It says "done uploading", and again also says "avrdude: warning: cannot set sck period. please check for usbasp firmware update." There is no blinking in the led, so the sketch is not working.

if after this I connect the arduino again via usb and try again to upload "blink" via AVRISP mkII, it gets stuck in the uploading. "avrdude: stk500v2_getsync(): timeout communicating with programmer"

if I try to burn bootloader, it says "error while trying to burn bootloader" - "avrdude: usbdev_open(): did not find any USB device "usb" Error while burning bootloader."

How can I save my board?
I saw that @johnwasser said "Fix the auto-reset and you should get the bootloader to work more than once." but I dont know what that means...

thanks!

@johnwasser
@vick5821

camilozk:
ey guys!

I am trying a USBasp that I got following the information on this post.

first:

Tools->Board->Arduino Mega
Tools->Programmer->USBasp
Tools->Burn Bootloader

It says "done burning bootloader", but also says "avrdude: warning: cannot set sck period. please check for usbasp firmware update." Arduino´s led start to blink

second, I try to upload "blink":

Tools->Board->Arduino Mega
Tools->Programmer->USBasp
File->Upload Using Programmer

It says "done uploading", and again also says "avrdude: warning: cannot set sck period. please check for usbasp firmware update." There is no blinking in the led, so the sketch is not working.

if after this I connect the arduino again via usb and try again to upload "blink" via AVRISP mkII, it gets stuck in the uploading. "avrdude: stk500v2_getsync(): timeout communicating with programmer"

if I try to burn bootloader, it says "error while trying to burn bootloader" - "avrdude: usbdev_open(): did not find any USB device "usb" Error while burning bootloader."

How can I save my board?
I saw that @johnwasser said "Fix the auto-reset and you should get the bootloader to work more than once." but I dont know what that means...

Your board is fine, everything you have described is expected.

When you upload a sketch using "upload using programmer", the bootloader is overwritten (this is a limitation imposed by Atmel - you can't erase part of the flash when programming via ISP programmer, erase is all or nothing (unlike via self programming used by the bootloader), so it takes out the bootloader too. This is a feature, it's related to how lockbits work to keep code from being extracted). Thus, after uploading blink using USBAsp, normal upload should fail.

The SCK speed warning should be ignored. There was a project to make a better USBAsp firmware, but it hasn't finished as far as I know - and the other available firmware that does support sck speed setting has problems). I've seen a number of people complain that they tried upgrading it, and it broke all sorts of stuff.

You did not attempt to program it using an AVRISP MKII. The AVRISP MKII is a physical device, like the USBAsp, only more expensive, it does the same thing.
When you upload normally (by clicking the upload button), the Tools -> Programmer selection is ignored for boards that have a bootloader.

When you attempted to burn bootloader with the other programmer selected, you correctly received an error, since you did not have an AVRISP MKII connected to your computer.

camilozk:
ey guys!

I am trying a USBasp that I got following the information on this post.

first:

Tools->Board->Arduino Mega
Tools->Programmer->USBasp
Tools->Burn Bootloader

It says "done burning bootloader", but also says "avrdude: warning: cannot set sck period. please check for usbasp firmware update." Arduino´s led start to blink

second, I try to upload "blink":

Tools->Board->Arduino Mega
Tools->Programmer->USBasp
File->Upload Using Programmer

It says "done uploading", and again also says "avrdude: warning: cannot set sck period. please check for usbasp firmware update." There is no blinking in the led, so the sketch is not working.

if after this I connect the arduino again via usb and try again to upload "blink" via AVRISP mkII, it gets stuck in the uploading. "avrdude: stk500v2_getsync(): timeout communicating with programmer"

if I try to burn bootloader, it says "error while trying to burn bootloader" - "avrdude: usbdev_open(): did not find any USB device "usb" Error while burning bootloader."

How can I save my board?
I saw that @johnwasser said "Fix the auto-reset and you should get the bootloader to work more than once." but I dont know what that means...

Your board is fine, everything you have described is expected.

When you upload a sketch using "upload using programmer", the bootloader is overwritten (this is a limitation imposed by Atmel - you can't erase part of the flash when programming via ISP programmer, erase is all or nothing (unlike via self programming used by the bootloader), so it takes out the bootloader too. This is a feature, it's related to how lockbits work to keep code from being extracted). Thus, after uploading blink using USBAsp, normal upload should fail.

The SCK speed warning should be ignored. There was a project to make a better USBAsp firmware, but it hasn't finished as far as I know - and the other available firmware that does support sck speed setting has problems). I've seen a number of people complain that they tried upgrading it, and it broke all sorts of stuff.

You did not attempt to program it using an AVRISP MKII. The AVRISP MKII is a physical device, like the USBAsp, only more expensive, it does the same thing.
When you upload normally (by clicking the upload button), the Tools -> Programmer selection is ignored for boards that have a bootloader.

When you attempted to burn bootloader with the other programmer selected, you correctly received an error, since you did not have an AVRISP MKII connected to your computer.

To "save" your board, just burn bootloader with USBAsp like you did here, and don't upload a sketch using the USBAsp.

thank you very much for your very precise explanation DrAzzy! very helpful!

just one more note; I saw @ http://www.arduino.cc/en/Hacking/Bootloader?from=Tutorial.Bootloader that the board "must be powered by an external power supply or the USB port." I was also missing that part...

I still cannot upload sketch with the USBasp. After checking that upload via arduino IDE is working normally and that I can restore the bootloader with USBasp, I attempt to upload "blink" via USBasp. What I get still is "done uploading" but no blinking, plus the warning "
avrdude: warning: cannot set sck period. please check for usbasp firmware update."

camilozk:
board "must be powered by an external power supply or the USB port." I was also missing that part...

Shouldn't be necessary with USBasp, it will power the board. That is necessary for the AVRISP MkII programmer though.

camilozk:
I still cannot upload sketch with the USBasp. After checking that upload via arduino IDE is working normally and that I can restore the bootloader with USBasp, I attempt to upload "blink" via USBasp. What I get still is "done uploading" but no blinking

That's a known issue Program doesn't run after Upload Using Programmer with USBasp (Mega2560) · Issue #246 · arduino/ArduinoCore-avr · GitHub. So you would either need to change the line in boards.txt:

mega.menu.cpu.atmega2560.bootloader.high_fuses=0xD8

to

mega.menu.cpu.atmega2560.bootloader.high_fuses=0xD9

However you would need to change it back to D8 if you want to Burn Bootloader. I have had a strange thing happen occasionally after messing with this setting where I get a double bootloader blink on my Mega 2560 that remains even after reburning the bootloader but doesn't appear to cause any problems.

You could also fix this problem(and the avrdude warning) by updating your USBasp firmware to a new, unofficial version but this is a more advanced process and you risk making your programmer unusable. Many of the USBasps come with a locked firmware which prevents you from being able to go back to the original firmware which is better than the standard firmware that is freely available. I would recommend only attempting this if you have a spare USBasp that you will keep the original firmware on in case you have problems with the update. I am using this firmware and have found that it solves your problem and works fine. The instructions are here: USBasp Update Warning - Microcontrollers - Arduino Forum

thanks pert

I tried the first option (mega.menu.cpu.atmega2560.bootloader.high_fuses=0xD8 to mega.menu.cpu.atmega2560.bootloader.high_fuses=0xD9) and it didnt do the job.

the second option looks very complicated so I am not going for it right now... I will study it with time and consider it.

thank you very much for sharing your experience!

That's unfortunate it didn't work but with the ATmega2560 there's not much reason not to just use the bootloader for uploading since it has so much flash memory. Remember to change the high_fuses setting back to the original value. Other than this issue, which doesn't occur with other Arduino boards like the Uno, the USBasp is the best programmer so it's great that they were able to fix the problem in the new firmware.

camilozk:
I tried the first option (mega.menu.cpu.atmega2560.bootloader.high_fuses=0xD8 to mega.menu.cpu.atmega2560.bootloader.high_fuses=0xD9) and it didnt do the job.

I realized I didn't mention you need to Tools > Burn Bootloader after making this change to actually set the new fuse setting on the ATmega2560. The reason for this is that Upload using programmer doesn't set fuses so even though you are just going to erase the bootloader you just burned you still need to Burn Bootloader after making any changes to the fuse settings.