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?
-
Enable verbose mode, program it once with the IDE, and copy the command line it uses.Chris Stratton– Chris Stratton2018年06月16日 01:30:07 +00:00Commented Jun 16, 2018 at 1:30
-
What is the IDE?Jonathan– Jonathan2018年06月16日 01:53:40 +00:00Commented 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.Jonathan– Jonathan2018年06月16日 01:58:48 +00:00Commented Jun 16, 2018 at 1:58
-
Also verbose modes -v, -vv, -vvv, and -vvvv don't really seem to affect anything.Jonathan– Jonathan2018年06月16日 02:02:52 +00:00Commented Jun 16, 2018 at 2:02
-
1You 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.Chris Stratton– Chris Stratton2018年06月16日 02:04:51 +00:00Commented Jun 16, 2018 at 2:04
2 Answers 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.
-
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.Jonathan– Jonathan2018年06月16日 13:41:05 +00:00Commented Jun 16, 2018 at 13:41 -
1The 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.Majenko– Majenko2018年06月16日 13:42:51 +00:00Commented Jun 16, 2018 at 13:42 -
That doesn't seem to help either, I'm afraid.Jonathan– Jonathan2018年06月16日 20:09:45 +00:00Commented Jun 16, 2018 at 20:09
-
1Have you had it working in the IDE at all?Majenko– Majenko2018年06月16日 20:10:33 +00:00Commented 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.)Jonathan– Jonathan2018年06月17日 15:22:09 +00:00Commented Jun 17, 2018 at 15:22
I had the same issue, and it was caused by udev, I found the answer here
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
-
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...codermonkeyfuel– codermonkeyfuel2019年02月24日 03:25:09 +00:00Commented Feb 24, 2019 at 3:25