Skip to content

Commit 4b3017e

Browse files
Add Linux USB Setup
1 parent 11987a1 commit 4b3017e

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

docs/getting-started/.nav.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
nav:
22
- toolchain-install.md
33
- creating-a-project.md
4-
- IDE/CLI Setup: ide_cli_setup
4+
- IDE/CLI Setup: ide_cli_setup
5+
- linux-usb-setup.md
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# USB Setup on Linux
2+
3+
By default, when you plug in an Mbed device to a Linux machine, its serial port (TTY) will get an arbitrary path (e.g. /dev/ttyACM0), and this path can even change depending on the order you plug things in. This can be really annoying, especially if you are working with multiple Mbed devices at the same time.
4+
5+
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.
6+
7+
## 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.
9+
2. Then, once you have found it, get the serial number of the Mbed device from its tty:
10+
```
11+
udevadm info -a -n /dev/ttyACMx | grep '{serial}' | head -n1
12+
```
13+
3. Create a file `/etc/udev/rules.d/99-usb-serial.rules` with contents like:
14+
```
15+
SUBSYSTEM=="tty", ATTRS{serial}=="<serial number>", MODE:="0666", SYMLINK+="tty<mbed target>", GROUP="plugdev"
16+
```
17+
where `<mbed board>` and `<serial number>` are replaced by the mbed target name and the serial number found above.
18+
19+
For example, for my NUCLEO_F429ZI board, it looks like this:
20+
```
21+
SUBSYSTEM=="tty", ATTRS{serial}=="066CFF343537424257254941", MODE:="0666", SYMLINK+="ttyNUCLEO_F429ZI", OWNER="jsmith"
22+
```
23+
24+
**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`.**
25+
26+
4. If you have not done this before, add your username to the `plugdev` group:
27+
```
28+
$ sudo usermod -a -G plugdev $(whoami)
29+
```
30+
You will need to log out and log in for this change to take effect.
31+
32+
5. Reload udev:
33+
```
34+
$ sudo udevadm control --reload-rules
35+
$ sudo udevadm trigger
36+
```
37+
6. You should now see your mbed device at the desired TTY path.
38+
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)
39+
40+
## Setting Up Udev Rules for Programming
41+
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.
42+
43+
The easiest way to do that is to download this config file [here](https://github.com/openocd-org/openocd/blob/master/contrib/60-openocd.rules) and copy it to /etc/udev/rules.d. Then, reload udev as above.

0 commit comments

Comments
 (0)