Flashing Arduino 101 from terminal/cmd

Hi, I am currently writing software, which should be capable of flashing an Arduino 101 board. I currently try to reproduce what the IDE does by using build-arduino to build the sketch, and then running the arduino101load (which in turn uses the provided dfu-util).

They both do their jobs well, but the arduino101load utility does not detect the Arduino 101 board and hits the wait timeout if I don't push the "master reset" button on the device manually when it scans for a device.

My guess is that Arduino IDE somehow reboots the board via USB (COM port, to be precise), but how does it do it? And how can I do the same?

I'm currently using windows and mac os x, but it needs to run on linux too.

For linux at least your life should be easy:

~/arduino-1.6.8/arduino --upload --board Intel:arc32:arduino_101 --port /dev/ttyACM0 ~/myDir/mySketch/mySketch.ino

However it sounds like you need/want control of the individual steps. The COM port baud rate is set to 1200 to force download mode.

Yes, you need to "touch" the port at 1200bps to trigger a reboot in download mode. The easiest way is to write a small program in a language without dependencies (eg golang) which opens/closes the port before trying the download. arduino101load sources are here if you want to hack them ;)

Here is the Python code I use to reset a board on Linux. Like Martino said, you just need to “touch” the port.

#!/usr/bin/python
# Script to reset Arduino 101 board
import serial
from commands import *

serialPath = '/dev/ttyACM0'

print "Resetting " + serialPath

mySerial = serial.Serial(serialPath, 1200)

mySerial.setDTR(level=False)
mySerial.close()
print "Reset Complete!"