- Error opening serial port (Linux)
- Overview
- How to set serial port permissions
- Как подключиться к плате через переходник USB-UART
- Fix serial port permission denied errors on Linux
- plink Unable to open serial port
- Configuration:
- Problem
- 1 Answer 1
- Cannot open /dev/ttyUSB0: Permission denied #26
- Comments
- Navis-Raven commented Jul 18, 2017
- ConstantJoe commented Aug 8, 2017
- stefanofiorentino commented Mar 28, 2018
- kbhuinfo commented Jan 22, 2019
- bumbalu commented Feb 13, 2019
- abstract17 commented Mar 29, 2019
- Taudris commented Apr 21, 2019
- shamo1 commented Nov 11, 2019
- fr3kz commented Nov 11, 2019
- Vince55 commented Jan 20, 2020
- tdgi commented Jan 24, 2020
- BlagoD commented Feb 10, 2020
- m-atoms commented May 19, 2020
- thecompoundingdev commented Jun 9, 2020 •
- hashc4t commented Jun 25, 2020
- duncanhames commented Jul 6, 2020
- kaustubhKVS commented Jul 13, 2020
- ThomasGeor commented Oct 9, 2020
- loleg commented Oct 30, 2020
- kelvin-JR commented Nov 3, 2020
- diesilveira commented Nov 12, 2020
- RicBar10 commented Nov 18, 2020
- Bill0412 commented Nov 21, 2020
- cheng3100 commented Jan 27, 2021
- stefanofiorentino commented Jan 27, 2021
- MohamedYousof commented Feb 4, 2021
- peely commented Feb 10, 2021 •
Error opening serial port (Linux)
Overview
When uploading a sketch you may get the following error
or, when opening the serial Monitor
Note: The number in ttyACM* may be different.
If this happens, start by ensuring that you are using the correct port:
- Arduino IDE:Tools > Port > [select port]
- Web Editor: Select port using the dropdown.
If the problem persists there may be an issue with permissions for the serial port. See below for step-by-step instructions on how to set the correct permissions.
How to set serial port permissions
Open Terminal and type
Press enter. Terminal will return something like
What we are interested in is the group name, which is probably called dialout .
Note: The number at the end of ttyACM may be different, or multiple entries might be returned.
Now we want to add your user to that group. Input the following command in the terminal, replacing with the group name from above, and with your username, both without brackets.
Press enter. Input password if prompted.
Lastly, for the new permissions to take effect, you need to log out and in to your user account.
You can verify the changes by typing
into the Terminal and pressing Enter. The group you added should appear in the list.
Источник
Как подключиться к плате через переходник USB-UART
Купил китайский переходник USB-UART под названием CP2102. В виндувсе без проблем соединялся со своей платой программой Putty. В убунте пользуюсь той же программой, но выскакиевает сообщение c текстом:
Драйвера я установил от производителя. Как-нибудь можно еще подключиться?
есть же minicom.
Ищи переходник на FTDI232R, или сам собери, документация прекрасная, схема простая. Я был удивлен, но драйвера в линуксе годные, перенос угкода и железа прошел незамеченным. Даже костылять ничего не пришлось. Силиконлабовские мосты мне никогда не нравились, глючноватые, подчеркну слово МНЕ.
Драйвера я установил от производителя
приведи результат работы команды:
к какому из них подключаешься?
Пробовал ко всем подключаться. Ну а судя по этому выводу:
Ничего не выводит. Просто долго жду и курсор мигает.
выбираешь во вкладке Session в группе Specify the destination you want to connect to выбираешь Serial
в поле Serial line пишешь /dev/ttyUSB3 и нажимаешь Open ?
и перевойти пользователем в систему
Да все так делаю, и выдает сообщение: Unable to open connection to: и т.д.
Кстати попробовал minicom. Через нее подключился, только клавиатура не работает.
Драйвера я установил от производителя
Через нее подключился, только клавиатура не работает.
Судя по всему, твоя железяка просто эхо не дает. Поэтому на экране ничего и не появляется.
По теме: есть удобная утилита com из пакета tinyserial, а еще есть screen — он-то точно «из коробки» везде есть!
P.S. Лучше б ты купил переходник на PL2303, он где-то в 2 раза дешевле (30..35 рублей супротив 60..70 для переходника на 2102)
Заработало. А что это было не подскажите?
Спасибо большое, друзья! Все работает.
Драйвера я установил от производителя
А что не так в этой фразе? Мне просто надо знать, для общего развития.
Это были права доступа на файл порта.
видишь вот тут группа написана: твой пользователь должен входить в эту группу, что бы получить права на чтение запись в это устройство. по умолчанию в эту группу пользователи не входят. магической строчкой ты добавил текущего пользователя в эту группу. перевходом в систему получил права группы.
Не нужны никакие «драйвера» для работы с этими переходниками! В ядре есть модуль usbserial, который отвечает за коммуникацию с подобным железом.
Для того, чтобы не париться с группами и правами доступа, обычно в /etc/udev/rules.d добавляют правило вроде такого:
VID и PID смотрят в выхлопе lsusb. Режим 0666 позволяет не париться с группами. Но там уж ваше дело.
в linux практически все драйвера входят в состав ядра
подключай устройство, смотри в dmesg, скорее всего оно определится и погрузится нужный драйвер
ты даже банальных unix прав не знаешь, читай книжки
Источник
Fix serial port permission denied errors on Linux
The ancient serial port which is no longer found on the latest motherboards and even the not so latest laptops is still used for connecting to the console of networking devices, headless computers and a lot other applications. On computers which do not have built-in serial ports USB-to-Serial adapters can be used. Linux identifies inbuilt serial ports as /dev/ttyS0, /dev/ttyS1,….. /dev/ttySn and USB-to-Serial adapters as /dev/ttyUSB0, …. /dev/ttyUSBn and they can be accessed using terminal emulator applications like PuTTY, minicom and screen.
Normally when the serial console is accessed using the terminal emulator of your choice as a non-root user you’ll get a “permission denied” error. Using PuTTY on Ubuntu I got the following error – “Unable to open connection to: Unable to open serial port“.
PuTTY on Linux throws this error if the user running it does not have permissions to access the serial port device file
This is because the device file of the serial port does not have permissions to allow to currently logged in user to “read” or “write” to the serial device. The following command will confirm that.
So we can see that only the “root” user and the “dialout” group have proper permissions, while chmod can be used to grant access to the required user or everyone it is messy and not a secure way. The easier way is the add the user to the dialout group.
First verify if the user does belong to the dialout group using the “id” command.
Next add the user to the “dialout” supplementary group.
You have to logout and login before changes take effect. After logging back in try the “id” command again.
Now all your terminal emulator applications will work with the serial port without any issues.
Источник
plink Unable to open serial port
Configuration:
- Windows 7
- putty 0.67
- plink 0.67
Problem
I am trying to use plink to open a serial port connection on COM9.
Using PuTTY I can open the serial connection on COM9 and I have a saved session for that serial connection.
The COM PORT settings are:
- Baud: 115200
- Data: 8-bits
- Stop: 1-bit
- Parity: None
- Flow Control: None
When I try and use plink instead of PuTTY , I get the following errors:
But if I use the saved PuTTY session for COM9, it works!
However, I cannot use saved sessions, as my aim is to use plink with Expect to automate testing with the Device connected by serial, and will be on different machines and different COM ports.
1 Answer 1
I already know the answer, but I googled the problem and saw similar questions with no answers. Hopefully, the next person to Google this will find this and it will save them some trouble.
This problem is Windows OS specific.
On Windows, addressing a COM port greater than COM9 requires special addressing.
From COM1 to COM9 you identify them as just that e.g. COM1 , COM2 , etc, but over COM9 you have to address them in a special way, for COM10 you must identify it as \\.\COM10 , and so on.
So, I tried this and it works:
I don’t know why the special COM port addressing format is required for plink , and why it is required for COM9, which shouldn’t need it. When using serial to COM1 it works without it. PuTTY doesn’t seem to care either.
Источник
Cannot open /dev/ttyUSB0: Permission denied #26
Comments
Navis-Raven commented Jul 18, 2017
I had an issue , while trying to do flash
Cannot open /dev/ttyUSB0: Permission denied
I palliated to this problem with the command » sudo chmod -R 777 /dev/ttyUSB0 » each time I wanted to flash.
Do you know more about these bugs ? This maybe due to an ubuntu bug (Ubuntu 16 LTS) but I don’t know
The text was updated successfully, but these errors were encountered:
ConstantJoe commented Aug 8, 2017
I’m not a dev on this project, just a user so if anyone else wants to jump in please do:
This is not an issue with the esp8266, and its not actually a bug at all, its just part of Linux. Its best practice to not change permissions in /dev unless as a last resort. What you want to do instead is to add yourself to the group which would give you permission to access the tty ports.
To see the groups you are in simply type:
To see all available groups type:
Most of them are self-explanatory, in this case you want to add yourself to either the tty group, or dialout, which you would do by:
sudo usermod -a -G tty yourname
Then your user should have access to tty without use of sudo.
stefanofiorentino commented Mar 28, 2018
After the sudo usermod -a -G tty yourname you have to logout/login to get group addition happens.
kbhuinfo commented Jan 22, 2019
I had to add my user to group «dialout» too (ubuntu). Logout/login required.
bumbalu commented Feb 13, 2019
Thank you people, it helped me to get access to my 3d printer from Klipper on Raspberry Pi!
abstract17 commented Mar 29, 2019
PROPER LOGOUT IS REQUIRED
Taudris commented Apr 21, 2019
Can this issue be added to the install documentation? Or even better, is there a way to automate handling it?
shamo1 commented Nov 11, 2019
this is actually a permission problem u have to allow your Arduino IDE to access the specified port just simply type following commands in your terminal
sudo su
//type your password
cd /
cd dev
chown username ttyUSB0
fr3kz commented Nov 11, 2019
thank you shamo1, it helped me
Vince55 commented Jan 20, 2020
thanks shamo1, that worked for me too!
tdgi commented Jan 24, 2020
I add myself to dialout group and it works:
sudo usermod -a -G dialout your_user_name
BlagoD commented Feb 10, 2020
I had to add my user to group «dialout» too (ubuntu). Logout/login required.
Indeed, without being member of the «dialout» group, the access to the ttyUSB is not granted.
Thanks for pointing it out!
m-atoms commented May 19, 2020
note for future users who are curious about this
Problem
Cannot open /dev/ttyUSB0: Permission denied error is caused by the user not having access to the serial ports as other commenters have mentioned. More specifically, the user is not in the dialout group.
Solution
sudo usermod -a -G dialout $USER
For anyone who likes knowing what they’re running before they run it:
usermod — modify a user account
-a — add the user to supplementary groups
-G — a list of supplementary groups (man page says to use -a only with -G )
dialout — group that controls access to serial ports (and other hardware too)
$USER — Bash variable containing current username (not a builtin, usually automatically set env variable)
bonus notes: This is the ‘linux way’ to solve the problem. Adding the user to the group with permission to use the device is much safer than changing the permissions of the device itself. And as others have mentioned, make sure you log out for the changes to take effect.
thecompoundingdev commented Jun 9, 2020 •
thanks @shamo1 ! I tried adding myself to tty and dialout group and it worked after logging back in. but the next day it gave same error but I was still a member of those groups. Had to add chown ttyUSB0 through root and it worked!
hashc4t commented Jun 25, 2020
For anyone using Arch Linux, Arch has a separate user group for serial ports called uucp.
To add your current user:
sudo usermod -a -G uucp $USER
then logout/login.
duncanhames commented Jul 6, 2020
For anyone using Arch Linux, Arch has a separate user group for serial ports called uucp.
To add your current user:
sudo usermod -a -G uucp $USER
then logout/login.
Thanks for that!
kaustubhKVS commented Jul 13, 2020
this is actually a permission problem u have to allow your Arduino IDE to access the specified port just simply type following commands in your terminal
sudo su
//type your password
cd /
cd dev
chown username ttyUSB0
This worked better for me !! They should include this on documentation !! Thankyou @shamo1 .
ThomasGeor commented Oct 9, 2020
this is actually a permission problem u have to allow your Arduino IDE to access the specified port just simply type following commands in your terminal
sudo su
//type your password
cd /
cd dev
chown username ttyUSB0
This one worked for me with ESP32
loleg commented Oct 30, 2020
In addition to adding my user to the tty and dialout groups on Fedora Linux 32, I also had to follow the instructions here:
On modern distros that use ConsoleKit create the file /etc/udev/rules.d/01-ttyusb.rules containing the following and then reload the udev rules and replug the Arduino device:
kelvin-JR commented Nov 3, 2020
this is actually a permission problem u have to allow your Arduino IDE to access the specified port just simply type following commands in your terminal
sudo su
//type your password
cd /
cd dev
chown username ttyUSB0
it’s helpful ,thank you
diesilveira commented Nov 12, 2020
RicBar10 commented Nov 18, 2020
this is actually a permission problem u have to allow your Arduino IDE to access the specified port just simply type following commands in your terminal
sudo su
//type your password
cd /
cd dev
chown username ttyUSB0
thanks you, it solve the problem, you’re a genius
Bill0412 commented Nov 21, 2020
this is actually a permission problem u have to allow your Arduino IDE to access the specified port just simply type following commands in your terminal
sudo su
//type your password
cd /
cd dev
chown username ttyUSB0
This solves my problem, thanks!
cheng3100 commented Jan 27, 2021
Hi ,just look at this issue and I found a better solution .
Just type this commad to install a udev ruler file:
This ruler file is from platformio.
And you also need to join group dialout and plugdev :
stefanofiorentino commented Jan 27, 2021
And you also need to join group dialout and plugdev:
and remember to logout/login..
MohamedYousof commented Feb 4, 2021
this is actually a permission problem u have to allow your Arduino IDE to access the specified port just simply type following commands in your terminal
sudo su
//type your password
cd /
cd dev
chown username ttyUSB0
This worked for me Ubuntu 20.04
peely commented Feb 10, 2021 •
note for future users who are curious about this
Problem
Cannot open /dev/ttyUSB0: Permission denied error is caused by the user not having access to the serial ports as other commenters have mentioned. More specifically, the user is not in the dialout group.
Solution
sudo usermod -a -G dialout $USER
For anyone who likes knowing what they’re running before they run it:
usermod — modify a user account
-a — add the user to supplementary groups
-G — a list of supplementary groups (man page says to use -a only with -G )
dialout — group that controls access to serial ports (and other hardware too)
$USER — Bash variable containing current username (not a builtin, usually automatically set env variable)
bonus notes: This is the ‘linux way’ to solve the problem. Adding the user to the group with permission to use the device is much safer than changing the permissions of the device itself. And as others have mentioned, make sure you log out for the changes to take effect.
This is the safest, cleanest and most reliable answer. Don’t just go round changing ownership, make yourself a member of that devices ownership group. Thank you @m-atoms for the clear explanation.
Источник