Using USBasp as an Arduino Board

The title is pretty self-explanatory, but I had trouble doing this. Since I really like the small form-factor of the USBasp, I would like to use it as an Arduino Board with an ATMega8. The main problem is that when I plug it in it doesn't show up as a serial port so I cannot program it with the Arduino IDE.

I am using macos Mojave 10.14.1 with Arduino IDE 1.8.7. Is there anyway I can get around to "program the programmer" ?

A USBasp isn't a board but a programmer :wink: The ATmega8 is the "replacement" of the board. And a programmer isn't used as a board / serial.

Google "usbasp driver" :wink:

I am aware that USBasp is a "programmer" to program other chips, but I want to use it at as a standalone development board.

No, it's not a "programmer", it is a programmer :slight_smile: The standalone part is the ATmega. You can combine it to develop a program but it will not be the same as any Arduino board. That's because a USBasp programs the chip ISP, not via serial as normal ATmega board.

But if you want to use the USPasp:

  • Install the driver
  • Upload programs using "Upload Using Programmer" (after selecting the right programmer)

So basically for example I cannot write and upload a blink LED program which blink the led ON the USBasp device ? I cannot use it as I would use any Arduino Board ? I had thought I could somehow burn the Arduino bootloader into the ATMega8 chip on the USBasp board ?

Ahh, reprogram the uC of the USPasp. Mm, might be possible. Although I don't know a bootloader with USB on the ATmega8. And it doesn't give you much pins to use.

Grab Minicore. GitHub - MCUdude/MiniCore: Arduino hardware package for ATmega8, ATmega48, ATmega88, ATmega168, ATmega328 and ATmega328PB
Put a short on JP2 (SelfProgramming pins).

Select Board: Atmega8
Clock: "12 MHz external"
Bootloader: No

Programmer: Usbasp ## or the Programmer of your choice

Burn Bootloader.

Pull up a blink sketch and change to Pins 14 and 15 and flash the Leds anyway you want.

Upload using Programmer and it should work.

Look a little closer at the USBasp Schematic, and if you wanted to go to the effort, you could put the bootloader on the Atmega8 and connect a USB to TTL device on the atmega8's 10 pin connector using T & R .

Ahh, wasn't aware of Minicore being able to to that. :slight_smile:

Sorry! I was thrown off into thinking a separate ATmega and the USBasp :confused:

kprims essentially posted the same info while I was writing this, but mine is slightly different so I'll post it anyway:

mlg556:
I cannot use it as I would use any Arduino Board ? I had thought I could somehow burn the Arduino bootloader into the ATMega8 chip on the USBasp board ?

Here's how to do it:

  • Install MiniCore, following these instructions: GitHub - MCUdude/MiniCore: Arduino hardware package for ATmega8, ATmega48, ATmega88, ATmega168, ATmega328 and ATmega328PB
  • Connecting a jumper across J2 on the USBasp you want to turn into an "Arduino Board". This just needs to be something that will create an electrical connection. In a pinch, you could just hold a piece of wire in place (firmly so it gets a good connection).
  • Connect an ISP programmer to the ICSP connector on the "Arduino Board" USBasp. If you have another ISP programmer, you can just plug its cable right in and all the connections will be correct. If you don't have another programmer, you can use a spare Arduino board as an "Arduino as ISP: https://www.arduino.cc/en/Tutorial/ArduinoISP
  • Tools > Board > ATmega8 (This assumes you have the common ATmega8 USBasp. There are apparently some with ATmega88 and if so you should chose that from the Board menu instead.)
  • Tools > Clock > 12 MHz External
  • Tools > Bootloader > Yes
  • Tools > Programmer > select the appropriate programmer selection for the programmer you are using to program your USBasp
  • Tools > Burn Bootloader

After doing that, remember to always use the same MiniCore board and clock selection when you use your "Arduino Board" USBasp

mlg556:
So basically for example I cannot write and upload a blink LED program which blink the led ON the USBasp device ?

Yes, you can do that. Here is a sketch that will blink the "green" LED (actually blue on my USBasp:
const byte LEDpin = 14;
const unsigned int duration = 1000;

void setup() {
pinMode(LEDpin, OUTPUT);
}

void loop() {
digitalWrite(LEDpin, HIGH);
delay(duration);
digitalWrite(LEDpin, LOW);
delay(duration);
}

You can find which Arduino pins are mapped to what on the USB by referring to the USBasp schematic:



and the MiniCore pin mapping:


From the schematic, you can see that the "green" LED is on PC0. From the pinout diagram, you can see that PC0 is mapped to Arduino pin 14.

You could also just use your ISP programmer to upload your sketches to the "Arduino Board" USBasp using the Arduino IDE's Sketch > Upload Using Programmer. If you're only going to do that, you might as well select Tools > Bootloader > No, and then do Burn Bootloader again. That will save you 0.5 kB of flash memory that would otherwise be reserved for the boot section. Note that when you do a Sketch > Upload Using Programmer, it erases the bootloader. If you want to do an upload over the UART using the bootloader after that, you first need to do a Burn Bootloader again.

Many of the 10 pin USBasp have the UART pins (RX, TX) broken out on some of the 10 pin connector's unused pins. You could connect a USB to TTL serial adapter module or cable (AKA "FTDI") to those pins and use that for uploads via the bootloader and communication with your computer (e.g. Serial Monitor).

I've actually been meaning to create an Arduino hardware package specifically for the USBasp, with boards for each of the common variants (6 pin, 10 pin, ATmega8, ATmega88). The primary purpose of this would be to allow you to update the USBasp firmware via the Arduino IDE, however, it would also allow you to use the USBasp as an Arduino board if you like.

I hadn't thought of the possibility of adding a USB bootloader so you could upload via the USB plug. I was just assuming people would upload to it using an ISP programmer. I'm not sure how tricky that would be to make happen. I know this sort of thing has been done in different ways by DigiStump and Adafruit for their ATtiny boards, but I don't know how easily that work could be translated over to the ATmega8.

Thanks for all the detailed replies ! I will get to it and share the results.