Thread Tools
Jun 09, 2017, 07:18 AM
Registered User
Discussion

Failed to open serial Ubuntu


Does anyone have any experience working with betaflight F3 and linux? I've been having issues with the drivers from the word go.
It detects when I plug in on /dev/ttyACM0, whne I click connect in betaflight configurator it disconnects and give "Failed to open serial port". There is not /dev/ttyUSB* I'm using Ubunut 17.04 .
Sign up now
to remove ads between posts
Jun 09, 2017, 07:30 PM
Registered User
Ace12GA's Avatar
EDIT: to anyone hitting this from google, or searching the boards, skip on down to post 4 for a more convenient method.

sudo chmod 0777 /dev/ttyACM0

It's a permissions thing.

EDIT: Sorry, Ubuntu, you probably need a little more.

1. Plug in the FC to USB.
2. Wait roughly 20 seconds for it to connect and boot.
3. Open Configurator
4. Open a terminal and execute the above command. Leave the terminal open, you may need it.
5. Click "Connect" in configurator.
6. If it fails to connect, wait a few seconds, and run the command in the terminal again (up arrow key to repeat the last command)

That should work. You may find that you need to rerun the permissions command after a reflash, or even after a reboot. Depends on the FC and the USB interface.

There is a way to set this permission automatically, but I can't be bothered to myself.
Last edited by Ace12GA; Nov 11, 2017 at 11:43 AM.
Nov 09, 2017, 04:56 AM
Registered User
hi,
I have the same issue and your help is very nice.
just a little line command.... 1 week of search.

Thank you

It's good

Mamat
Nov 10, 2017, 08:54 AM
My quadcopter is not a drone!
unseen's Avatar
This is completely the wrong way to do this!

When the device file is created, it gets created as owner:root, group:dialout and permissions 660. Changing the permissions on the device file is the wrong way to get access to it as a user, especially when you have to do it every time the device is connected.

A much better idea (and the correct way to do this) is to add your user to the 'dialout' group:

sudo usermod -a -G dialout <username>
Nov 11, 2017, 11:42 AM
Registered User
Ace12GA's Avatar
Quote:
Originally Posted by unseen
This is completely the wrong way to do this!

When the device file is created, it gets created as owner:root, group:dialout and permissions 660. Changing the permissions on the device file is the wrong way to get access to it as a user, especially when you have to do it every time the device is connected.

A much better idea (and the correct way to do this) is to add your user to the 'dialout' group:

sudo usermod -a -G dialout <username>
That is a simpler and more convenient way to do it, which I personally started using around August when I was setting up a dozen quads with my club. I wouldn't say altering the permissions on the device is wrong though, as it accomplishes the same thing, granting the user account the rights to use the device. Where it is a pain is when setting up F4 flight controllers which have a lengthy reboot as compared to a F1 or F3 based device, forcing the reset of the permissions.

Sorry, I'm annoyed by the "wrong" part of your post. It's not wrong, just a little more effort. Less convenient.

To anyone reading this in the future, adding yourself to the group is a one time thing, and works great. I recommend it.
Nov 11, 2017, 03:59 PM
My quadcopter is not a drone!
unseen's Avatar
How about "suboptimal" instead?

Devices are assigned to groups and have their permissions set through the udev rules in /lib/udev/rules.d and /etc/udev/rules.d. Although repetitively changing the permissions on the device each time the device file is created will achieve the purpose of granting access to all unprivileged users, it is not a recommended or security conscious way to control device permissions.

Permissions should always be set as restrictively as possible. Using groups to give users access to resources is a secure and safe way to do that. Manually changing file permissions as the superuser is a bad habit to get into, regardless of how experienced you are with Linux or any UNIX system.
Nov 11, 2017, 04:34 PM
My quadcopter is not a drone!
unseen's Avatar
As an aid to anyone having problems flashing a flight controller that uses DFU flashing mode on Linux, you don't need to install any drivers, but you may need to let the operating system know about the flight controller when it is in DFU mode.

When you flash a flight controller that uses a Virtual Comm Port instead of a dedicated external UART-USB chip like the CP2102 on the SP Racing F3, the flight controller disconnects and then reconnects in DFU mode with a different identity on the USB bus.

All you need to do is create a text file named 45-stdfu-permissions.rules and edit it to contain the following:

Code:
# DFU (Internal bootloader for STM32 MCUs)
SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", MODE="0664", GROUP="plugdev"
Once you have created the file, copy it to /etc/udev/rules.d with:
Code:
sudo cp 45-stdfu-permissions.rules /etc/udev/rules.d
and add your user to the group 'plugdev' with:
Code:
sudo usermod -a -G plugdev <username>
That's it!

These instructions apply for flight controllers designed to run Cleanflight , iNav or Betaflight only and having a compatible bootloader. Flight controllers designed for OpenPilot/LibrePilot/dRonin/Arducopter will create different interfaces and may require the installation of rules specific that that flight controller and specific bootloader.
Last edited by unseen; Dec 12, 2017 at 01:07 AM.
Nov 13, 2017, 08:31 AM
Registered User
Ace12GA's Avatar
Quote:
Originally Posted by unseen
How about "suboptimal" instead?
Works for me.

Quote:
Originally Posted by unseen
Permissions should always be set as restrictively as possible. Using groups to give users access to resources is a secure and safe way to do that. Manually changing file permissions as the superuser is a bad habit to get into, regardless of how experienced you are with Linux or any UNIX system.
Agree, in a multi-user or enterprise environment.
Dec 11, 2017, 05:28 PM
Registered User
I reckon on the venn diagram of noob Leader 120 owners running Linux has a pretty small overlap, but I'm in it!

I found this thread while googling for the same 'failed to open serial port' issue - I did find someone else recommending removing modemmanager before I found this thread but that didn't help...

Anyway, I'm posting because I tried adding my user to the 'dialout' group but that doesn't seem to help. I also added my user to 'plugdev' group as I saw that mentioned but the only thing that allows me to connect to my Leader 120 via Betaflight on Ubuntu is running the chmod command *every time* I connect.

Can anyone give me any pointers?

I did manage to flash the latest Betaflight in DFU mode using @unseen directions thanks BTW
Dec 12, 2017, 01:07 AM
My quadcopter is not a drone!
unseen's Avatar
Quote:
Originally Posted by nommo
I reckon on the venn diagram of noob Leader 120 owners running Linux has a pretty small overlap, but I'm in it!

I found this thread while googling for the same 'failed to open serial port' issue - I did find someone else recommending removing modemmanager before I found this thread but that didn't help...

Anyway, I'm posting because I tried adding my user to the 'dialout' group but that doesn't seem to help. I also added my user to 'plugdev' group as I saw that mentioned but the only thing that allows me to connect to my Leader 120 via Betaflight on Ubuntu is running the chmod command *every time* I connect.

Can anyone give me any pointers?

I did manage to flash the latest Betaflight in DFU mode using @unseen directions thanks BTW
What is written to /var/log/syslog when you connect the flight controller? What permissions, owner and group does the device file get created with before you run chmod?

Essentially, you need to look up the VendorID and ProductID for the device in the syslog and then see what rules (if any) already exist for that device. If there are no rules, or they are incorrect, you can specify or correct the udev rules so that it will be set up correctly.
Dec 12, 2017, 05:59 AM
Registered User
Quote:
Originally Posted by unseen
What is written to /var/log/syslog when you connect the flight controller? What permissions, owner and group does the device file get created with before you run chmod?

Essentially, you need to look up the VendorID and ProductID for the device in the syslog and then see what rules (if any) already exist for that device. If there are no rules, or they are incorrect, you can specify or correct the udev rules so that it will be set up correctly.
Oh I just tried again to tail the syslog and it works!

I think I probably needed to restart? I didn't try that last night.

Here's what /var/log/syslog says when I plug in FYI:

Quote:
Dec 12 11:52:31 nommo-lat kernel: [ 8151.127471] usb 2-1.4: new full-speed USB device number 8 using ehci-pci
Dec 12 11:52:31 nommo-lat kernel: [ 8151.207469] usb 2-1.4: device descriptor read/64, error -32
Dec 12 11:52:32 nommo-lat kernel: [ 8151.395525] usb 2-1.4: device descriptor read/64, error -32
Dec 12 11:52:32 nommo-lat kernel: [ 8151.583533] usb 2-1.4: new full-speed USB device number 9 using ehci-pci
Dec 12 11:52:32 nommo-lat kernel: [ 8151.663535] usb 2-1.4: device descriptor read/64, error -32
Dec 12 11:52:32 nommo-lat kernel: [ 8151.851511] usb 2-1.4: device descriptor read/64, error -32
Dec 12 11:52:33 nommo-lat kernel: [ 8152.455593] usb 2-1.4: new full-speed USB device number 11 using ehci-pci
Dec 12 11:52:33 nommo-lat kernel: [ 8152.568011] usb 2-1.4: New USB device found, idVendor=0483, idProduct=5740
Dec 12 11:52:33 nommo-lat kernel: [ 8152.568018] usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Dec 12 11:52:33 nommo-lat kernel: [ 8152.568022] usb 2-1.4: Product: STM32 Virtual COM Port
Dec 12 11:52:33 nommo-lat kernel: [ 8152.568025] usb 2-1.4: Manufacturer: STMicroelectronics
Dec 12 11:52:33 nommo-lat kernel: [ 8152.568028] usb 2-1.4: SerialNumber: 2069375A4234
Dec 12 11:52:33 nommo-lat kernel: [ 8152.568681] cdc_acm 2-1.4:1.0: ttyACM0: USB ACM device
Dec 12 11:52:33 nommo-lat mtp-probe: checking bus 2, device 11: "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4"
Dec 12 11:52:33 nommo-lat mtp-probe: bus: 2, device: 11 was not an MTP device
Thanks again for the pointers chap!
Dec 12, 2017, 06:44 AM
My quadcopter is not a drone!
unseen's Avatar
Yeah, if you'd just added yourself to the group and hadn't logged out and in again, things that were already running were not yet aware of your new group membership.

Good to hear that it's working now!
Apr 06, 2018, 06:12 PM
I USE CAPS - EYE TROUBLE
Happymcc's Avatar
Thanks unseen that worked great .

Quote:
Originally Posted by unseen
This is completely the wrong way to do this!

When the device file is created, it gets created as owner:root, group:dialout and permissions 660. Changing the permissions on the device file is the wrong way to get access to it as a user, especially when you have to do it every time the device is connected.

A much better idea (and the correct way to do this) is to add your user to the 'dialout' group:

sudo usermod -a -G dialout <username>
Aug 30, 2018, 02:42 AM
Registered User
This didn't work for me. I had to add uucp and now connecting fine. (Linux mint)
Last edited by Ant73; Aug 30, 2018 at 02:42 AM. Reason: Added OS
Aug 30, 2018, 03:58 AM
Registered User
grizewald's Avatar
Quote:
Originally Posted by Ant73
This didn't work for me. I had to add uucp and now connecting fine. (Linux mint)
Sorry, but whatever you did, adding uucp had nothing to do with it as uucp has nothing to do with giving an unprivileged user access to a serial port.

Most likely, you hadn't logged out and in again after adding yourself to the dialout group.


Quick Reply
Message:

Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Help! Cleanflight failed to open serial port upon trying to flash! Skyline 32 in Nighthawk Bfreak Beginner Multirotor Drones 5 Dec 15, 2017 08:27 PM
Discussion Cleanflight "failed to open serial port" MicrometUK Multirotor Drone Electronics 3 Nov 22, 2016 12:13 PM
Discussion Cleanflight Failed to open serial port niels0608 Beginner Multirotor Drones 10 Sep 17, 2016 11:11 AM
Help! Failed to open serial port.Windows 8.1 fireshovel Multirotor Drone Electronics 4 Sep 04, 2016 12:23 PM
Help! Failed to open serial port.Windows 8.1 fireshovel Beginner Multirotor Drones 0 May 25, 2016 03:45 PM