Created by: gwideman, Dec 9, 2014 2:25 pm
Revised by: gwideman, Apr 14, 2015 4:11 pm (15 revisions)

2015-04-14: Largely superseded by:

Overview

Notes on setting up the programmer equipment and software for programming AVR chips. Example uses:
  • Atmel AVRISP MkII programmer
  • Window 7-64
    • ... and its driver security restrictions.
    • libusb... sort of
  • Atmel Studio 6.2
  • WinAVR, GCC toolchain, AVRDude
  • Target ATTiny85 chip
... and the numerous pitfalls and confusing junctures I encountered. Recorded here so as to avoid them in future, I hope.

Steps

WinAVR

  • Ladyada WinAVR setup tutorial: http://www.ladyada.net/learn/avr/setup-win.html.
    • Failed installing libusb(-win32?) driver. Mainly because version supplied with WinAVR doesn't include a digital signature that Windows 7-64 will accept.
    • My attempt to get a newer libusb to install failed, though I don't remember how.
      • I visited Device Manager to uninstall this libusb driver.
    • I was able to edit and compile a simple AVR program using Programmer's Notepad
    • I couldn't get AVRDUDE to do anything that resembled "working" with AVRISP MkII. Mostly because I couldn't tell from its error messages what it thought was wrong.
    • I decided to divert to installing Atmel Studio to get something working.
    • After installing Atmel Studio I installed libusb-win32 and set a filter driver using the Filter Driver GUI tool.
      • I then played a bit with AVRDUDE and still couldn't determine if it was succeeding to talk to the AVRISP programmer. More later...

Atmel Studio

  • I decided to try to get Atmel Studio working, figuring that Atmel surely provided a driver for their own AVRISP MkII programmer that would work, and I could use that to observe and validate the AVRISP's behavior, the external target chip and so on. (I had read that there was a libusb-win32 driver that could operate as a filter on top of Atmel's USB-to-AVRISP driver, and I figured I could get that going later.)
  • Atmel Studio 6.2 install took 20-30 minutes.
    • Included installing driver for AVRISP
AVRISP behavior:
State
USB-side light
ISP-side light
AVRISP plugged in to USB, target cable unplugged
Green
Red
Plug in target, as yet unpowered
Green
Red
Power target
Green
Green
Target is powered, but no target chip
Green
Green
Powered target, but wiring problem (Eg: no pullup on reset line)
Green
Orange blink
More serious wiring problem
Green
Red blink
Powered and properly functioning target; During a programming function, such as read or write.
Green
Orange



AVR Studio observations
  • Very slow on recent i7 laptop. Takes about a minute just to start the IDE. Opening a trivial "solution" takes half a minute.
  • Salient dialog is: Tools > Device Programming. Some notes:
Dialog tab
Dialog element
Comments
Top area
Select Tool combo box.
AVRISP shows up twice. Once as "AVRISP mkII" and once as "AVRISP mkII 000200202292". See Tool information below for explanation

Device
I selected ATtiny85

Interface
ISP

Apply button
I guess you hit this after changes

Device signature, Target voltage
Hit "Read" button to get these from target.
Interface settings
ISP clock
Set to something low initially. Comment says set it < 1/4 device frequency
Tool information

With Tool = AVRISP mkII: Serial number empty; Connection com.atmel.avrdbg.connection.libusb0; Firmware 1.17; Hardware version 1.
With Tool = AVRISP mkII 000200202292: Serial number 000200202292 (ah-HAH!); Connection com.atmel.avrdbg.connection.jungousb; Firmware 1.17; Hardware version 1.
So apparently Atmel Studio sees the additional libusb-win32 filter driver, or maybe some vestige of the libusb install that I failed to back out. Or maybe "libusb0" is the API that any libusb-related thingy exposes to a program.
Device information
Read button
Reads info from target chip, and displays it. Should show Detected device type and signature. Signature is same as
Oscillator calibration

Not explored
Memories

Offers programming, read, erase, verify functions. (Once preceding items worked, the programming functions worked fine.)
Fuses

Programs the fuses. Default: SPIEN; CKDIV8; SUT_CKSEL = INTRCOSC_8MHZ_6CK_14CK_64MS
Lock bits

NO_LOCK
Production file

Contains programming functions, including for Flash, EEPROM, Fuses and Lock bits all on one panel.



Back to AVRDUDE

By this point
  • I'd got my target board working in Atmel Studio. In the process correcting a missing pull-up resistor on /Reset.
  • I'd installed the libusb-win32 filter driver.
Questions:
  • What commands does AVRDUDE offer that might be useful in verifying operation of the programming setup?
AVRDUDE docs: http://www.nongnu.org/avrdude/user-manual/avrdude_toc.html
Sample commands: All of these worked fine
Command
Expalnation
avrdude -p t85 -c avrispmkII -P usb -U eeprom:r:test.hex:i
part=attiny85; programmer=avrisp mkii; port=usb; Memory operation = eeprom read to file test.hex in intel hex format
avrdude -p t85 -c avrispmkII -P usb -U signature:r:test.hex:i
Ditto, except read the 3 signature bytes
avrdude -p t85 -c avrispmkII -P usb -n
part=attiny85; programmer=avrisp mkii; port=usb; don't write.
This command would appear to request that nothing happen. However AVRDUDE's response is informative and confirms a connection to the target:
avrdude: AVR device is initialized and ready to accept instructions
Reading: ####....####: 100%
avrdude: Device signature = 0x1e930b
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

Some AVRDUDE responses to not-working conditions:
[TODO]

Other tips

  • Problem: Windows detects a newly-plugged device, but fails to install a driver for it, and doesn't prompt for one. This can happen if there's an existing driver that thinks it can handle a device, but then fails to do so. In that case:
    • Open Windows Device Manager
    • See item Other Devices, under which should appear the not-properly-installed device.
    • Right-click on the device item, select "Update Driver Software...", which will start the wizard for installing a driver, for which you can specify location of install files etc.

References

Atmel

libusb

This is apparently NOT what you need. There are a bunch of sites somehow associated to "plain" libusb, and they seem unaware that there is any confusion from the proliferation of overlapping sites, and also unaware of any installation problem on Win 7-64. For what it's worth:
This might lead to something: https://github.com/libusb/libusb/issues/43

libusb-win32

NOTE: Do not get sidetracked onto the plain libusb component supplied with WinAVR, which fails Windows 7-64 digital signature requirement.
  • http://sourceforge.net/p/libusb-win32/wiki/Home/ "libusb-win32 libusb-win32 is a port of libusb-0.1 under Windows"
  • Download: https://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/
  • Version is at 1.2.6.0, and this version number seems unrelated to the version number of libusb.
  • Three possible driver installation approaches ("modes") documented on the Home page:
    • Device driver mode. Self-sufficient driver. However, this competes with AVR Studio's Jungo-supplied driver, if that's installed (before or after). (eg: Jungo driver to talk over USB to Atmel AVRISP MkII programmer).
    • Device filter driver mode. This presents a libusb API to programs that expect it, and routes that through an existing device driver, most usefully, AVR Studio's driver. Libusb-win32 comes with a small "Filter Wizard GUI" program to allow installing and configuring device filters on a per-USB-port basis. (Hence user has to invoke Filter Wizard whenever programmer gets plugged into a USB port that it hasn't previously been plugged into.)
    • Class filter mode: Attaches filter to "all possible device class" [sic]. Docs recommend against that mode.
Conclusion: If you want to use Atmel Studio as well, install that first, then install libusb-win32 and use it in Device Filter Driver mode.

Zadig

Seems like a good idea, but what does it do with WinAVR, where Atmel Studio and AVRDude seem to need two different drivers. (Resolved by libusb-win32's filter mode -- but does zadig know about that?)

AVR Studio, Atmel Studio

WinAVR

WinAVR includes

N
Tool
Descr
Latest V
Link/Comment
1
AVR GNU Binutils 2.19
Binary utilities for AVR target (including assembler, linker, etc.).


2
AVR GNU Compiler Collection (GCC) 4.3.3
C language and C++ language compiler for AVR target. There are caveats for using the C++ compiler. See the installed avr-libc User Manual in the <InstallDir>\doc directory.


3
avr-libc 1.6.7cvs
C Standard Library for AVR.


4
AVRDUDE 5.8cvs (2010
avrdude is an open source programmer software that is user extensible.
6.0.1 2013-09-17
Version in Arduino 1.0.6 is 5.11, 2011-09-02
5
AVR GNU Debugger (GDB) / Insight 6.8
GDB is a command-line debugger. Insight is GDB with a GUI!


6
AVaRICE 2.9
avarice is a program for interfacing the Atmel JTAG ICE to GDB and users can debug their AVR. Use it in conjunction with GDB.


7
SimulAVR 0.9cvs
simulavr is used in conjunction with GDB to provide AVR simulation.


8
AVR32 GNU Binutils 2.19



9
AVR32 GNU Compiler Collection (GCC) 4.3.2
Either a repeated item, or deliberately included older version


10
Newlib (for AVR32) 1.16.0



11
AVR32 GNU Debugger (GDB) / Insight 6.7.1



12
Splint 3.1.2



13
SRecord 1.47
SRecord is a collection of powerful tools for manipulating EPROM load files. It reads and writes numerous EPROM file formats, and can perform many different manipulations.


14
MFile
An automatic makefile generator for AVR GCC.


15
Programmers Notepad 2.0.8.718
Programming editor and IDE. This editor includes the Scintilla editor component.
2.0.8.718?
https://sourceforge.net/projects/pnotepad/
16
LibUSB 0.1.12.1 and device drivers
This is a USB library that is linked into AVRDUDE and AVaRICE to allow them to connect to the Atmel JTAG ICE mkII and the Atmel AVRISP mkII. Drivers for these devices are also included.

Outdated, Not able to install on Win7-64. libusb0 site warns of severe bugs.
17
Cygwin DLLs
Certain DLLs from the Cygwin project are required for specific included packages. See the Build Notes section for which packages require which DLL. NOTE: Not all executables require these Cygwin DLLs.


18

Many native Win32 GNU programs and utilities including make and bash.


19
Tofrodos 1.6
A command-line text file line-ending convertor.


20

A Makefile Template for you to use in your projects


21

Documentation for the various projects.


22

Source code patches used to build the various projects.


Notes
1. WinAVR-user-manual.html also says: "LibUSB-Win32 is a USB library that is linked into AVRDUDE and AVaRICE to allow them to connect to the Atmel JTAG ICE mkII and the Atmel AVRISP mkII. Drivers for these devices are also included. LibUSB is installed under: <install>\utils\libusb\bin"
This is very flaky. The manifest list above talks about libusb, whereas this narrative talks about libusb-win32, which is NOT the same thing. Looking in the <install>\utils\libusb\bin directory, there are files that might be libusb-win32, or might not, and there's no indication of version. In any case, Windows 7-64 fails to install them due to lack of digital signature.
2. In general, it's hard to imagine that the components in WinAVR are up-to-date.

AVRDude

AVRDUDE tips

... such as sample command lines

Alternative approaches