And, to confirm my suspicions, I was able to write a sketch to the Arduino if I manually hold the reset button and release just as the avrdude command is issued.
Code: Select all
pi@raspberrypi ~/arduino $ make upload
/usr/bin/avr-g++ -MM -mmcu=atmega328p -DF_CPU=8000000L -DARDUINO=100 -I. -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard -g -Os -w -Wall -ffunction-sections -fdata-sections -fno-exceptions build-cli/blink.cpp -MF build-cli/blink.d -MT build-cli/blink.o
cat build-cli/blink.d > build-cli/depends.mk
for STTYF in 'stty -F' 'stty --file' 'stty -f' 'stty <' ; \
do $STTYF /dev/tty >/dev/null 2>&1 && break ; \
done ; \
$STTYF /dev/ttyAMA0 hupcl ; \
(sleep 0.1 2>/dev/null || sleep 1) ; \
$STTYF /dev/ttyAMA0 -hupcl
/usr/bin/avr-g++ -c -mmcu=atmega328p -DF_CPU=8000000L -DARDUINO=100 -I. -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard -g -Os -w -Wall -ffunction-sections -fdata-sections -fno-exceptions build-cli/blink.cpp -o build-cli/blink.o
/usr/bin/avr-gcc -mmcu=atmega328p -Wl,--gc-sections -Os -o build-cli/arduino.elf build-cli/blink.o build-cli/libcore.a -lc -lm
/usr/bin/avr-objcopy -O ihex -R .eeprom build-cli/arduino.elf build-cli/arduino.hex
/usr/bin/avrdude -q -V -p atmega328p -C /etc/avrdude.conf -c arduino -b 57600 -P /dev/ttyAMA0 \
-U flash:w:build-cli/arduino.hex:i
avrdude-original: AVR device initialized and ready to accept instructions
avrdude-original: Device signature = 0x1e950f
avrdude-original: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude-original: erasing chip
avrdude-original: reading input file "build-cli/arduino.hex"
avrdude-original: writing flash (1078 bytes):
avrdude-original: 1078 bytes of flash written
avrdude-original: safemode: Fuses OK
avrdude-original done. Thank you.
This means I need to figure out why the autoreset code doesn't actually work. Still open to thoughts...
autoreset code:
https://github.com/deanmao/avrdude-rpi
Code: Select all
#!/usr/bin/python
import RPi.GPIO as GPIO
import sys, os, re, time, fcntl
fd = sys.stdin.fileno()
fl = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
GPIO.setmode(GPIO.BOARD)
dtr = re.compile('.+TIOCM_DTR.+')
start = time.time()
def reset():
pin = 27
GPIO.setup(pin, GPIO.OUT)
GPIO.output(pin, GPIO.HIGH)
time.sleep(0.12)
GPIO.output(pin, GPIO.LOW)
def process():
while True:
try:
duration = time.time() - start
input = sys.stdin.readline().strip()
if dtr.match(input):
reset()
return
elif duration > 5000:
return
except:
continue
process()
print "done with autoreset"