Short Form
I need to be able to write a .hex file to my Leonardo via USB using the command line.
The Arduino IDE is able to do this, but I cannot.
It appears that the difference is that the Arduino IDE resets the Leonardo ("Forcing reset using 1200bps open/close ..."), but I cannot find ard-reset-arduino anywhere on my system.
How does the Arduino IDE do the reset? And how can I replicate that from the CLI?
Details
Here's what I see when the Arduino IDE writes to the Leonardo:
Global variables use 217 bytes (8%) of dynamic memory, leaving 2,343 bytes for local variables. Maximum is 2,560 bytes.
Forcing reset using 1200bps open/close on port /dev/cu.usbmodem1411
PORTS {/dev/cu.Bluetooth-Incoming-Port, /dev/cu.rdPhone-WirelessiAP, /dev/cu.usbmodem1411, /dev/tty.Bluetooth-Incoming-Port, /dev/tty.rdPhone-WirelessiAP, /dev/tty.usbmodem1411, } / {/dev/cu.Bluetooth-Incoming-Port, /dev/cu.rdPhone-WirelessiAP, /dev/cu.usbmodem1411, /dev/tty.Bluetooth-Incoming-Port, /dev/tty.rdPhone-WirelessiAP, /dev/tty.usbmodem1411, } => {}
<repeated 19 times>
PORTS {/dev/cu.Bluetooth-Incoming-Port, /dev/cu.rdPhone-WirelessiAP, /dev/cu.usbmodem1411, /dev/tty.Bluetooth-Incoming-Port, /dev/tty.rdPhone-WirelessiAP, /dev/tty.usbmodem1411, } / {/dev/cu.Bluetooth-Incoming-Port, /dev/cu.rdPhone-WirelessiAP, /dev/cu.usbmodem1411, /dev/tty.Bluetooth-Incoming-Port, /dev/tty.rdPhone-WirelessiAP, /dev/tty.usbmodem1411, } => {}
Uploading using selected port: /dev/cu.usbmodem1411
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega32u4 -cavr109 -P/dev/cu.usbmodem1411 -b57600 -D -Uflash:w:/var/folders/7x/bsz1mn9d5ps8pzs886s71d9m0000gq/T/arduino_build_917640/leds_test.ino.hex:i
avrdude: Version 6.3, compiled on Sep 12 2016 at 17:22:25
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
<eliding a bunch of lines>
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
<eliding more lines>
avrdude: verifying ...
avrdude: 9146 bytes of flash verified
avrdude done. Thank you.
When I try the same avrdude
command via the command line, it's a different story. (Note that I'm not resetting the Leonardo -- how to do that is the crux of my question!)
$ /Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega32u4 -cavr109 -P/dev/cu.usbmodem1411 -b57600 -D -Uflash:w:/var/folders/7x/bsz1mn9d5ps8pzs886s71d9m0000gq/T/arduino_build_917640/leds_test.ino.hex:i
avrdude: Version 6.3, compiled on Sep 12 2016 at 17:22:25
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
<eliding a bunch of lines>
Programmer Type : butterfly
Description : Atmel AppNote AVR109 Boot Loader
Connecting to programmer: .avrdude: Send: . [1b]
avrdude: Send: S [53]
avrdude: ser_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
<lots of sends and lots of programmer is not responding errors>