In AVR Programmers I: Arduino as ISP we built an AVR programmer using an Arduino Uno. Pin10 of our Programmer toggles the reset of our target chip. A hex file from your PC is uploaded through the programmer to the target chip.
We programmed the Uno with the ArduinoISP sketch so that it became a USB to SPI serial data converter. Avrdude now sees the board as a -c avrisp or -c stk500v1 device on the same USB serial port.
A green LED named heartbeat pulses to remind us that it is working as a programmer. A red error LED needs you to press reset button on the board.
6pin and 10pin headers are quite standard for AVR programmers and development boards. Careful matching pins, do not force connectors, they are keyed to control orientation. Look for number, dot and triangle symbols for pin1.
USBtiny ISP programmers are designed around ATtiny MCU chips. ATtiny is the same thing as an Arduino but smaller. Less flash and RAM, same clock speeds.
ATtiny2313 chips have 20 pins, 2kByte flash to store a program and 128 Bytes of RAM for calculations. ATtiny44 chips have 14 pins, 4kByte flash and 256 Bytes of RAM. These smaller chips now have to do the same job as the ArduinoISP and read/write files on your computer to chips like on an Arduino.
These three USB dongles all work as USBtiny programmers. The 6pin and 10pin box headers use the standard pinout configuration. Careful to look for number, dot and triangle symbols for pin1.
All three came already with working firmware to be -c usbtiny programming circuit. No serial comm port is assigned. Windows PCs will need driver software to use these programmer devices.
LinuxPlug the USBtiny programmer into a Linux computer. dmesg and lsusb commands should show the device recognized.
To upload a hex file on a comms port your user account in Linux needs to have the privileges of the dialout group. If you see messages saying you are blocked from sending a file on your comms port then try the CLI command.
$ sudo usermod -a -G dialout $USER
Windows DriversPlug the USBtiny programmer into a PC. Windows will need a driver so that it recognizes the USBtiny and knows how to use it. There will not be a serial port assigned.
If you follow the links to FabISP and Adafruit you will see that they started with drivers that worked but now recommend using Zadig for installing drivers in your computer.
Follow instructions menu Options->List All Devices select USBtiny. It will take a minute to install driver libusb-win32(version). More details in project FabISP AVR ISP ATtiny44. You may have to repeat the driver installation if you switch between USBtiny and USBasp programmer devices.
AvrdudeTerminal command to download firmware from an Arduino target.
avrdude -p m328p -c usbtiny -U flash:r:target.hex:i
The avrdude.exe program is installed with Arduino IDE or it can be installed separately. There are GUI versions with a graphical interface. You don't need a -P com port for a USBasp programmer.
Make sure you have all the parameters typed correctly. Check the -p part, -c circuit, hex file name, etc.
Arduino IDEMenu Tools->Programmer->USBtinyISP then Sketch->Upload Using Programmer.
Menu Tools->External Tools... and add a new entry. Avrdude.exe must be on the computer. The arguments field tells avrdude to use a -c usbtiny to write a hex file named after the project.
Arguments: -p atmega328p -c usbtiny -U flash:w:$(BinDir)\$(TargetName).hex:i
Menu Tools->usbTiny and a black command window will blink as the hex file uploads. Close on exit is the default but you can uncheck for troubleshooting. Read error messages closely for corrections.
Arduino ISP boardArduino Corp made their own Arduino ISP boardcontaining an ATtiny45 chip. Here's what we see in the schematic drawing. USB port has +5V, gnd, D+ and D- leads. 6pin ISP header for programming. SJFAB header to put into programming mode.
3 SPI pins SCK, MISO and MOSI, a pin to reset the target chip. 3 pins for USB. Data+ and Data- carry serial data to and from the USB port, Data+ is also connected to an interrupt pin so that a connected computer can get the attention of the MCU running the AVR ISP thingy there.
Think of the USBtiny programmer as an Arduino board. It has been programmed with a software sketch to make it be a programmer. A metal jumper puts the device into flash mode and you can upload new firmware through the ICSP connector.
Adafruit USBtinyAdafruit's version USBtinyISP uses the ATtiny2313. JP1 and JP2 are the 6pin and 10pin box connectors for ICSP programming. The pins are connected to each other.
Notice how the SELF PGM header connects the RST of the programming port to reset on the chip. Short SELF PGM and you can upload new firmware to this board.
FabISPFabISP is about fabrication. A reliable programmer you would need in a factory or college laboratory. Some schools do have you build and program a USBtiny programmer as part of a greater embedded programming class.
ATtiny44 and ATtiny45 chips have plenty of IO pins for Data+, Data-, RST, SCK, MOSI and MISO leads.
Just like the ArduinoISP there are firmware sketches or C/C++ programs to make the board into a programmer. Project FabISP AVR ISP ATtiny44 USBtiny Programmer looks at an inexpensive programmer made with this design.
It's not workingModify the avrdude command and make it work at a baud rate speed -b 19200 or -b 9600. Change from USB3.0 ports to USB2.0 ports on your computer. Try different USB data cables. Make sure you are using the correct -p part and -c circuit parameters.
avrdude -p m328p -c usbtiny -b 9600 -U flash:r:target.hex:i
Some colleges include building a programmer in their embedded training courses. You print PCB circuits and solder in components. Circuit schematics and PCB drawings are available. You can download source files and compile firmware for your own dongle.
Burn Bootloader?Maybe not. If you are programming an Atmel AVR processor with a USBtiny device then you may not want to add the bootloader program. It consumes flash and is only needed to work with Arduino IDE.
Comments