Re: timeouts on USB ISP programmer

From: Tomek CEDRO <>
Date: Fri, 08 Apr 2022 16:04:25 UTC
On Fri, Apr 8, 2022 at 11:08 AM Axel Rau <> wrote:
> Am 08.04.2022 um 05:33 schrieb Tomek CEDRO <>:
> Mystery solved ;-)
> For avrdude `-P` parameter defines the the programmer port __BUT__ (as
> obviously stated in man page) if you use `usb:` device then you need
> to provide programmer SERIAL NUMBER last bytes not the OS serial port
> device ;-)

> I have no such serial number on the outside of my DIAMEX-ISP-USB. )-:
> All I have is this:
> root@home2l:/ # usbconfig -d 0.4 dump_device_desc
> ugen0.4: <ERFOS AVR-ISP2> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (500mA)
>   bLength = 0x0012
>   bDescriptorType = 0x0001
>   bcdUSB = 0x0200
>   bDeviceClass = 0x0002  <Communication device>
>   bDeviceSubClass = 0x0000
>   bDeviceProtocol = 0x0000
>   bMaxPacketSize0 = 0x0040
>   idVendor = 0x16c0
>   idProduct = 0x2a9b
>   bcdDevice = 0x4340
>   iManufacturer = 0x0001  <ERFOS>
>   iProduct = 0x0002  <AVR-ISP2>
>   iSerialNumber = 0x0003  <19331-49101-552>
>   bNumConfigurations = 0x0001

Good news is that you can only provide `-P usb` if you have one
Programmer Interface and it is defined in the configuration. In your
case if you want to use specific serial number that would probably be
`-P usb:552` parameter.

> Would it help to create a section for programmer diamex-isp-usb ?

Yes. As Diamex interface is not defined in the configuration files,
where all hardware definition resides, avrdude will not detect it.

You need to create a local user configuration file  (`~/.avrduderc`)
with the interface definitions. Try copy-paste from existing similar
interface, change VID:PID pair, and step by step make it work :-)

> All I got with -vvv:
> avrdude: usbdev_open(): did not find any (matching) USB device "usb:552" (0x03eb:0x2104)
> avrdude: usbdev_open(): did not find any (matching) USB device "usb:0552" (0x03eb:0x2104)
> avrdude: usbdev_open(): did not find any (matching) USB device "usb:0003" (0x03eb:0x2104)
> avrdude: usbdev_open(): did not find any (matching) USB device "usb:1552" (0x03eb:0x2104)

Okay, so at first you need to provide VID=0x16C0 and PID=0x2A9B in
your local configuration file that will contain the interface
definition. At the end of message I will try to deduce example
configuration file for you :-)

> I’m still not convinced that this stick does real USB mode (instead of serial emulation via ftdi.

This is not the problem. It uses "real USB mode" to transport commands
between PC and FT2232 too. Most of those Programmer dongles uses
Virtual-COM-Port-over-USB (aka VCP / USB CDC). No matter if you use
dedicated IC like FT2232H that you can simply put in your design and
control with a predefined command sequences using libraries like
LibUSB+LibFTDI, or you use a microcontroller with embedded USB Device
silicon that puts additional burden on you to create a base firmware
for that in the first place just then to get the commands to control
it like FT2232.

Using FT2232H is cheaper when you consider firmware + software
developer time cost and you need no extra functionalities beyond GPIO
control. This is really powerful chip and I still keep my KT-LINK in
my backpack every day :-)

> I’m willing to buy a quality programmer from ATmel to move on.
> Any recommendations?
> Please advice.

You will learn more when you bring your interface to life. Maybe
contact Diamex and ask them to create such configuration for avrdude.
Maybe you can create such configuration and ask them for some
financing for better motivation. You can also send one programmer to
me and I will try to help but I need that hardware at hand :-)

I have one project in mind that will use ATtiny10. In order to program
this chip I also bought these two ATtiny104XNANO and ATtiny416XNANO.
These were cheap generic boards, one of them should work with existing
Open-Source utilities, so I was sure I could convert them to
programmer of my ATtiny10. Thanks to you I took some time and focus to
research the area in practice :-)

If you plan to work more with AVR and have some funding then ATMEL-ICE
seems most popular interface and it is also supported in all possible
configurations with avrdude:

> All I currently need, is burning/flashing/fusing ATtinys:
>  avrdude -c stk500v2 -p t861 -P /dev/ttyU1 \
>     -U hfuse:w:init.t861.elf \
>     -U efuse:w:init.t861.elf \
>     -U eeprom:w:init.t861.elf \
>     -U flash:w:init.t861.elf

t861 target seems to be already in place, we just need to create a
configuration for Diamex interface :-)

> But debugging support would be helpful in the future.

It may be possible, looks like the code is there, but first things
first, we need to create a base interface configuration for Flashing..
it may then allow Debug.

I am not that familiar with avrdude. Did not even know that Debug is
now possible with AVR. It seems that depends on how you connect the
Interface to the Target MCU as there are several possible ways. Last
time I played with AVR was around 2003 :-) :-)

If you need to know the details DataSheets are always best place to
look in the first place. I learned digital electronics from Atmel's
datasheets (for At89C51 MCU) in the 1990's :-)

> Sorry, I'm a newbie in the MCU business.
> Thank you so much for all the time you did spend to help me,
> Axel

No worries. This is the most beautiful time of exploration. Also the
hardest one as lots and lots of unexpected details jump out of the
hat. But this is absolutely normal. We all learn all the time :-)



Here is an example `~/.avrduderc` to try out. It should work out of
the box as FT2232 has constant `reset`, `sck`, `mosi`, `miso` pins.
`VID:PID` pair is defined. You y need to tune `usbvendor`,
`usbproduct`, `usbdev`, `usbsn` fields. Default programmer is defined
so there is no need to provide `-c` parameter. Maybe `-P usb` is
necessary not sure. Please let us know how this works for you (with
`-vvv` switch).

# Possible entry formats are:
#   programmer
#       parent <id>                                 # optional parent
#       id       = <id1> [, <id2> [, <id3>] ...] ;  # <idN> are quoted strings
#       desc     = <description> ;                  # quoted string
#       type     = <type>;                          # programmer type,
quoted string
#                          # supported programmer types can be listed
by "-c ?type"
#       connection_type = parallel | serial | usb
#       baudrate = <num> ;                          # baudrate for
#       vcc      = <num1> [, <num2> ... ] ;         # pin number(s)
#       buff     = <num1> [, <num2> ... ] ;         # pin number(s)
#       reset    = <num> ;                          # pin number
#       sck      = <num> ;                          # pin number
#       mosi     = <num> ;                          # pin number
#       miso     = <num> ;                          # pin number
#       errled   = <num> ;                          # pin number
#       rdyled   = <num> ;                          # pin number
#       pgmled   = <num> ;                          # pin number
#       vfyled   = <num> ;                          # pin number
#       usbvid   = <hexnum>;                        # USB VID (Vendor ID)
#       usbpid   = <hexnum> [, <hexnum> ...]        # USB PID (Product ID) (1)
#       usbdev   = <interface>;                     # USB interface or
other device info
#       usbvendor = <vendorname>;                   # USB Vendor Name
#       usbproduct = <productname>;                 # USB Product Name
#       usbsn    = <serialno>;                      # USB Serial Number
#        To invert a bit, use = ~ <num>, the spaces are important.
#        For a pin list all pins must be inverted.
#        A single pin can be specified as usual = ~ <num>, for lists
#        specify it as follows = ~ ( <num> [, <num2> ... ] ) .
#        (1) Not all programmer types can process a list of PIDs.
#     ;

# set this to avoid providing `-c` all the time :-)
default_programmer = "diamex-avr-usb";

# this will interface with the chips on these programmers:
#, jtagkey-tiny.shtml
#, arm-usb-tiny.html
# The drivers will look for a specific device and use the first one found.
# If you have mulitple devices, then look for unique information (like SN)
# And fill that in here.
# Note that the pin numbers for the main ISP signals (reset, sck,
# mosi, miso) are fixed and cannot be changed, since they must match
# the way the Multi-Protocol Synchronous Serial Engine (MPSSE) of
# these FTDI ICs has been designed.

  id         = "diamex-avr-usb";
  desc       = "FT2232 based Diamex AVR USB programmer";
  type       = "avrftdi";
  connection_type = usb;
  usbvid     = 0x16C0;
  usbpid     = 0x2A9B;
  usbvendor  = "";
  usbproduct = "";
  usbdev     = "A";
  usbsn      = "";
#ISP-signals - lower ADBUS-Nibble (default)
  reset  = 3;
  sck    = 0;
  mosi   = 1;
  miso   = 2;
#LED SIGNALs - higher ADBUS-Nibble
#  errled = 4;
#  rdyled = 5;
#  pgmled = 6;
#  vfyled = 7;
#Buffer Signal - ACBUS - Nibble
#  buff   = 8;