嵌入式爱好者

linux-3568-电脑访问开发板插上的TF卡,频繁插拔TF卡如何实现自动挂载

2023-2-24 08:24| 发布者: PaperLove| 查看: 245| 评论: 0

类目: 知识库  >  RK3568系列产品     文档编号: 928

问题:

频繁插拔tf卡,需要插拔usb数据线或者输入otg主从切换命令。

解决方法:

1 修改/etc/udev/rules.d/automount.rules

# Media automounting

SUBSYSTEM=="block", ACTION=="add"    RUN+="/etc/udev/scripts/mount.sh"

SUBSYSTEM=="block", ACTION=="remove" RUN+="/etc/udev/scripts/mount.sh"

SUBSYSTEM=="block", ACTION=="change", ENV{DISK_MEDIA_CHANGE}=="1" RUN+="/etc/udev/scripts/mount.sh"

SUBSYSTEM=="block", KERNEL=="mmcblk1", ACTION=="add"    RUN+="/etc/udev/scripts/1.sh"

SUBSYSTEM=="block", KERNEL=="mmcblk1", ACTION=="remove" RUN+="/etc/udev/scripts/2.sh"

2 添加/etc/udev/scripts/1.sh

#!/bin/bash

modprobe g_mass_storage file=/dev/mmcblk1 luns=1 stall=0 removable=1 &

echo host > /sys/devices/platform/fe8a0000.usb2-phy/otg_mode &

echo peripheral > /sys/devices/platform/fe8a0000.usb2-phy/otg_mode &

3 添加/etc/udev/scripts/2.sh

#!/bin/bash

rmmod g_mass_storage

4 执行chmod +x /etc/udev/scripts/1.sh

chmod +x /etc/udev/scripts/2.sh

插入TF卡电脑端会自动显示盘符,弹出TF卡需要先在电脑端弹出,再拔出TF卡。


已解决

未解决

只是看看

最新评论

QQ|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )

GMT+8, 2024-11-16 15:01

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

返回顶部