You are not logged in.
Hello all,
I use an Arduino, an open-source microcontroller platform, which sits on /dev/ttyUSB0 and spits out data over the serial port. It would be very useful to me to be able to access the arduino without having to be root or to sudo. As it is, here's what happens:
[user@computer ~]$ minicom -D /dev/ttyUSB0 -b 57600
minicom: cannot open /dev/ttyUSB0: Permission denied
[user@computer ~]$ sudo minicom -D /dev/ttyUSB0 -b 57600
Welcome to minicom 2.5
OPTIONS: I18n
Compiled on Feb 2 2011, 18:45:31.
Port /dev/ttyUSB0
Press CTRL-A Z for help on special keys
GO,1023,353,352,255,0,1,,377,0,505,ST
GO,1023,297,295,255,0,1,,204,0,505,ST
GO,1023,387,386,255,0,1,,417,0,506,ST
..... and so on.
How can I fix this?
Thanks!
Last edited by tirezo (2011-07-07 19:43:59)
Offline
By the way, here's ls -l for the device:
[user@computer ~]$ ls -l /dev/ | grep ttyUSB
crw-rw---- 1 root uucp 188, 0 Jul 6 15:22 ttyUSB0
I tried adding myself to the uucp group and it still didn't work:
[user@computer ~]$ groups user
lp wheel uucp games video audio optical storage scanner power users
Offline
okay, this worked:
sudo chmod 666 /dev/ttyUSB0
But how can I have arch do this automatically for all USB devices?
Last edited by tirezo (2011-07-06 19:40:59)
Offline
I think you want to create a udev rule.
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
Thanks ewaller! I had no idea what udev rules were.
For anyone having trouble with arduino permissions on arch, add the following 2 lines to this file:
/etc/udev/rules.d/50-embedded_devices.rules
SUBSYSTEMS="usb", ATTRS{product}== "Arduino Uno", GROUP="users", MODE="0666"
SUBSYSTEMS="usb", ATTRS{product}== "FT232R USB UART", GROUP="users", MODE="0666"
This will let you use the arduino uno and duemilanove without having to worry about permissions (I haven't tested any other versions)
****UPDATE: This doesn't work.
Last edited by tirezo (2011-07-07 19:45:04)
Offline
I had the same problem and after much mucking around in udevadm, found out why this wasn't working; it should be SUBSYSTEMS=="usb", not single =. Udev considered this file unparseable.
SUBSYSTEMS=="usb", ATTRS{product}== "Arduino Uno", GROUP="users", MODE="0666"
SUBSYSTEMS=="usb", ATTRS{product}== "FT232R USB UART", GROUP="users", MODE="0666"
I found you can also avoid needing a reboot/replug by running:
$sudo udevadm trigger
(Tested on Mint 17.1)
Offline
Not sure if you need it for the Arduino, just the USB UART serial adapter.
I may have to CONSOLE you about your usage of ridiculously easy graphical interfaces...
Look ma, no mouse.
Offline
Easier than the udev rule would just be to add your user to the uucp group as the device files already have group r/w access.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Yup, great call Trilby.
# usermod -a -G uucp yourregusername
Offline
As to why adding oneself to uucp group failed to solve permission issue for OP is probably because he forgot to relog his user.
Wiki also suggest that if adding a user to uucp is still causing problems, try adding the user to lock group also.
Offline
None of this works for me. I added myself to
uccp
a long time ago and have been quite happy using my arduino with Arch. All of the sudden (there was a system upgrade) it stopped working.
Now I get the error message:
avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied
Problem uploading to board.
Whenever I try to upload. I added myself to
lock
and re-logged in. Still doesn't work. When running the Arduino IDE as root, however, there is no issue. It works fine.
Other strange fact. I changed the permission mode of
/dev/ttyACM0
to 666, but after trying to upload to the board the permission mode reverts to 660, i.e.
crw-rw----
Any suggestions? I didn't make a udev rule yet, but I don't think it should be necessary.
Offline
What type of Arduino is it? Some flavors do a USB disconnect when the Arduino's processor is reset -- Leonardo and others that use the Atmel's intrinsic USB interface do this. Edit: When it reconnects, the permissions reset (end edit)
Which version of AVRDUDE are you using? A recent version had issues with Arduino and needed downgradng.
What is the output of groups
Last edited by ewaller (2016-01-10 05:04:40)
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
@ tirezo, can you try changing permission of minicom, so that when it is run by normal user it runs with root previlages,
sudo chmod u+s /usr/bin/minicom
assuming minicom is in /usr/bin, this works with wvdial when I use it for my usb modem.
Arch is home!
https://github.com/Docbroke
Offline
Thanks for the quick reply, ewaller!
What type of Arduino is it?
It's an Arduino Esplora
Some flavors do a USB disconnect when the Arduino's processor is reset -- Leonardo and others that use the Atmel's intrinsic USB interface do this. Edit: When it reconnects, the permissions reset (end edit)
Right, the Esplora is based on Leonardo, I believe.
Which version of AVRDUDE are you using? A recent version had issues with Arduino and needed downgradng.
What is the output of groups
My avrdude version is 1:6.1-1 (Edit: This version was installed on December 9 2015, and uploading worked fine then. I downgraded to avrdude 6.1-1 but there was no imporvement.)
Groups output: tty wheel uucp lock audio vboxusers nick (n.b. my username is nick)
I'm using the latest version (as of January 9th 2016) of the Arduino IDE and also I can upload to my board when running the IDE as root.
Last edited by NickTouik (2016-01-10 14:50:09)
Offline
What is the output of
ls -l /dev/ttyACM0
Offline
It works here....
ewaller@turing ~ 1096 %pacman -Qi arduino
Name : arduino
Version : 1:1.6.7-1
Description : Arduino prototyping platform SDK
Architecture : x86_64
URL : http://arduino.cc/en/Main/Software
Licenses : GPL LGPL
Groups : None
Provides : None
Depends On : gtk2 libusb-compat java-runtime desktop-file-utils giflib avrdude
Optional Deps : None
Required By : None
Optional For : None
Conflicts With : None
Replaces : None
Installed Size : 402.84 MiB
Packager : Unknown Packager
Build Date : Sat 02 Jan 2016 09:58:16 AM PST
Install Date : Sat 02 Jan 2016 10:00:43 AM PST
Install Reason : Explicitly installed
Install Script : Yes
Validated By : None
ewaller@turing ~ 1097 %pacman -Qi avrdude
Name : avrdude
Version : 1:6.1-1
Description : Download/upload/manipulate the ROM and EEPROM contents of AVR microcontrollers
Architecture : x86_64
URL : http://www.nongnu.org/avrdude/
Licenses : GPL
Groups : None
Provides : None
Depends On : readline libftdi libusb-compat elfutils
Optional Deps : None
Required By : arduino
Optional For : None
Conflicts With : None
Replaces : None
Installed Size : 950.00 KiB
Packager : Anatol Pomozov <anatol.pomozov@gmail.com>
Build Date : Wed 09 Dec 2015 01:04:02 PM PST
Install Date : Thu 10 Dec 2015 08:03:58 AM PST
Install Reason : Installed as a dependency for another package
Install Script : No
Validated By : Signature
ewaller@turing ~ 1098 %ll /dev/ttyACM?
crw-rw---- 1 root uucp 166, 1 Jan 10 08:33 /dev/ttyACM1
ewaller@turing ~ 1099 %
As a sanity check, is the group of the device node uucp?
Edit: I just saw bstaletic's post -- I think we are on the same track.
Last edited by ewaller (2016-01-10 16:52:03)
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
Everything looks like it checks out:
ls -l ttyACM0
crw-rw---- 1 root uucp 166, 0 Jan 10 20:32 ttyACM0
and
[nick@TaMereVIII dev]$ pacman -Qi arduino
Name : arduino
Version : 1:1.6.7-1
Description : Arduino prototyping platform SDK
Architecture : x86_64
URL : http://arduino.cc/en/Main/Software
Licenses : GPL LGPL
Groups : None
Provides : None
Depends On : gtk2 libusb-compat java-runtime desktop-file-utils giflib
avrdude
Optional Deps : None
Required By : None
Optional For : None
Conflicts With : None
Replaces : None
Installed Size : 402.84 MiB
Packager : Unknown Packager
Build Date : Sat 09 Jan 2016 11:02:35 PM EST
Install Date : Sat 09 Jan 2016 11:19:22 PM EST
Install Reason : Explicitly installed
Install Script : Yes
Validated By : None
[nick@TaMereVIII dev]$ pacman -Qi avrdude
Name : avrdude
Version : 1:6.1-1
Description : Download/upload/manipulate the ROM and EEPROM contents of AVR
microcontrollers
Architecture : x86_64
URL : http://www.nongnu.org/avrdude/
Licenses : GPL
Groups : None
Provides : None
Depends On : readline libftdi libusb-compat elfutils
Optional Deps : None
Required By : arduino
Optional For : None
Conflicts With : None
Replaces : None
Installed Size : 950.00 KiB
Packager : Anatol Pomozov <anatol.pomozov@gmail.com>
Build Date : Wed 09 Dec 2015 04:04:02 PM EST
Install Date : Sun 10 Jan 2016 09:50:40 AM EST
Install Reason : Installed as a dependency for another package
Install Script : No
Validated By : None
This is really frustrating. Works fine as root, and I think the permission problem is subtle because when I upload, I get the permission error but my Arduino also resets, so something is going through.
Edit: I also rebooted, deleted the ~/Arduino and ~/.arduino15 directories, to remove any options. Still no luck. I also tried chowning ttyACM0 to myself, but it resets to belonging to root.
Last edited by NickTouik (2016-01-11 01:49:12)
Offline
Exactly the same problem here, I used dirty fix
sudo chmod u+s /usr/bin/avrdude
Offline
Thanks alot Kostafun. That sure is dirty, but totally works! I didn't know about you could set programs to run that way.
I have two questions:
1) How do I revert avrdude to its original privilege settings?
2) How insecure is this? Is it possible to execute arbitrary code or read/write to the file system via avrdude?
Offline
What that does is set the SUID bit. It causes the program to run with the privileges of the files's owner (root) rather than the user's. Clear the bit with chmod u-s /usr/bin/avrdude ( I think)
It is not too bad WRT security. Something still smells fishy as to why it does not work without this hammer.
Last edited by ewaller (2016-01-12 04:50:09)
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
@NickTouik, I had posted similar solution in my previous post.
"chmod u+s" adds s to root permission, you can check current permissions with "ls -l /usr/bin/avrdude", this s permission can be removed with below command
sudo chmod u-s /usr/bin/avrdude
Bit more on that bit, 'u' is file owner which is root in this case I believe, with u+s any user can execute file as owner of that file. You can change other permission similarly using u(for owner), g(for group), o(for other), while permissions are w(write),r(read),x(execute). '+' to add and '-' to remove permissions. so 'chmod g+wx' gives write and execute permissions to the group that owns the file.
regarding your second question, with this any user can execute avrdude with root permissions, but anyway that is what you want, isn't it?
-regards
Last edited by Docbroke (2016-01-12 05:11:25)
Arch is home!
https://github.com/Docbroke
Offline
Thank you for your responses and edifying explanations.
@Docbroke: I now understand your previous response . As for my second question, generally if some program has this type of elevated privilege there should be a good reason e.g. sudo. To be honest, I'm not sure what avrdude does exactly nor what its scope is; so, as a sensible user, I shouldn't just leave it "u+s". I'll probably write a script to switch the permission for just when I need to use it. Then again if avrdude can only write to attached USB devices, then who cares, right?
@ewaller: I aggree this isn't completely satisfactory. Feel free to propose queries to my system to find the real problem.
Last edited by NickTouik (2016-01-12 14:10:54)
Offline
To be honest, I'm not sure what avrdude does exactly nor what its scope is; ...
Thus spake man avrdude
AVRDUDE(1) BSD General Commands Manual AVRDUDE(1)
NAME
avrdude — driver program for ``simple'' Atmel AVR MCU programmer
SYNOPSIS
avrdude -p partno [-b baudrate] [-B bitclock] [-c programmer-id]
[-C config-file] [-D] [-e] [-E exitspec[,exitspec]] [-F]
[-i delay] [-n -logfile] [-n] [-O] [-P port] [-q] [-s] [-t] [-u]
[-U memtype:op:filename:filefmt] [-v] [-x extended_param] [-V]
DESCRIPTION
Avrdude is a program for downloading code and data to Atmel AVR microcon‐
trollers. Avrdude supports Atmel's STK500 programmer, Atmel's AVRISP and
AVRISP mkII devices, Atmel's STK600, Atmel's JTAG ICE (mkI, mkII and 3,
the latter two also in ISP mode), programmers complying to AppNote AVR910
and AVR109 (including the Butterfly), as well as a simple hard-wired pro‐
grammer connected directly to a ppi(4) or parport(4) parallel port, or to
a standard serial port. In the simplest case, the hardware consists just
of a cable connecting the respective AVR signal lines to the parallel
port.
.....8<.................8<...........
The Arduino (which is very similar to the STK500 1.x) is supported via
its own programmer type specification ``arduino''.
.....8<.................8<...........
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
hi
i run arduino ide with gksudo. AND upload code is no error.
in desktop right click icon arduino ide / and open it with gedit / then add "gksudo -k -u root" to first "Exec" line.
[Desktop Entry]
Type=Application
Name=Arduino IDE
GenericName=Arduino IDE
Comment=Open-source electronics prototyping platform
Exec=gksudo -k -u root /media/ProgLinux/arduino64linux/arduino-1.6.9/arduino
Icon=arduino-arduinoide
Terminal=false
Categories=Development;IDE;Electronics;
MimeType=text/x-arduino
Keywords=embedded electronics;electronics;avr;microcontroller;
StartupWMClass=processing-app-Base
Last edited by eshahnazi (2016-09-28 18:48:08)
Offline
Hi,
I run in the same "time waste hole".
I ask myself is it a bug?
Where:
$ ls -al /dev/ttyACM0
crw-rw---- 1 root uucp 166, 0 Jun 29 09:07 /dev/ttyACM0
As i understand uucp also root do have a write permission. Add I add $USER to group uucp. But the membership doesn't change the right to write.
chmod a+rw /dev/ttyACM0 does give write pemission until a reconnection.
I also create udev without success.
I also ask myself: Is there a second membership on arch needed?
On debian based distribution, add a $USER to group dialout and everything works fine as expected.
After 2 days, I realize i can't fix my avrdude write permission issue on arch. Sadly I give up and use a other distribution to program the ATmega32U4 Pro Micro via arduino ide.
Offline