I’m having trouble successfully uploading arduino sketches to my Zumo robot from linux (Ubuntu 18.04 MATE). When uploading from Windows 10, sketches upload fine, however I do most of my work on linux and as such would much prefer to be able to upload through linux.
I’ve followed the various bootloader reset procedures in the Zumo’s user guide all to no avail. So far the only things that remotely works is to wipe the Zumo with sudo avrdude -c avr109 -p atmega32U4 -P /dev/ttyACM0 -e
then upload with Arduino IDE. The IDE will give an error but the sketch still uploads the first time after wiping. I then have to wipe it again to upload any updates, otherwise it errors out without uploading. The first upload error(s) I get is:
avrdude: verification error, first mismatch at byte 0x003c
0x00 != 0x0c
avrdude: verification error; content mismatch
avrdude: verification error; content mismatch
When trying to upload again without wiping the Zumo, I get the following errors (there are more than the ones provided but they’re all roughly the same message):
avrdude: error: programmer did not respond to command: set addr
avrdude: error: programmer did not respond to command: write block
***failed;
avrdude: Error: butterfly programmer uses avr_write_page() but does not
provide a cmd() method.
*** page 97 (addresses 0x30e2 - 0x3161) failed to write
avrdude: error: programmer did not respond to command: set addr
avrdude: error: programmer did not respond to command: leave prog mode
avrdude: error: programmer did not respond to command: exit bootloader
Any help would be greatly appreciated.
Hello.
I am sorry you are having trouble programming your Zumo 32U4 from Linux.
What version of the Arduino IDE do you have, and how did you install it? If you have not done so already, could you try downloading Arduino 1.8.12 from the official Arduino download page and see if that version works for you?
Also, please try running sudo systemctl stop ModemManager
. This terminates ModemManager, a program that comes with Ubuntu which sometimes causes issues because it tries to connect to USB serial ports and send modem commands to them.
If doing those two things does not work, I would like to get more information about what is going wrong. Please upload a sketch using Windows to ensure that the Zumo has a valid sketch running on it. Then, in Linux, please open the Arduino IDE, open the “File” menu, select “Preferences”, check the “upload” checkbox next to “Show verbose output during:”, and then click “OK”. This enables verbose output during upload. Then, please attempt to upload a sketch to your Zumo, and copy and paste the entire output from the Arduino IDE so we can see more details about what is happening.
–David
I am running the latest version of Arduino IDE (1.8.12). Running sudo systemctl stop ModemManager
seemed to fix it for me mostly. The only thing is that occasionally uploading will produce an error such as:
avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied
Verbose output:
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/andrew/Downloads/arduino-1.8.12/hardware/tools/avr/etc/avrdude.conf"
User configuration file is "/home/andrew/.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
avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied
avrdude done. Thank you.
— or —
Found programmer: Id = "139 0 1"; type = 0
Software Version = 1.3; Hardware Version = 8.
avrdude: error: buffered memory access not supported. Maybe it isn't
a butterfly/AVR109 but a AVR910 device?
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
avrdude: error: programmer did not respond to command: leave prog mode
avrdude: error: programmer did not respond to command: exit bootloader
Verbose output:
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/andrew/Downloads/arduino-1.8.12/hardware/tools/avr/etc/avrdude.conf"
User configuration file is "/home/andrew/.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 = "138 0 1"; type = 0
Software Version = 1.3; Hardware Version = 9.
avrdude: error: buffered memory access not supported. Maybe it isn't
a butterfly/AVR109 but a AVR910 device?
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
avrdude: error: programmer did not respond to command: leave prog mode
avrdude: error: programmer did not respond to command: exit bootloader
The two errors don’t happen randomly. The permission denied error appears during a normal upload attempt while the programmer error occurs when re-attempting to upload right after a permission denied error when the LED is fading in and out as if its in bootloader mode. This is an issue I’ve seen some of my students encounter with their Zumos occasionally as well but so far they’ve been able to upload fine by just retrying a few times till it doesn’t give an error.
I am glad that stopping ModemManager is helping. To make sure it does not start up the next time you reboot, I recommend running:
sudo systemctl disable ModemManager
I tried to reproduce your problem today using Arduino 1.8.12 for 64-bit Linux on Ubuntu 18.04, with ModemManager stopped. I did see the “Permission denied” error happen once. I think this might be happening because AVRDUDE is running too soon after the new serial port for the bootloader has appeared, and the system has not had enough time to set up the permissions of the serial port.
It is probably possible to configure the Arduino IDE to delay a little bit before running AVRDUDE. I would try adding sleep 1 &&
at the beginning of the AVRDUDE command that the Arduino IDE runs, which is defined in hardware/arduino/avr/platform.txt, on the line that starts with “tools.avrdude.upload.pattern”. However, I have not tested this. If that does not work, it should at least be possible to replace the avrdude
executable with a shell script that delays before calling the real avrdude
.
For your other error, I suspect you are getting it because you tried to upload while the Zumo was already in bootloader mode. If the “Permission denied” error happens, it is best to wait 8 seconds before trying again so that the Zumo 32U4 can get out of bootloader mode and go back to running your sketch, which is the state the Arduino IDE expects it to be in when uploading. I suspect that AVRDUDE was talking to the sketch running on the Zumo, thinking that it was actually the bootloader, and that “138 0 1” is a fragment of some text that your sketch was trying to send with Serial.print
.
–David