Help with udev rules for arduboy


(Brian) #1

I’m trying to flash a *.hex file to the Arduboy on Ubuntu 18.04.

$ groups
brian adm tty dialout cdrom sudo dip plugdev lpadmin sambashare libvirt vboxusers

$ ls -l /dev/ttyACM0 
crw-rw-rw- 1 root dialout 166, 0 Jan 22 22:55 /dev/ttyACM0

$ cat /etc/udev/rules.d/51-arduboy.rules 
SUBSYSTEM=="usb",  ATTRS{idVendor}=="2341", ATTRS{idProduct}=="[80]036", GROUP="dialout", MODE="0666"
KERNEL=="ttyACM*", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="[80]036", GROUP="dialout", MODE="0666"

$ dmesg | tail -n 6
[ 1221.094323] usb 1-1.1: new full-speed USB device number 25 using xhci_hcd
[ 1221.189285] usb 1-1.1: New USB device found, idVendor=2341, idProduct=8036
[ 1221.189293] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1221.189298] usb 1-1.1: Product: Arduino Leonardo
[ 1221.189303] usb 1-1.1: Manufacturer: Arduino LLC
[ 1221.192643] cdc_acm 1-1.1:1.0: ttyACM0: USB ACM device

However, upload still fails with a permission denied error:

$ python uploader.py ~/arduboy/crait/MidnightWild.arduboy 

Arduboy python uploader v1.1 by Mr.Blinky April - June 2018

Loading "MidnightWild.arduboy"
Found Arduino Leonardo at port /dev/ttyACM0
Selecting bootloader mode...
Found Arduino Leonardo at port /dev/ttyACM0
Traceback (most recent call last):
  File "uploader.py", line 177, in <module>
    bootloaderStart()      
  File "uploader.py", line 80, in bootloaderStart
    bootloader = Serial(port,57600)
  File "/home/brian/.local/lib/python2.7/site-packages/serial/serialutil.py", line 240, in __init__
    self.open()
  File "/home/brian/.local/lib/python2.7/site-packages/serial/serialposix.py", line 268, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 13] could not open port /dev/ttyACM0: [Errno 13] Permission denied: '/dev/ttyACM0'

I noticed that when the device is put into bootloader mode, dmesg shows this:

[ 1403.438342] usb 1-1.1: USB disconnect, device number 25
[ 1403.656267] usb 1-1.1: new full-speed USB device number 26 using xhci_hcd
[ 1403.746047] usb 1-1.1: New USB device found, idVendor=2341, idProduct=0036
[ 1403.746049] usb 1-1.1: New USB device strings: Mfr=2, Product=1, SerialNumber=0
[ 1403.746050] usb 1-1.1: Product: Arduino Leonardo
[ 1403.746051] usb 1-1.1: Manufacturer: Arduino LLC
[ 1403.747446] cdc_acm 1-1.1:1.0: ttyACM0: USB ACM device
[ 1411.630520] usb 1-1.1: USB disconnect, device number 26
[ 1411.817200] usb 1-1.1: new full-speed USB device number 27 using xhci_hcd
[ 1411.909194] usb 1-1.1: New USB device found, idVendor=2341, idProduct=8036
[ 1411.909202] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1411.909209] usb 1-1.1: Product: Arduino Leonardo
[ 1411.909213] usb 1-1.1: Manufacturer: Arduino LLC
[ 1411.911382] cdc_acm 1-1.1:1.0: ttyACM0: USB ACM device

So I suspect when the device is reconnected, it’s setup with the wrong permissions, which is why the write fails. Though I’m not sure what additional udev-fu I need to make it work. Any suggestions?

Thanks!


#2

I’m having a similar issue with ACM0. I was going to suggest dialout but it seems you’re in that group already. Just in case you do need to restart your session for group changes to be in effect. From what I’ve found there seems to be some chance with whether or not ACM0 wants to cooperate. My device starts to flash and then falls midway and soft bricks.

Try different usb ports, USB2 over USB3 or C. I found one thread that implied it might be a bug in the IDE but you’re using the python script.

There’s a few other methods you could try besides the IDE and script. Building games from the command line under Linux

I also suggest collecting your tears of frustration and offering them to linus in hopes of a random update making it suddenly work.


(Scott) #3

I can’t say for sure with Ubuntu 18.04 but with 16.04 I had to disable Modem Manager.


(Brian) #4

Thanks. Yeah I had already uninstalled modem manager prior to that post (sudo apt-get remove --purge modemmanager).

I also tried the arduino IDE but it seems that won’t let me upload a hex file directly. It seems to only work for building from a sketch, which isn’t what I want. I just wanted to upload things, not worry about trying to get them to build.


(Scott) #5

But can you upload a compiled sketch using the IDE?


(Brian) #6

Yes, that seems to work.


(Brian) #7

Oh. Interesting. It looks like that script is a little too eager to get the job done - the device probably hasn’t settled (and had udev rules applied) by the time the script finds it and tries to connect.

See this line:

If I change it to sleep 2 seconds instead of 0.1, then it works.

I also tried 0.5s, but that did not work, and my arduboy seems to be stuck now - it doesn’t turn on.

Update: Seems this post got it working again: Arduboy died - Only red led on when plugged

@Mr.Blinky