USB ISP Modification

Hi,

I recently bough one of these since it was cheap and came with a 2x5 to 2x3 adapter. Tought it would work as a USBasp with Arduino, however it turns out it doesn't. It shows up as a USB HID device and has some slight changes from the standard USBasp. After lots of googling and reading through the USBasp firmware code I managed to get it flashed with a modified version of the USBasp firmware and tought I'd share a guide in case someone else has this or a similar ISP.

1 - Solder pin 5 (RESET) on the ISP header to pin 29 on the ATMega8A.

2 - Connect the ISP header to another ISP (e.g. Arduino as ISP).

3 - (Optional) Backup the original firmware.

Example with an ArduinoISP on Windows:

avrdude -c arduino -p atmega8 -P com3 -b 19200 -U hfuse:r:hfuse_orig.bin:r -U lfuse:r:lfuse_orig.bin:r -U flash:r:flash_orig.bin:r -U eeprom:r:eeprom_orig.bin:r

(There's a copy of avrdude in your Arduino\hardware\tools\avr\bin folder.)

4 - Get the latest USBasp firmware from USBasp - USB programmer for Atmel AVR controllers - fischl.de.

5 - Modify usbconfig.h (D+ is connected to D2 and D- is connected to D3), i.e. the defines should be,

...
#define USB_CFG_IOPORTNAME      D
/* 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      3
/* 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       2
/* 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!
...

6 - Modify the DDR settings in the main function in main.c to,

...
/* no pullups on USB and ISP pins */
PORTD = 0;
PORTB = 0;
 
/* all outputs except PD2 = INT0 */
DDRD = 0b01101100;

/* output SE0 for USB reset */
DDRB = 0b00111100;
j = 0;
/* USB Reset by device only required on Watchdog Reset */
while (--j) {
 i = 0;
 /* delay >10ms for USB reset */
 while (--i)
 ;
}
/* all USB and ISP pins inputs */
DDRB = 0;
DDRD = 0b01100000;
...

7 - Modify usbasp.h to make the LEDs work (hooked up to PD5 and PD6). The following sort of works (LED is normally off and turns on when programming):

...
/* macros for gpio functions */
#define ledRedOn()    PORTD |= 0b01000000
#define ledRedOff()   PORTD &= 0b10111111
#define ledGreenOn()  PORTD |= 0b01000000
#define ledGreenOff() PORTD &= 0b10111111
...

8 - Compile using "make main.hex" and flash using "make flash" as well as setting the fuses with "make fuses".

You can get make for windows here: Make for Windows.

You have to add an environment variable in Windows to be able to run it without specifying a path (Control Panel -> System -> Advanced system settings -> Environment Variables... -> Path -> Edit, and add ; at the end). You might as well also add the Arduino\hardware\tools\avr\bin as it contains avrdude and avr-gcc.

You also have to edit the Makefile and change the ISP and PORT variables to what you are using and for ArduinoISP you have to add "-b 19200" to flash, fuses and avrdude.

You can either copy avrduide.conf from Arduino\hardware\tools\avr\etc to the bin folder where avrdude is located or add a "-C " in the Makefile.

9 - Desolder the wire from step 1.

10 - Hook the USB programmer up to a USB port and install drivers located in the bin\win-driver folder of the USBasp firmware from step 4 (for Windows 8 you have to disable driver signature verification, just google "windows 8 disable driver signature verification").

11 - And done, your USB programmer now works as a USBasp with avrdude which means you can directly upload sketches in the Arduino IDE (File -> Upload Using Programmer, after you've set Tools -> Programmer to USBasp).

A zip-file containing a binary of the modified firmware is attached as well as a zip-file containing the modified bits of code. A schematic of the device is also attached (if your ISP is different you can reverse engineer yours as well, just takes a magnifying glass or good eyes and a multimeter with a continuity tester).

USB_ISP.pdf (35 KB)

modified_code.zip (8.85 KB)

usbasp_modified_firmware_binary.zip (4.89 KB)

1 Like

You can avoid all the permanent path changes in Windows by creating a 2 line file named environment.cmd and with contents similar to below (edit for your system needs):

path=%path%;C:\Program Files (x86)\Arduino_106\hardware\tools\avr\bin;
CMD /K "PROMPT $G &&CLS&&PATH"

Ray