1

I have a hand-wired keyboard that uses a Pro Micro board, with an ATmega32u4 chip. I can't seem to flash firmware on it. The commands I've been trying are variations of:

avrdude -p m32U4 -P /dev/ttyACM0 -c avr109 -U flash:w:atreus62.hex

The errors I've been getting begin:

Writing | #######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: write block
 ***failed; 
 ***failed; 
 ***failed; 
 ***failed; 

And end:

#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.16s
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

I'm on Arch Linux. Any ideas?

asked Jun 16, 2018 at 0:45
9
  • Enable verbose mode, program it once with the IDE, and copy the command line it uses. Commented Jun 16, 2018 at 1:30
  • What is the IDE? Commented Jun 16, 2018 at 1:53
  • And what do you mean by "program it"? Could you just tell me what the avrdude command is? I don't have any IDE installed. Commented Jun 16, 2018 at 1:58
  • Also verbose modes -v, -vv, -vvv, and -vvvv don't really seem to affect anything. Commented Jun 16, 2018 at 2:02
  • 1
    You are asking a question on the Arduino site, presumably you are familiar with the Arduino tools? If not, give that a try first to validate your hardware and tools setup (before you try to do things the hard way. Use the avrdude and configuration file for it that ships with a modern Arduino IDE version, and let the IDE drive it the first time, with verbose mode selected in the dropdown menu, so you see the suitable command. Commented Jun 16, 2018 at 2:04

2 Answers 2

2

There's two stages to uploading a hex file to a USB-based Arduino - and you're only doing the second stage.

The first stage is to reset the board into the bootloader so it can accept the instructions from the second stage. The IDE normally does that manually for you when you hit the UPLOAD button.

The way these boards are reset is to first open the CDC/ACM port and set the baud rate to 1200, then close the port again. That triggers the code to reset the board into the bootloader.

You can probably do it using the stty tool in Linux:

$ stty -F /dev/ttyACM0 speed 1200
$ stty -F /dev/ttyACM0 speed 115200
$ avrdude -p m32U4 -P /dev/ttyACM0 -c avr109 -U flash:w:atreus62.hex

The second stty may not actually be needed, but it's good to reset the baud rate to a normal value ready for uploading. I don't have a board to hand right now to test it though.

answered Jun 16, 2018 at 11:49
11
  • Those commands don't seem to help, sadly. They both return 9600, if that's at all helpful. I'm still getting "programmer did not respond" errors. Commented Jun 16, 2018 at 13:41
  • 1
    The return value is the value it was before changing it. The second should return 1200 not 9600. You can try using stty -F /dev/ttyACM0 ospeed 1200 ispeed 1200 instead. Commented Jun 16, 2018 at 13:42
  • That doesn't seem to help either, I'm afraid. Commented Jun 16, 2018 at 20:09
  • 1
    Have you had it working in the IDE at all? Commented Jun 16, 2018 at 20:10
  • I'm at a loss for how to upload .hex files to a chip using the IDE. (And furthermore the IDE is almost totally useless to me, since the UI isn't HiDPI-friendly.) Commented Jun 17, 2018 at 15:22
2

I had the same issue, and it was caused by udev, I found the answer here

It's some obscure bug

Tweaking udev rules solved the problem for me, now all is good, here is the procedure: https://learn.adafruit.com/adafruit-arduino-ide-setup/linux-setup#udev-rules

answered Dec 27, 2018 at 16:15
1
  • Had the same issue, and this fixed it for me! (mostly - I still had to use the stty commands from Majenko's answer, and run the upload a couple of times in order to get it working... but it worked!) It's a bit difficult to find this answer... Commented Feb 24, 2019 at 3:25

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.