avrdude butterfly programmer uses avr_write_page() but does not provide a cmd()

Hi guys,
I am using some arduino micros (recognized as leonardos), but avrdude does not the way I want to

my steps:

  1. starting arduino 1.8.4 (also tried 1.8.6 does not change anything)
  2. loading blink sketch and inserting Serial.begin(9600); Serial.pritln("a");
  3. configuring as board arduino micro
  4. setting verbose output during upload
  5. hit the keys for uploading
  6. in default the port of the arduino is not found, so I double "press" reset at the hardware and the port is found.
    After this steps I get following output:
Build options changed, rebuilding all
Archiving built core (caching) in: /tmp/arduino_cache_312223/core/core_arduino_avr_micro_80d002210ad4f4c4b138a75ac18d4048.a
Sketch uses 4202 bytes (14%) of program storage space. Maximum is 28672 bytes.
Global variables use 153 bytes (5%) of dynamic memory, leaving 2407 bytes for local variables. Maximum is 2560 bytes.
PORTS {/dev/ttyS0, } / {/dev/ttyS0, } => {}
PORTS {/dev/ttyS0, } / {/dev/ttyS0, } => {}
PORTS {/dev/ttyS0, } / {/dev/ttyS0, } => {}
PORTS {/dev/ttyS0, } / {/dev/ttyS0, } => {}
PORTS {/dev/ttyS0, } / {/dev/ttyS0, } => {}
PORTS {/dev/ttyS0, } / {/dev/ttyS0, } => {}
PORTS {/dev/ttyS0, } / {/dev/ttyS0, } => {}
PORTS {/dev/ttyS0, } / {/dev/ttyS0, } => {}
PORTS {/dev/ttyS0, } / {/dev/ttyS0, } => {}
PORTS {/dev/ttyS0, } / {/dev/ttyS0, } => {}
PORTS {/dev/ttyS0, } / {/dev/ttyS0, } => {}
PORTS {/dev/ttyS0, } / {/dev/ttyS0, } => {}
PORTS {/dev/ttyS0, } / {/dev/ttyS0, } => {}
PORTS {/dev/ttyS0, } / {/dev/ttyS0, } => {}
PORTS {/dev/ttyS0, } / {/dev/ttyS0, } => {}
PORTS {/dev/ttyS0, } / {/dev/ttyS0, } => {}
PORTS {/dev/ttyS0, } / {/dev/ttyACM1, /dev/ttyS0, } => {/dev/ttyACM1, }
Found upload port: /dev/ttyACM1
/home/user/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/bin/avrdude -C/home/user/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf -v -V -patmega32u4 -cavr109 -P/dev/ttyACM1 -b57600 -D -Uflash:w:/tmp/arduino_build_591334/Blink.ino.hex:i 

avrdude: Version 6.3, compiled on Jan 17 2017 at 11:00:16
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/home/user/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf"
         User configuration file is "/home/user/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM1
         Using Programmer              : avr109
         Overriding Baud Rate          : 57600
         AVR Part                      : ATmega32U4
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  9000  9000 0x00 0x00
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : butterfly
         Description     : Atmel AppNote AVR109 Boot Loader

Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
    Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.

Programmer supports the following devices:
    Device code: 0x44

avrdude: devcode selected: 0x44
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9587 (probably m32u4)
avrdude: reading input file "/tmp/arduino_build_591334/Blink.ino.hex"
avrdude: writing flash (4202 bytes):

Writing | #avrdude: butterfly_recv(): programmer is not responding
avrdude: error: programmer did not respond to command: set addr
####################avrdude: error: programmer did not respond to command: set addr
#######avrdude: error: programmer did not respond to command: set addr
###avrdude: butterfly_recv(): programmer is not responding
avrdude: error: programmer did not respond to command: set addr
################### | 100% 17.84s

avrdude: 4202 bytes of flash written

avrdude done.  Thank you.

This one is a short one, sometimes I get a hundred outputs of **failed

I tried yet using the cmd line, but it does not change.
the avrdude is the newest version 6.3

Can someone help me?

Which OS?

Ubuntu 18.10 is where I have the problem

I now switched to my laptop ( which uses Ubuntu 18.04 and arduino ide 1.8.5). Here I do not have any problem. So it is neither the cable nor the board itself

Hi Fabian727,

seems iam facing the same / a similar problem.

i updated my kubuntu from 18.04 to 18.10 two days ago..
(but used arduino not for some weeks before today...)

iam tried with IDE 1.8.8.
but same behavior with IDE 1.8.7

iam getting:

---snip---
/home/stefan/mydata/arduino_sketchbook/_tests/test__Blink_D9/test__Blink_D9.ino
Using board 'Olimexino_32U4' from platform in folder: /home/stefan/.arduino15/packages/Olimex/hardware/avr/1.4.5
Using core 'arduino' from platform in folder: /home/stefan/mydata/tools/arduino/arduino-1.8.8/hardware/arduino/avr
Build options changed, rebuilding all
Detecting libraries used...
---snip---
Compiling sketch...
/home/stefan/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/avr-g++ -c -g -Os -Wall -Wextra -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10808 -DARDUINO_AVR_OLIMEXINO_32U4 -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 "-DUSB_MANUFACTURER=\"Unknown\"" "-DUSB_PRODUCT=\"Olimexino-32U4\"" -I/home/stefan/mydata/tools/arduino/arduino-1.8.8/hardware/arduino/avr/cores/arduino -I/home/stefan/.arduino15/packages/Olimex/hardware/avr/1.4.5/variants/Olimexino_32U4 /tmp/arduino_build_662211/sketch
Compiling libraries...
Compiling core...
---snip---
Archiving built core (caching) in: /tmp/arduino_cache_36317/core/core_Olimex_avr_Olimexino_32U4_7a80f03e9ac65f24d1dab897de003671.a
Linking everything together...
---snip---
/tmp/arduino_build_662211/test__Blink_D9.ino.elf
Sketch uses 4984 bytes (17%) of program storage space. Maximum is 28672 bytes.
Global variables use 164 bytes (6%) of dynamic memory, leaving 2396 bytes for local variables. Maximum is 2560 bytes.
Forcing reset using 1200bps open/close on port /dev/ttyACM0
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyS4, } => {}
PORTS {/dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {/dev/ttyACM0, }
Found upload port: /dev/ttyACM0
/home/stefan/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino14/bin/avrdude -C/home/stefan/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino14/etc/avrdude.conf -v -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D -Uflash:w:/tmp/arduino_build_662211/test__Blink_D9.ino.hex:i 

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

         System wide configuration file is "/home/stefan/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino14/etc/avrdude.conf"
         User configuration file is "/home/stefan/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM0
         Using Programmer              : avr109
         Overriding Baud Rate          : 57600
         AVR Part                      : ATmega32U4
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  9000  9000 0x00 0x00
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : butterfly
         Description     : Atmel AppNote AVR109 Boot Loader

Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
    Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.

Programmer supports the following devices:
    Device code: 0x44

avrdude: devcode selected: 0x44
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9587 (probably m32u4)
avrdude: reading input file "/tmp/arduino_build_662211/test__Blink_D9.ino.hex"
avrdude: writing flash (4984 bytes):

Writing | #################avrdude: error: programmer did not respond to command: set addr
###############avrdude: error: programmer did not respond to command: set addr
################## | 100% 0.60s

avrdude: 4984 bytes of flash written
avrdude: verifying flash memory against /tmp/arduino_build_662211/test__Blink_D9.ino.hex:
avrdude: load data flash data from input file /tmp/arduino_build_662211/test__Blink_D9.ino.hex:
avrdude: input file /tmp/arduino_build_662211/test__Blink_D9.ino.hex contains 4984 bytes
avrdude: reading on-chip flash data:

Reading | #avrdude: error: programmer did not respond to command: set addr
#avrdude: error: programmer did not respond to command: set addr
.....
##avrdude: error: programmer did not respond to command: set addr
#avrdude: error: programmer did not respond to command: set addr
#avrdude: error: programmer did not respond to command: set addr
#avrdude: error: programmer did not respond to command: set addr
##avrdude: error: programmer did not respond to command: set addr
#avrdude: error: programmer did not respond to command: set addr
#avrdude: error: programmer did not respond to command: set addr
## | 100% 0.06s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0x0d != 0x0c
avrdude: verification error; content mismatch
avrdude: error: programmer did not respond to command: leave prog mode
avrdude: error: programmer did not respond to command: exit bootloader

avrdude done.  Thank you.

the other problem iam facing is that i get

Reading | ################################################## | 100% 0.25s

avrdude: Device signature = 0x3f0d0d
avrdude: Expected signature for ATmega32U4 is 1E 95 87
         Double check chip, or use -F to override this check.

avrdude done.  Thank you.

Wrong microcontroller found.  Did you select the right board from the Tools > Board menu?

according to this post in the pololu forum the signature of '0x3f0d0d' consists of

Looking at your build output in more detail, the 0x3f portion of the 0x3f0d0d “signature” returned by AVRDUDE is the ASCII question mark, which is sent by the A-Star 32U4 bootloader when it receives an unrecognized command.
0x0d is the ASCII carriage return, which is also sent by the bootloader in response to some commands.
Perhaps another program is connecting to the A-Star’s bootloader’s serial port before AVRDUDE and sending some invalid commands to it.

  • Amanda

i have no idea whats going on -
i also tried to create a udev rule to disable the modem manager for this boards...
based on a-star/udev-rules/a-star.rules at master · pololu/a-star · GitHub

leonardo.rules

# Linux users can copy this file into /etc/udev/rules.d/ to prevent
# ModemManager from taking over the virtual serial port of the 32u4

# udevadm control --reload-rules
# udevadm trigger --attr-match=subsystem=usb


# Olimex
# official original arduino leonardo bootloader?
SUBSYSTEM=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="0036", ENV{ID_MM_DEVICE_IGNORE}="1"
# Olimexino-32U4 special?
SUBSYSTEM=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="8036", ENV{ID_MM_DEVICE_IGNORE}="1"

but i did not see any change.

Hello,

I had similar problems. But I used avrdude directly and I have older OS (4.10.0-42-generic #46~16.04.1-Ubuntu).

But I found this solution:

https://forum.arduino.cc/index.php?topic=129647.0

$ sudo usermod -a -G dialout
$ sudo apt-get --purge remove modemmanager

Hi all,

iam currently using Kubuntu 18.10. and Arduino IDE 1.8.9. :slight_smile:
and still had the issues that the ttyACM0 port vanished afert a few seconds..

$ dmesg --follow
...
[ 3164.971466] usb 2-1.3: new full-speed USB device number 11 using ehci-pci
[ 3165.081539] usb 2-1.3: New USB device found, idVendor=2341, idProduct=0237, bcdDevice= 0.01
[ 3165.081545] usb 2-1.3: New USB device strings: Mfr=2, Product=1, SerialNumber=0
[ 3165.081549] usb 2-1.3: Product: Genuino Micro   
[ 3165.081553] usb 2-1.3: Manufacturer: Arduino LLC
[ 3165.082188] cdc_acm 2-1.3:1.0: ttyACM0: USB ACM device
[ 3167.819210] usb 2-1.3: USB disconnect, device number 11

the time-stamps tell you - it was visible for about ~2.8 seconds :confused:

after i tried to use a bunch of udev related ideas to get the ModemManager to ignore the arduino boards -
(i did not want to remove it entirely)
today i found the tip on temporary disabling the service:
source: The Linux ttyACM0 drama - more details after a lot of experimenting - #20 by gian21391 - Installation & Troubleshooting - Arduino Forum

here a repost of the information from above - so they are easier & faster to find via search engines:

disable ModemManager temporarily:

sudo systemctl stop ModemManager.service

with

systemctl status ModemManager.service

you can check if this is really stopped. it should print something like:

$ systemctl status ModemManager.service
● ModemManager.service - Modem Manager
   Loaded: loaded (/lib/systemd/system/ModemManager.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Sat 2019-04-06 12:59:54 CEST; 6s ago
  Process: 1104 ExecStart=/usr/sbin/ModemManager --filter-policy=strict (code=exited, status=0/SUCCESS)
 Main PID: 1104 (code=exited, status=0/SUCCESS)

Apr 06 12:54:26 stefan-Latitude-E6510 ModemManager[1104]: <warn>  [plugin manager] task 19,ttyACM0: error when checking support with plugin 'Cinterion': '(tty/ttyACM0) failed to open port: Could not open serial device ttyACM0: No such file or directory'
Apr 06 12:54:26 stefan-Latitude-E6510 ModemManager[1104]: <warn>  (ttyACM0) could not open serial device (2)
Apr 06 12:54:26 stefan-Latitude-E6510 ModemManager[1104]: <warn>  [plugin manager] task 19,ttyACM0: error when checking support with plugin 'Iridium': '(tty/ttyACM0) failed to open port: Could not open serial device ttyACM0: No such file or directory'
Apr 06 12:54:26 stefan-Latitude-E6510 ModemManager[1104]: <warn>  (ttyACM0) could not open serial device (2)
Apr 06 12:54:26 stefan-Latitude-E6510 ModemManager[1104]: <warn>  [plugin manager] task 19,ttyACM0: error when checking support with plugin 'Generic': '(tty/ttyACM0) failed to open port: Could not open serial device ttyACM0: No such file or directory'
Apr 06 12:54:26 stefan-Latitude-E6510 ModemManager[1104]: <info>  Couldn't check support for device '/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3': not supported by any plugin
Apr 06 12:59:54 stefan-Latitude-E6510 systemd[1]: Stopping Modem Manager...
Apr 06 12:59:54 stefan-Latitude-E6510 ModemManager[1104]: <info>  Caught signal, shutting down...
Apr 06 12:59:54 stefan-Latitude-E6510 ModemManager[1104]: <info>  ModemManager is shut down
Apr 06 12:59:54 stefan-Latitude-E6510 systemd[1]: Stopped Modem Manager.

here i also found warnings telling me that my udev-rules did not stopped it from messing with my boards.... :o :confused:

but after the stop of it the boards worked as expected

to disable the service permanently just run

sudo systemctl disable ModemManager.service

all options are as following:

systemctl [stop|start|restart|enable|disable] ModemManager.service

(this should be true for all services...)

Thanks for sharing your findings s-lighte! I'm sure anyone experiencing the same issue will be very grateful to find this information.

That ModemManager has caused a lot of headaches.

there are a light at the end of the tunnel...

with ModemManager Version 1.10.6 this problem should be fixed...
you can check your currently installed version with

~$ ModemManager --version

ModemManager 1.10.4
Copyright (C) 2008-2019 The ModemManager authors
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl-2.0.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

as you see - for me i have to wait a little till my disttribution will get the update..

some really in depth description of the multiple things that lead to this can be read in this github merge request

so it should be also fixed if you can update your bootloader...

at the end there there are links to the announcement:

https://lists.freedesktop.org/archives/modemmanager-devel/2019-September/007424.html

Hey hey,
This is the third bugfix release in the ModemManager 1.10.x series.
Overview of changes in ModemManager 1.10.6

The list of changes in this version includes:
....

  • udev:
    ** Updated ID_MM_DEVICE_IGNORE to make it really a user-usable tag, applicable not only to TTY devices but to any kind of device (e.g. to blacklist MBIM modems); and also applicable under any kind of filter mode (including 'strict' mode).
    ...

and with this it is also in the official documentation
https://www.freedesktop.org/software/ModemManager/api/latest/ModemManager-Common-udev-tags.html#ID-MM-DEVICE-IGNORE:CAPS

i will have a play with the other ideas that are available in this stackoverflow question.
if i find something i will report back here..

sunny greetings
stefan