6

I'm trying to program an ATtiny85, using an AVRISP mkII programmer (this one: https://www.amazon.de/dp/B00IYNAXUC/ref=cm_sw_r_sms_c_api_i_VXOWDb3H3N5ND) with the Arduino IDE (version 1.8.10 on Ubuntu 18.10). For the ATtiny, I've installed https://github.com/damellis/attiny using the board manager, as recommended in countless tutorials.

Now, everything seems to be recognized fine, and I've selected the programmers port in the IDE: /dev/ttyACM0.
But when I try to upload a sketch, the IDE instead trys to pass usb as the port to avrdude. This is only visble when enabling verbose output: (paths abbreviated)

/home/[...]/avrdude -C/home/[...]/avr/etc/avrdude.conf -v -pattiny85 -cstk500v2 -Pusb -Uflash:w:/tmp/arduino_build_728460/sketch.ino.hex:i 

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/home/[...]/avrdude.conf"
         User configuration file is "/home/[...]/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : stk500v2
avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)

avrdude done.  Thank you.

usb isn't even a selectable port in the IDE!

Simply pasting the avrdude command (first line in the output above) to a terminal and changing usb to /dev/ttyACM0 makes it program the IC perfectly (but of course, that's a rather cumbersome workaround).

Also, selecting another programmer in the IDE (like AVR ISP, without the mkII) makes it use the correct port (but of course it won't work, since it's the wrong programmer).

Am I doing something wrong, or is this an actual bug in the Arduino IDE?

Fii
  • 161
  • 3

2 Answers2

1

I would say you have to select the Arduino as ISP Programmer. Not the mkII ISP. Perhaps the attiny board library can handle connection to attiny dev boards over usb if you use the standard programmer. But that's just a very very rough guess. But selecting the Arduino as ISP is a requirement.

Edit:

No you can not use the Arduino as ISP if you use an STK500 programmer.

D. A. Mellis' tool is designed for an Arduino as a programmer.

But if your work around does the programming, the mkII is the right tool. You have to find out, how the IDE builds the CLI string to start avrdude.

The tool you installed contains a text file called platform.txt:

name=ATtiny Microcontrollers

tools.avrdude.path={runtime.tools.avrdude.path}
tools.avrdude.erase.params.verbose=-v -v -v -v
tools.avrdude.erase.params.quiet=-q -q
tools.avrdude.erase.pattern="{cmd.path}" "-C{config.path}" {erase.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -e -Uefuse:w:{bootloader.extended_fuses}:m -Uhfuse:w:{bootloader.high_fuses}:m -Ulfuse:w:{bootloader.low_fuses}:m

tools.avrdude.bootloader.params.verbose=-v -v -v -v
tools.avrdude.bootloader.params.quiet=-q -q
tools.avrdude.bootloader.pattern="{cmd.path}" "-C{config.path}" {bootloader.verbose} -p{build.mcu} -c{protocol} {program.extra_params}

I would say the entry tools.avrdude.bootloader.pattern does the trick. Especially the variable {program.extra_params}. You have to find out how the IDE is building this variable. One of it's options must be -P<Port>. But why does the IDE use the value usb for <port>?

I'll try to find out. But I have no access to an IDE at the moment. If you (or someone else) find a solution before me, please add an answer and mark it as accepted, so I need not investigate further.

Peter Paul Kiefer
  • 1,893
  • 9
  • 11
1

You mean that the STK500 v2 programmer uses an emulated serial port rather than direct USB? Then I guess there is a bug in the Arduino IDE. The file programmers.txt contains the following lines describing the programmer:

avrispmkii.name=AVRISP mkII
avrispmkii.communication=usb
avrispmkii.protocol=stk500v2
avrispmkii.program.protocol=stk500v2
avrispmkii.program.tool=avrdude
avrispmkii.program.extra_params=-Pusb

You may locate this file in your Arduino installation and replace the last line from this snippet by

avrispmkii.program.extra_params=-P{serial.port}

If that works, it would be a good idea to submit a pull request with the fix to the Arduino team.

Alternatively, you may try selecting “Atmel STK500 development board” as a programmer. This is supposed to autodetect the version of the STK500 protocol, and uses the correct serial port.

Edit: you may also have to replace

avrispmkii.communication=usb

by

avrispmkii.communication=serial

C.f. this bug report, which seems to cover the exact issue you are facing.

Edgar Bonet
  • 45,094
  • 4
  • 42
  • 81