5

I am trying to connect to an Arduino Leonardo from the command line using:

./avrdude -patmega32u4 -C../etc/avrdude.conf -cavr109 -P/dev/cu.usbmodem1421

I get a series of the following errors:

avrdude: butterfly_recv(): programmer is not responding

This seems to indicate that the board is not kicking into bootloader mode. I've tried to force bootloader mode by double tapping the reset button during upload, but to no avail.

How can I fix this?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Trevor Shaw
  • 123
  • 1
  • 10

2 Answers2

4

As per the page Arduino Leonardo upload from Makefile I need to trigger bootloader mode by making a serial connection with 1200 bit/s and then immediately disconnecting.

The reason I wasn't able to make this work by tapping the reset button is that the Leonardo often grabs a new serial port name when it resets, so I would enter bootloader successfully, but when I went to flash, the port in my command line was no longer valid.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Trevor Shaw
  • 123
  • 1
  • 10
0

As pointed out in the answer you have to first make a 1200bit/s connection and then disconnect, but the answer doesn't explain how to do this.

What I did was first uploaded a dummy program to my Leonardo in the Arduino IDE, making sure "verbose" mode was enabled for uploading in File -> Preferences. By "dummy" program I just mean anything that will successfully upload, let's say a program that is nothing but an empty setup() and loop() function.

Then scroll through the log and find the command it uses to upload.

Then create an "upload.sh" file and paste in that command, changing the ".hex" file to the file you want to upload.

Finally, add another line to the top of the file for making the temporary 1200bit/s connection, so when you run the script it will make the connection then immediately upload your file.

My script ended up looking something like this.

device=ACM0
stty -F /dev/tty$device 1200 cs8 -cstopb -parenb && echo -ne '\x00' > /dev/tty$device && sleep 1 && stty -F /dev/tty$device 0

"/home/primary/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude" "-C/home/primary/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega32u4 -cavr109 "-P/dev/ttyACM0" -b57600 -D "-Uflash:w:p4s.hex:i"

This worked successfully for me to send the "p4s.hex" file.

Change "device" to the tty device you're using and again the last line is copied from whatever your Arduino IDE is doing. It should already have the correct device name.

The first two lines again are just for making the temporary 1200bit/s connection and then immediately disconnecting.

amihart
  • 171
  • 1
  • 6