Skip to content

Instantly share code, notes, and snippets.

@tspspi
Last active May 18, 2024 20:17
Show Gist options
  • Save tspspi/ed2b406abbad6fff903d9d8039df3b4e to your computer and use it in GitHub Desktop.
Save tspspi/ed2b406abbad6fff903d9d8039df3b4e to your computer and use it in GitHub Desktop.
devd rules for FreeBSDs

devd ruleset for some devices on FreeBSD

This gist contains some devd rulesets to be used with FreeBSDs devd that assign unique device names to some USB devices. Those are:

  • CP2102 based serial interfaces (/dev/cp2102n_$sernum)
  • FT232 based serial interfaces (/dev/ft232r_$sernum)
  • Atmega2560 Arduino boards (/dev/mega2560_$sernum)

Note: Some of the scripts include chown and chgrp statements, some applications may require them (with adjusted user and group)

attach 1000 {
match "vendor" "0x10c4";
match "product" "0xea60";
action "ln -sf /dev/cua$ttyname /dev/cp2102n_$sernum && ln -sf /dev/cua$ttyname.lock /dev/cp2102n_$sernum.lock && ln -sf /dev/cua$ttyname.init /dev/cp2102n_$sernum.init && chmod 660 /dev/cua$ttyname && chmod 660 /dev/cua$ttyname.lock && chmod 660 /dev/cua$ttyname.init && chmod -h 660 /dev/cp2102n_$sernum && chmod -h 660 /dev/cp2102n_$sernum.lock && chmod -h 660 /dev/cp2102n_$sernum.init";
};
notify 1000 {
match "vendor" "0x10c4";
match "product" "0xea60";
match "type" "DETACH";
match "subsystem" "DEVICE";
action "rm /dev/cp2102n_$sernum && rm /dev/cp2102n_$sernum.init && rm /dev/cp2102n_$sernum.lock";
};
attach 1000 {
match "vendor" "0x0403";
match "product" "0x6001";
action "ln -sf /dev/cua$ttyname /dev/ft232r_$sernum && ln -sf /dev/cua$ttyname.lock /dev/ft232r_$sernum.lock && ln -sf /dev/cua$ttyname.init /dev/ft232r_$sernum.init";
};
notify 1000 {
match "vendor" "0x0403";
match "product" "0x6001";
match "type" "DETACH";
match "subsystem" "DEVICE";
action "rm /dev/ft232r_$sernum && rm /dev/ft232r_$sernum.lock && rm /dev/ft232r_$sernum.init";
};
attach 1000 {
match "vendor" "0x2341";
match "product" "0x0042";
action "ln -sf /dev/cua$ttyname /dev/mega2560_$sernum && ln -sf /dev/cua$ttyname.lock /dev/mega2560_$sernum.lock && ln -sf /dev/cua$ttyname.init /dev/mega2560_$sernum.init && chmod 770 /dev/cua$ttyname* && chmod 770 /dev/mega2560_$sernum* && chown root /dev/cua$ttyname* && chgrp wheel /dev/cua$ttyname*";
};
notify 1000 {
match "vendor" "0x2341";
match "product" "0x0042";
match "type" "DETACH";
match "subsystem" "DEVICE";
action "rm /dev/mega2560_$sernum && rm /dev/mega2560_$sernum.init && rm /dev/mega2560_$sernum.lock";
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment