Skip to content

Configuring an Mbed TTY Device on Linux

Jamie Smith edited this page Sep 4, 2024 · 8 revisions

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.

Setting up the TTY

  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.
  2. 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
  1. 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"

⚠️ If you have multiple of the same Mbed board, give them different symlink names, e.g. ttyNUCLEO_F429ZI_1 and ttyNUCLEO_F429ZI_2.

  1. If you have not done this before, add your username to the plugdev group:
$ sudo usermod -a -G plugdev $(whoami)
  1. Reload udev:
sudo udevadm control --reload-rules
sudo udevadm trigger
  1. You should now see your mbed device at the path /dev/tty<mbed target>.
  2. 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)

Setting Up Udev Rules

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.