Skip to content

Commit bb0b5e0

Browse files
Document USB setup corner cases
1 parent ea19083 commit bb0b5e0

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

docs/getting-started/linux-usb-setup.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ By default, when you plug in an Mbed device to a Linux machine, its serial port
55
This page will show you how to configure an Mbed device to have a consistent TTY path on Linux, and also how to set the permissions so that it can be accessed without root.
66

77
## Setting up the TTY
8-
1. First, you need to figure out what tty device corresponds to the Mbed board. It will generally be one of the /dev/ttyACMx devices, which you can list by running `ls -l /dev/ttyACM*`. Maybe the easiest way to identify the right one is to unplug and replug the board and see which ttyACM device vanishes and reappears.
8+
1. First, you need to figure out what tty device corresponds to the Mbed board. It will generally be one of the /dev/ttyACMx devices, which you can list by running `ls -l /dev/ttyACM*`. Generally the easiest way to identify which is by running `sudo dmesg -w` in a console, then plugging in the device and looking at the prints produced by the kernel. (If the device has multiple TTYs, see "Devices with Multiple TTYs" below)
99
2. Then, once you have found it, get the serial number of the Mbed device from its tty:
1010
```
1111
udevadm info -a -n /dev/ttyACMx | grep '{serial}' | head -n1
1212
```
13+
(if this command does not print anything, see "Devices Without a Serial Number" below)
1314
3. Create a file `/etc/udev/rules.d/99-usb-serial.rules` with contents like:
1415
```
1516
SUBSYSTEM=="tty", ATTRS{serial}=="<serial number>", MODE:="0666", SYMLINK+="tty<mbed target>", GROUP="plugdev"
@@ -18,7 +19,7 @@ This page will show you how to configure an Mbed device to have a consistent TTY
1819
1920
For example, for my NUCLEO_F429ZI board, it looks like this:
2021
```
21-
SUBSYSTEM=="tty", ATTRS{serial}=="066CFF343537424257254941", MODE:="0666", SYMLINK+="ttyNUCLEO_F429ZI", OWNER="jsmith"
22+
SUBSYSTEM=="tty", ATTRS{serial}=="066CFF343537424257254941", MODE:="0666", SYMLINK+="ttyNUCLEO_F429ZI", GROUP="plugdev"
2223
```
2324
2425
**Note: If you have multiple of the same Mbed board, make sure to give them different symlink names, e.g. `ttyNUCLEO_F429ZI_1` and `ttyNUCLEO_F429ZI_2`.**
@@ -37,6 +38,24 @@ This page will show you how to configure an Mbed device to have a consistent TTY
3738
6. You should now see your mbed device at the desired TTY path.
3839
7. To connect to it, install minicom, then run `minicom -D /dev/tty<mbed target> -b 115200` (or substitute a different baud rate if your code is not configured for 115200 baud)
3940
41+
!!! warning "Devices with Multiple TTYs"
42+
A few Mbed targets (including `NRF52840_DK`) have multiple TTYs from a single USB device, so the above udev rule will not work. You need to add an additional segment, `DEVPATH=="*:1.0*"`, to select only the first TTY.
43+
44+
For example, for my NRF52840_DK, my udev rule looks like
45+
46+
```
47+
SUBSYSTEM=="tty", ATTRS{serial}=="001050278063", MODE:="0666", DEVPATH=="*:1.0*", SYMLINK+="ttyNRF52840_DK", GROUP="plugdev"
48+
```
49+
50+
!!! warning "Devices Without a Serial Number"
51+
A few Mbed targets (including all SparkFun Artemis boards and some older Nuvoton ones) do not have a unique serial number, so the above way of writing the udev rule will not work. Instead, you must make the rule based on the vendor and product IDs of the device, as printed by lsusb. For example, for SFE_ARTEMIS, one might do:
52+
53+
```
54+
SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", MODE:="0666", SYMLINK+="ttySFE_ARTEMIS", GROUP="plugdev
55+
```
56+
57+
Note that this does not work if you have multiple of serial-number-less devices connected to a single computer. There is no way to repeatably assign the TTY name in that situation.
58+
4059
## Setting Up Udev Rules for Programming
4160
If your device has a debugger onboard, you may also need to install udev rules to allow that debugger to be accessed by tools like STM32Cube, OpenOCD, and PyOCD.
4261

0 commit comments

Comments
 (0)