3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

パーミッション変更(実行権限など)を自動で付与する

Posted at

著者の実行環境はJetson nano & ubuntu18.04になります。

実行権限をつけたいデバイスを接続してlsusbコマンドをします。

user@user-desktop:~$ lsusb
Bus 002 Device 002: ID 0bda:0411 Realtek Semiconductor Corp. 
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 15d1:0000  
Bus 001 Device 004: ID 054c:09cc Sony Corp. 
Bus 001 Device 003: ID 0483:374b STMicroelectronics ST-LINK/V2.1 (Nucleo-F103RB)
Bus 001 Device 002: ID 0bda:5411 Realtek Semiconductor Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

例としてマイコンボード(Nucleo F446-RE)の場合は

Bus 001 Device 003: ID 0483:374b STMicroelectronics ST-LINK/V2.1 (Nucleo-F103RB)

の0483:374bの番号を使用します。

次に50-udev-default.rulesを開いてルールを記入する設定ファイルを開きます。この際ファイルが存在しない場合は作成します。
vimを使用していますが自由にエディタを使用してください。

※設定ファイル名はフォーマットは決まっていて、0詰め2桁数値-名前.rulesとすれば名前は何でも良く、最初の番号は優先順位のようです。

sudo vim /lib/udev/rules.d/50-udev-default.rules

ファイルを開いたら以下のように記入します。idVendorとidProductに先程の番号になります。

KERNEL=="ttyACM*", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", GROUP="dialout", MODE="0777"

記入が終わったらPCを再起動して以下のコマンドで権限が付与されているかを確認します。

user@user-desktop:/etc/udev/rules.d$ ls -la /dev/ttyACM0
crwxrwxrwx 1 root dialout 166, 0  6月  7 22:23 /dev/ttyACM0

これでパーミッションが変更されていたら成功です。

また、複数のデバイスのパーミッションを変更したい場合は

KERNEL=="ttyACM*", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", GROUP="dialout", MODE="0777"
KERNEL=="ttyACM*", ATTRS{idVendor}=="15d1", ATTRS{idProduct}=="0000", GROUP="dialout", MODE="0777" 

のようにデバイスごとに記入します(上記は北陽のUTM-30LXの例)。

参考
https://itkobo-z.jp/archives/218

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?