Upload to Leonardo sometimes fails with Permission denied
- Dominant language
- Java
- Stars
- 14.6k
- Forks
- 7k
- PR merge metrics
- No merged PRs in 30d
Description
```
Forcing reset using 1200bps open/close on port /dev/ttyACM0
PORTS {/dev/ttyACM0, /dev/ttyS0, /dev/ttyS4, /dev/ttyS5, } / {/dev/ttyS0, /dev/ttyS4, /dev/ttyS5, } => {}
PORTS {/dev/ttyS0, /dev/ttyS4, /dev/ttyS5, } / {/dev/ttyACM0, /dev/ttyS0, /dev/ttyS4, /dev/ttyS5, } => {/dev/ttyACM0, }
Found upload port: /dev/ttyACM0
//bin/avrdude -C//etc/avrdude.conf -v -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D -Uflash:w:/tmp/arduino_build_862951/semaphore.ino.hex:i.
avrdude: Version 7.0
Copyright (c) Brian Dean, http://www.bdmicro.com/
Copyright (c) Joerg Wunsch
System wide configuration file is "//etc/avrdude.conf"
User configuration file is "/home/dimich/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/ttyACM0
Using Programmer : avr109
Overriding Baud Rate : 57600
avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied
avrdude: opening programmer "avr109" on port "/dev/ttyACM0" failed
```
This happens because udev applies permissions to device files non-atomically: first it creates /dev/ACM* with root:root ownership and then `GROUP="uucp"` is applied. When SerialUploader detects port appearence it invokes avrdude immediately, even if ownership/permissions aren't yet applied.
Possible solution is to wait for port is accessible, e.g. with `access(port, R_OK | W_OK)`.
Contributor guide
Research direction
Start at the SerialUploader port-detection and upload path described in the report, then reproduce an upload to a Leonardo on /dev/ttyACM0 under udev. Done means avrdude is not invoked until the port is readable and writable, so the upload no longer fails with Permission denied.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, linux
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100