No Programming via Native USB port possible on Linux

Hi,

maybe this issue was already discussed but I did not find anything.

I am using Arduino 1.5.6-r2 Beta on Linux Mint 15. I tried to flash my sketch via the native USB port of the Due but it does not work (No device found on ttyACM0). There is already a sketch flashed via programming port, so the USB 1200Baud hack is already in there. I tried the same on Windows 7 and it works. Is it a problem of the Beta version on Linux? Can someone try this with his Due?

best regards

What happens, when you start
udevadm monitor
in a terminal window and than connect the DUE?

Which /dev/tty* device will be assigned to the DUE, if there is any.
Furthermore which ownership/access mode has that tty-device?
In most Linux distributions you need to add your user to the group "dialout" , that you have access to the tty-device.

udevadm monitor says:

KERNEL[34873.505350] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3 (usb)
KERNEL[34873.505738] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.0 (usb)
KERNEL[34873.506049] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.0/tty/ttyACM0 (tty)
KERNEL[34873.506101] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.1 (usb)
KERNEL[34873.506173] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.2 (usb)
KERNEL[34873.506476] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.2/0003:2341:003E.0011 (hid)
KERNEL[34873.507029] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.2/input/input28 (input)
KERNEL[34873.507114] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.2/input/input28/mouse2 (input)
KERNEL[34873.507239] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.2/input/input28/event14 (input)
KERNEL[34873.507381] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.2/0003:2341:003E.0011/hidraw/hidraw2 (hidraw)
UDEV  [34873.513783] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3 (usb)
UDEV  [34873.515129] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.0 (usb)
UDEV  [34873.515511] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.1 (usb)
UDEV  [34873.515821] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.2 (usb)
UDEV  [34873.517626] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.2/0003:2341:003E.0011 (hid)
UDEV  [34873.519118] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.2/0003:2341:003E.0011/hidraw/hidraw2 (hidraw)
UDEV  [34873.521323] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.2/input/input28 (input)
UDEV  [34873.523659] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.2/input/input28/mouse2 (input)
UDEV  [34873.523940] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.2/input/input28/event14 (input)
UDEV  [34873.532082] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.0/tty/ttyACM0 (tty)

ownership/access mode: crw-rw---- 1 root dialout 166, 1 Apr 23 18:34 /dev/ttyACM0
my groups: myname : myname adm dialout fax cdrom floppy tape sudo audio dip video plugdev fuse lpadmin scanner sambashare

If I try to upload the sketch I get the following message:

Der Sketch verwendet 53.888 Bytes (10%) des Programmspeicherplatzes. Das Maximum sind 524.288 Bytes.
Erzwinge Reset durch Öffnen/Schließen mit 1200bps auf dem Port/dev/ttyACM0
PORTS {/dev/ttyACM0, } / {} => {}
PORTS {} / {} => {}
PORTS {} / {/dev/ttyACM0, } => {/dev/ttyACM0, }
Found upload port: /dev/ttyACM0
/opt/arduino-1.5.6-r2/hardware/tools/bossac -i -d --port=ttyACM0 -U true -e -w -v -b /tmp/build492793706391964386.tmp/AoControlWPS.cpp.bin -R 
No device found on ttyACM0

OK, with the output from udevadm it is visible, that

  • The device is recognized
  • /dev/ttyACM0 is the right device
  • an Arduino-Sketch is loaded

When the DUE is erased, the output would look like:

KERNEL[584.788164] add      /devices/pci0000:00/0000:00:06.0/usb1/1-2 (usb)
KERNEL[584.789848] add      /devices/pci0000:00/0000:00:06.0/usb1/1-2/1-2:1.0 (usb)
KERNEL[584.795772] add      /devices/pci0000:00/0000:00:06.0/usb1/1-2/1-2:1.0/tty/ttyACM0 (tty)
KERNEL[584.795805] add      /devices/pci0000:00/0000:00:06.0/usb1/1-2/1-2:1.1 (usb)
UDEV  [584.798089] add      /devices/pci0000:00/0000:00:06.0/usb1/1-2 (usb)
UDEV  [584.798120] add      /devices/pci0000:00/0000:00:06.0/usb1/1-2/1-2:1.1 (usb)
UDEV  [584.798138] add      /devices/pci0000:00/0000:00:06.0/usb1/1-2/1-2:1.0 (usb)
UDEV  [584.800642] add      /devices/pci0000:00/0000:00:06.0/usb1/1-2/1-2:1.0/tty/ttyACM0 (tty)

The access-rights are looking good as well, the device is owned by root:dialout and your account is in the group dialout.

Now lets look some more in the details:

In one terminal window you have still udevadm monitor running.
In a second window you enter: stty -F /dev/ttyACM0 1200

Now you should see, that the HID devices dissappear. When you now reset the DUE, the output should look like as my example above, as the GPNVM bits are set to boot SAM-BA

If that is not working, something is weird with your sketch, as the serial interrupt-handler is not invoked. If that is the case, press ERASE followed by an reset and try to load the sketch again.

If uploading works, when you pressed ERASE before, the problem is somewhere in your sketch. Uploading can only work, when the DUE gets in SAM-BA mode, which needs either sketch-interaction or manual erase. That is the main difference to the programming port, where the 16U2 triggers the erase and reset-pins, even when the sam3x8e hangs.

If the reboot into SAM-BA mode works, and upload is still not possible, you need to check the core SAM-BA communication.
First call bossac from a terminal window:
/opt/arduino-1.5.6/hardware/tools/bossac -i
Output should look like:

Device found on ttyACM0
Device       : ATSAM3X8
Chip ID      : 285e0a60
Version      : v1.1 Dec 15 2010 19:25:04
Address      : 524288
Pages        : 2048
Page Size    : 256 bytes
Total Size   : 512KB
Planes       : 2
Lock Regions : 32
Locked       : none
Security     : false
Boot Flash   : false

If that does not work, use picocom (or any other terminal program like minicom)
picocom -b 9600 -p n -d 8 /dev/ttyACM0
In the terminal window type:
T#
V#
and the output should look like:

v1.1 Dec 15 2010 19:25:04

Leave picocom with Ctrl-A Ctrl-X
If that works and bossac does not, it might be an issue with the serial speed over USB (port, cabling, drivers)
The terminal test used a lower speed than bossac.

One situation, where I found that behaviour is, when I run linux as virtual machine in VMWARE and Virtualbox. Configuring USB as 1.1 in the virtual machine setup fixes that problem.


One point I have not mentioned: It can also happen, that the erased arduino is not recognized, as in that case it identifies itself with the Atmel VID:PID (03EB:6124) instead of the Arduino . However all kernels knowing how to handle Arduino VID:PID should know about the Atmel ones. But it is worth to mention, taht this could also be an issue.

Hi,

thanks for your extensive help!

If I type stty -F /dev/ttyACM0 1200
then udevadm outputs:

KERNEL[20012.111931] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.0/tty/ttyACM0 (tty)
KERNEL[20012.112021] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.0 (usb)
KERNEL[20012.112118] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.1 (usb)
UDEV  [20012.112896] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.1 (usb)
UDEV  [20012.113020] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.0/tty/ttyACM0 (tty)
UDEV  [20012.113649] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.0 (usb)
KERNEL[20012.124307] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.2/input/input34/mouse2 (input)
UDEV  [20012.125135] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.2/input/input34/mouse2 (input)
KERNEL[20012.128342] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.2/input/input34/event14 (input)
UDEV  [20012.129118] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.2/input/input34/event14 (input)
KERNEL[20012.132240] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.2/input/input34 (input)
KERNEL[20012.132356] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.2/0003:2341:003E.0017/hidraw/hidraw2 (hidraw)
KERNEL[20012.132414] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.2/0003:2341:003E.0017 (hid)
KERNEL[20012.132446] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.2 (usb)
KERNEL[20012.132943] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-4 (usb)
UDEV  [20012.133242] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.2/input/input34 (input)
UDEV  [20012.133295] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.2/0003:2341:003E.0017/hidraw/hidraw2 (hidraw)
UDEV  [20012.133866] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.2/0003:2341:003E.0017 (hid)
UDEV  [20012.134354] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.2 (usb)
UDEV  [20012.135009] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-4 (usb)
KERNEL[20012.485016] add      /devices/pci0000:00/0000:00:14.0/usb3/3-4 (usb)
KERNEL[20012.485430] add      /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.0 (usb)
KERNEL[20012.485738] add      /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.0/tty/ttyACM0 (tty)
KERNEL[20012.485779] add      /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.1 (usb)
UDEV  [20012.488233] add      /devices/pci0000:00/0000:00:14.0/usb3/3-4 (usb)
UDEV  [20012.489582] add      /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.1 (usb)
UDEV  [20012.489651] add      /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.0 (usb)
UDEV  [20012.493646] add      /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.0/tty/ttyACM0 (tty)

So this looks good, but If I try to open the port I get the following:

$ picocom -b 9600  -p n -d 8 /dev/ttyACM0
picocom v1.7

port is        : /dev/ttyACM0
flowcontrol    : none
baudrate is    : 9600
parity is      : none
databits are   : 8
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv
imap is        : 
omap is        : 
emap is        : crcrlf,delbs,


FATAL: cannot open /dev/ttyACM0: Device or resource busy

One time it worked, but mostly not. I do not know why he thinks the resource is busy?

Now it becomes totally weird. It seems that the device needs up to 20s to come up. Look at this. I tried bossac every 5s:

$ stty -F /dev/ttyACM0 1200 
$ /opt/arduino-1.5.6-r2/hardware/tools/bossac -i
Auto scan for device failed
Try specifying a serial port with the '-p' option
$ /opt/arduino-1.5.6-r2/hardware/tools/bossac -i
Auto scan for device failed
Try specifying a serial port with the '-p' option
$ /opt/arduino-1.5.6-r2/hardware/tools/bossac -i
Auto scan for device failed
Try specifying a serial port with the '-p' option
$ /opt/arduino-1.5.6-r2/hardware/tools/bossac -i
Auto scan for device failed
Try specifying a serial port with the '-p' option
$ /opt/arduino-1.5.6-r2/hardware/tools/bossac -i
Device found on ttyACM0
Device       : ATSAM3X8
Chip ID      : 285e0a60
Version      : v1.1 Dec 15 2010 19:25:04
Address      : 524288
Pages        : 2048
Page Size    : 256 bytes
Total Size   : 512KB
Planes       : 2
Lock Regions : 32
Locked       : none
Security     : false
Boot Flash   : false

As you can see. After 20s I get a connection. Huh??

Are you running Linux on bare metal or in a virtual system?
As I wrote, I have seen this behavior a lot in virtual environments. On bare metal I would try to use another cable as a first try.
It looks like, that the core SAM-BA connection is more timing critical then the 16U2 programming port connection.

It is a bare Linux Mint 15 Mate, 64bit running on a Lenovo Y510P.

I tried different cables and it is always the same. It needs up to 30s until the port can be opened from picocom or bossac after opening and closing with 1200baud. It is weird because the port is available instantly, but can not be opened.

Do you have the modemmanager running?
If so, disable that.

Furthermore do an lsof | grep ttyACM to see, if other processes are blocking the device!

how can I stop modem-manager? I think it is running

$ ps aux | grep modem
root     14809  0.3  0.0  83412  3432 ?        S    17:00   0:00 /usr/sbin/modem-manager
lsof | grep ttyACM

returns nothing in between the 30s, where the port can not be opened.

service modemmanager stop

and if you don't need it: apt-get remove modemmanager

any success?

Great!! Now it works. After uninstalling modemmanager there is no more delay.
Thanks a lot for your help!

Do you know why modemmanager causes this behavior?

Because modem-manager listens on the DBUS if serial devices may become available. If one device is detected, which could be an modem, the modemmanager tries to identify and initialize that modem. When you told about that ~ 30s period it was suddenly clear.
I could have asked the question more early, but as I don't install modemmanager at all, I went that way down, I had to go myself.

Sorry for leading the long way round!

No problem, the long way was good to learn new Linux command line things :slight_smile:
Thanks a lot again!