Go Down

Topic: Can't Update The Firmware On My USBasp Atmega8 Using Arduino (Read 12510 times) previous topic - next topic

angelosanzeri

Hi everybody,
I'm writing because I'm having some problem flashing the USBasp I bought.
First of all, I have Ubuntu, so from my terminal I installed avrdude as such:

Code: [Select]
sudo apt-get install avrdude avrdude-doc binutils-avr avr-libc gcc-avr gdb-avr

Then I took my USBasp and try the JP2 pinouts to shortcircuit them and set it to self-programming mode.
Here it is my USBasp, I shortcircuited the two pins over "JP2":

USBasp front: http://i.imgur.com/ns7oEva.png
USBasp back: http://i.imgur.com/MC4AHtu.png
USBasp Atmega8A AU 1502: http://i.imgur.com/yr7Dc2k.png

Then I plugged my Arduino to my PC, uploaded the ArduinoISP sketch (File->Examples->ArduinoISP->ArduinoISP sketch), then I set my Arduino as AVRISP mkII (Tools->Programmer->AVRISP mkII) and plugged my USBasp to the Arduino board as such:

Arduino  USBasp
5v         VTG (pin 2)
GND     GND (pins 4-10)
13         SCK (pin 7)
12         MISO (pin 9)
11         MOSI (pin 1)
10         RESET (pin 5)

Here's the pic, showing the pins: http://goo.gl/VXExvO

Once I did that, I wanted to flash the ".hex" file I downloaded from here http://www.fischl.de/usbasp/ into the USBasp Atmega8.
So I opened up my terminal, I changed directory to /firmware inside the /bin directory, and wrote the following line:

Code: [Select]
sudo avrdude -c arduino -p m8 -P /dev/ttyACM0 -U flash:w:usbasp.atmega8.2011-05-28.hex

And here's the error the terminal said I came out with: http://i.imgur.com/vs9rSmN.png

I really look forward to receive some good advices to finally solve the problem because I've struggling for a very long time now.
Thanks very much for the help!

somedude

The device sig it's reporting is for the ATMEGA328P and not the ATMEGA8A.
Looks like it's trying to flash your Arduino and not the USBASP.

You should select 'Arduino as ISP' for the programmer in the IDE and not AVRISP MkII.
IIRC, in Linux, the USB port is like /dev/ttyUSB0 or something like that.
These are just comments, they may not be pertinent.

Concerning the signature issue: I'm not sure that you should set the self programming jumper (I don't have an USBASP), since you are using an external programmer to upload.

PeterVH

I think avrdude indeed talks to your arduino. My guess is, it is an uno and you did no disable autoreset, so the uno resets and avrdude communicates with the bootloader.

You do need the jumper over j2.

Note the pinout you attached is not for those blue boards: pins 4 and 6 are not ground, they are tx and rx. So pick pin 8 or 10 for ground.













angelosanzeri

I set "Arduino as ISP" and I tried both connecting JP2 or not, and it didn't work in both cases.

I connected ground to pin 10.

I checked the name of the USBport and I think the one I put in the line of code is correct, here's the terminal: http://i.imgur.com/4WkbLRZ.png

I seriously don't know what to do. What's the solution?

PeterVH

The /dev/ttyACM0 you used first, is the correct one.
Did you disable autoreset on the uno? A 10uF cap between rest and gnd will do.

angelosanzeri

No, I didn't disable the autoreset on the UNO.

Should I do it like this?

Circuit: http://i.imgur.com/P50Od9b.png

Schematic: http://i.imgur.com/WXDTRSt.png


bperrybap

You must install the self programming jumper in order to re-program the avr on the USBasp device.
This connects the reset pin of the AVR to the reset pin on the 10 pin header.
As-is without the jumper, the reset pin on the 10 pin header is connected to an AVR i/o pin so that the USBasp f/w can yank it low to program another AVR chip.

If using Arduino as ISP to program the AVR on the USBasp device you must first upload the sketch
and then use the Arduino as ISP programmer type as well as disable the Arduino auto reset.
If you don't disable the Arduino auto reset the avrdude running on the PC will be talking to the UNO bootloader rather than the arduino as ISP sketch. This will cause avrdude to see a m328 instead of the real target AVR chip.

The one tricky thing that you can run into is that the jumper labels on your USBasp board may not match the official USBasp jumper labels.
i.e. the jumper labeled as "jp2" on your USBasp may not be the self programming jumper.

I had this issue so I recommend that you use a visual inspection to follow the PCB traces for the JP2 traces to make sure that it connects to the AVR reset pin as well as the reset pin on the 10 pin header.

As long as you can verify one of those trace connections, you can know it is the correct jumper.

I modify the USBasp makefile so I can use the built in rules like "flash" to program the part.

You will also want to fix your udev entry for ISP device and your group permissions so you don't need to use sudo to talk to ports.

--- bill

angelosanzeri

I tried to trace back the path from pin 29 on my atmega 8 (http://goo.gl/Cc2gbu) and pin 10 from the header, both to JP2.

Pin 10 from the head seems to go to JP2, but there's no evidence from the pin 29 on the atmega8.

I tried to look for some schematics but my vendor doesn't provide that information so I found this, hope it'll help: http://blog.apexelectrix.com/how-to-update-usbasp-firmwares/.

My USBasp is obviously this (exact same model): http://blog.apexelectrix.com/wp-content/uploads/2013/09/IMAG0031.jpg.

Do you think I did correct when I sent those pics about Arduino UNO autorest disabling or should I do in another way?

Thanks

angelosanzeri

No, I didn't disable the autoreset on the UNO.

Should I do it like this?

Circuit: http://i.imgur.com/P50Od9b.png

Schematic: http://i.imgur.com/WXDTRSt.png


Did I do right thing with these sketches?

bperrybap

In terms of disabling auto reset. I can't help you there since I don't use ever use Arduino as an ISP as I have another ISP programmer. I used an AVR dragon to re-program my USBasp device.


Pin 10 on the 10 pin ISP header is ground that shouldn't be connected to the self-programming jumper.
Pin 5 on the 10 pin ISP header is ISP reset. That pin should be connected to to the self programming jumper.

The self programming jumper (normally labled J2) connects the AVR reset pin to the ISP header connector ISP reset pin (ISP header pin 5)

Pin 5 on the ISP header (ISP reset) also connects to an AVR i/o pin normally PB2.

In normal operation the AVR will drive PB2 i/o pin to control the ISP reset pin on the 10 pin ISP header.
In self programming operation, the ISP programmer will be driving the ISP reset pin on the 10 pin ISP header and that is why the ISP reset pin must be connected to the AVR reset pin.
That is what the self programming jumper does.

However, not all USBasp boards label their pins the same way.
For example the one I have uses the same schematic but labels the jumpers differently.
Here is the official ones compared to mine:
Jumper   Fischel               KKKusbasp
 J1    Target VCC          Slow SCK (hooks to pin 25 which is PC2 pin)
 J2    Firmware upgrade    Target VCC
 J3    slow SCK option     Firmware upgrade (hooks to ISP reset)


So mine uses J3 instead of J2.
I had to follow the traces to see which jumper was which as there as no documentation.
Also complicating matters is that a few of the USBasp boards change the i/o pins used and ship with altered firmware. With those boards, they will no longer work when upgraded with the stock firmware. You have to go in and tweak the code and rebuild the image to work with the pins they used.
Luckily there are not very many of those as most follow the stock schematic for the i/o pins.

Beyond wiring up the ISP header connector wires, you have to make sure the AVR reset pin is connected to the ISP reset pin and then ensure that if using an Arduino as your ISP programmer ensure that the it is not autoreset when avrdude runs.
If you are seeing the 328 signature the Arduino is resetting.
If you get a signature of 0's or timeout messages then then more than likely either ISP wiring is incorrect or the AVR is not being reset by the ISP reset signal.

--- bill

                                                             

angelosanzeri

#10
Nov 30, 2015, 11:10 pm Last Edit: Nov 30, 2015, 11:20 pm by angelosanzeri
I thank you for the exhaustive answer, I got what you are saying, but in order to understand if I'm doing it wrong I should disable Arduino UNO autoreset so I just want to know if these sketches ( http://i.imgur.com/P50Od9b.png, http://i.imgur.com/WXDTRSt.png) are correct in order to proceed.

I'm talking about what PeterVH said:
The /dev/ttyACM0 you used first, is the correct one.
Did you disable autoreset on the uno? A 10uF cap between rest and gnd will do.
Thanks

angelosanzeri

#11
Dec 01, 2015, 08:09 am Last Edit: Dec 01, 2015, 08:17 am by angelosanzeri
The /dev/ttyACM0 you used first, is the correct one.
Did you disable autoreset on the uno? A 10uF cap between rest and gnd will do.

No, I didn't disable the autoreset on the UNO.

Should I do it like this?

Circuit: http://i.imgur.com/P50Od9b.png

Schematic: http://i.imgur.com/WXDTRSt.png


I'm asking if I did correct just because I saw the official page on Arduino Playground and looks different:

http://playground.arduino.cc/Main/DisablingAutoResetOnSerialConnection

PeterVH

I had a look on your schematic, it looks ok to me.
I have the same blue lc technology usbasp clone, J2 is indeed the 'self' programming jumper, it should be closed.

Most people use the 10uF cap solution instead of the resistor one. I used it myself a lot. If you don't feel comfortable about the cap forcing reset high, you can also cut the RESET-EN trace. It can be cleanly closed afterwards.

john1993

I really look forward to receive some good advices to finally solve the problem because I've struggling for a very long time now.
my advices is to stop screwing with usbasp reflash.  in my experience theres never a reason to do so. at least not in windows world.  maybe linux has some fundamental defect that makes it necessary but i doubt it.

on the other hand i have seen many struggling (where did i hear that word?) with this process and often accomplish little more than brick the programmer or the target or both.

bperrybap

my advices is to stop screwing with usbasp reflash.  in my experience theres never a reason to do so. at least not in windows world.  maybe linux has some fundamental defect that makes it necessary but i doubt it.
John, I couldn't disagree more about having a reason to run the latest USBasp firmware.

Using the more recent USBasp firmware is very useful as it allows setting the ISP clock rate from avrdude. This allows setting the clock  to  a slow rate when programming and setting fuses in a virgin AVR. Without this capability you have to install a jumper to slow the clock because if the clock remains fast you will not be able to program a virgin AVR to be able to set the clock to 8Mhz or to set the fuses for a crystal.
To me it is a very useful feature to be able able to run the clock fast or slow when desired/needed and never have to mess with any jumpers on the USBasp device to do it.

The clock rate issue is not related to a particular OS.

Also there are some additional ISP features that can allow the uploads be be a bit quicker.
So all in all it is a useful update if your USBasp device is not running the latest f/w.

It isn't hard to reflash the USBasp device.
What can make it tricky or hard is when trying to use Arduino as ISP as there are many "gotch Yas" around the Arduino Auto-reset.

angelosanzeri,
The reason you are seeing different ways to "disable" auto-reset is that it varies depending on which revision of Arduino h/w you have.
The auto-reset circuit on the Arduino was a h/w solution to a s/w problem. And the auto-reset circuitry itself has issues, particularly on the pre-Uno boards.
There was an issue that depending on the signal being fed into the reset/auto-reset circuity, a high voltage spike/bounce could be generated on the AVR reset pin that could end up erasing the part or corrupting it in bad ways.
The auto-reset circuit was altered to include a protection diode and after that was done, the simple resistor that was being used to disable the auto-reset circuit wouldn't work anymore and that is why a cap is now used.
Which hack you use to disable the auto-reset depends on which version of the Arduino you have.

--- bill





Go Up