-
Notifications
You must be signed in to change notification settings - Fork 16
Configuring an Mbed TTY Device on Linux
By default, when you plug in an Mbed device to a Linux machine, it 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.
This page will show you how to configure an Mbed device to have a consistent path on Linux, and also how to set the permissions so that it can be programmed without root.
- 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. - Then, once you have found it, get the serial number of the Mbed device from its tty:
udevadm info -a -n /dev/ttyACMx | grep '{serial}' | head -n1
- Create a file
/etc/udev/rules.d/99-usb-serial.rules
with contents like:
SUBSYSTEM=="tty", ATTRS{serial}=="<serial number>", MODE:="0666", SYMLINK+="tty<mbed target>", GROUP="plugdev"
where <mbed board>
and <serial number>
are replaced by the mbed target name and serial number.
For example, for my NUCLEO_F429ZI board, it looks like this:
SUBSYSTEM=="tty", ATTRS{serial}=="066CFF343537424257254941", MODE:="0666", SYMLINK+="ttyNUCLEO_F429ZI", OWNER="jsmith"
ttyNUCLEO_F429ZI_1
and ttyNUCLEO_F429ZI_2
.
- If you have not done this before, add your username to the
plugdev
group:
$ sudo usermod -a -G plugdev $(whoami)
- Reload udev:
sudo udevadm control --reload-rules
sudo udevadm trigger
- You should now see your mbed device at the path
/dev/tty<mbed target>
. - 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)
To enable non-root users to access the device for programming, you may also need to add udev rules that set the correct permissions. Download this config file here and copy it to /etc/udev/rules.d. Then, reload udev as above. You may also need to add your user account to the "plugdev" group if it's not already:
sudo usermod -a -G plugdev <your username>
Then, log out and log in to make the change effective.