Introduction #
I recently bought a Bus Pirate and started to play around with it.
I was inspired by this post to create a symlink in /dev
for easier access. However, the commands required a few modifications for version 5.
For starters, the Bus Pirate 5 creates 2 devices:
- The first one gives access to a CLI configuration interface
- The second one gives direct access to the serial data
I wanted to mount the first one as /dev/buspirate
and the second one as /dev/piratebin
. Let’s assume they are mounted by default as /dev/ttyACM0
and /dev/ttyACM1
.
Gathering information #
All the informaiton we need can be gathered with 2 commands.
udevadm info -q all -a /dev/ttyACM0
udevadm info -q all -a /dev/ttyACM1
Typically, udev
rules use the ATTRS{idVendor}
and ATTRS{idProduct}
attributes to filter for the right device.
ATTRS{idProduct}=="7332"
ATTRS{idVendor}=="1209"
The SUBSYSTEM
attribute can be added for more robustness.
SUBSYSTEM=="tty"
However, the 2 devices have identical values for all these attributes. We need something to differenciate them so that we can give them the right name. The only noticeable difference is the interface name.
# /dev/ttyACM0
ATTRS{interface}=="Bus Pirate CDC"
# /dev/ttyACM1
ATTRS{interface}=="Bus Pirate BIN"
It would be ideal to use a udev
filter which uses all of the above.
SUBSYSTEM=="tty", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="7332", ATTRS{interface}=="Bus Pirate CDC"
However, it doesn’t work. The udevadm info
gives us the explanation.
A rule to match, can be composed by the attributes of the device and the attributes from one single parent device.
The ATTRS{idVendor}
and ATTRS{idProduct}
are further in the device tree and part of a different device than the ATTRS{interface}
attribute. Therefore, we don’t really have a choice but to only keep the latter.
Writing the rules #
Here are the resulting rules.
ACTION=="add", SUBSYSTEM=="tty", ATTRS{interface}=="Bus Pirate CDC", MODE="0660", SYMLINK+="buspirate"
ACTION=="add", SUBSYSTEM=="tty", ATTRS{interface}=="Bus Pirate BIN", MODE="0660", SYMLINK+="piratebin"
We can add them from the command line.
echo -e 'ACTION=="add", SUBSYSTEM=="tty", ATTRS{interface}=="Bus Pirate CDC", MODE="0660", SYMLINK+="buspirate"\nACTION=="add", SUBSYSTEM=="tty", ATTRS{interface}=="Bus Pirate BIN", MODE="0660", SYMLINK+="piratebin"' | sudo tee /etc/udev/rules.d/99-BusPirate.rules
And then restart the udev
process to reload the rules.
sudo systemctl restart udev
Now we have the /dev/buspirate
and /dev/piratebin
devices!