您尚未登录。

楼主 #1 2021-02-19 17:35:47

raspberryman
会员
注册时间: 2019-12-27
已发帖子: 503
积分: 465

主线Linux用shell命令切换 OTG(分享)tiny200/licheepi nano|zero均可以使用

dts配置:

&usb_otg {
        dr_mode = "otg"; /* 三个可选项: otg / host / peripheral */
        status = "okay";
};
##切换到host模式:
# echo host > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
# [  117.758152] phy phy-1c13400.phy.0: Changing dr_mode to 1
[  118.414817] usb 1-1: new high-speed USB device number 3 using musb-hdrc
[  118.598193] usb-storage 1-1:1.0: USB Mass Storage device detected
[  118.611789] scsi host0: usb-storage 1-1:1.0
[  119.686198] scsi 0:0:0:0: Direct-Access     Mass     Storage Device   1.00 PQ: 0 ANSI: 0 CCS
[  119.703976] sd 0:0:0:0: [sda] 3842048 512-byte logical blocks: (1.97 GB/1.83 GiB)
[  119.725260] sd 0:0:0:0: Attached scsi generic sg0 type 0
[  119.739844] sd 0:0:0:0: [sda] Write Protect is off
[  119.771819] sd 0:0:0:0: [sda] No Caching mode page found
[  119.777288] sd 0:0:0:0: [sda] Assuming drive cache: write through
[  119.801571]  sda: sda1 sda2 sda3
[  119.817224] sd 0:0:0:0: [sda] Attached SCSI removable disk

#
##切换到device模式:
# echo peripheral > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
[  123.880272] phy phy-1c13400.phy.0: Changing dr_mode to 2
# [  123.890905] usb 1-1: USB disconnect, device number 3

最近编辑记录 raspberryman (2021-02-19 17:39:26)

离线

楼主 #2 2021-02-19 17:36:18

raspberryman
会员
注册时间: 2019-12-27
已发帖子: 503
积分: 465

Re: 主线Linux用shell命令切换 OTG(分享)tiny200/licheepi nano|zero均可以使用

占坑

离线

楼主 #3 2021-02-19 17:38:55

raspberryman
会员
注册时间: 2019-12-27
已发帖子: 503
积分: 465

Re: 主线Linux用shell命令切换 OTG(分享)tiny200/licheepi nano|zero均可以使用

占坑

离线

#4 2021-02-19 22:06:30

zzm24
会员
注册时间: 2018-05-07
已发帖子: 113
积分: 105

Re: 主线Linux用shell命令切换 OTG(分享)tiny200/licheepi nano|zero均可以使用

多谢分享 标记一下

离线

#5 2021-02-20 12:31:07

xiezonglin
会员
注册时间: 2020-03-07
已发帖子: 12
积分: 5

Re: 主线Linux用shell命令切换 OTG(分享)tiny200/licheepi nano|zero均可以使用

正需要这东西,太感谢了

离线

#6 2021-02-20 14:54:44

MTLINUX
会员
注册时间: 2019-10-21
已发帖子: 28
积分: 0.5

Re: 主线Linux用shell命令切换 OTG(分享)tiny200/licheepi nano|zero均可以使用

刚打算要飞usbid线 测试otg,看到这个又省了一个io了。。。
经测试,正常;
感谢raspberryman!

离线

#7 2021-02-24 16:37:00

湘楚浪子
会员
注册时间: 2019-12-22
已发帖子: 40
积分: 39.5

Re: 主线Linux用shell命令切换 OTG(分享)tiny200/licheepi nano|zero均可以使用

MTLINUX 说:

刚打算要飞usbid线 测试otg,看到这个又省了一个io了。。。
经测试,正常;
感谢raspberryman!

奇怪 我的荔枝派zero V3s linux4.13 不行呢,不知道啥原因。

离线

#8 2021-02-24 17:33:08

jckimi
会员
注册时间: 2021-02-22
已发帖子: 3
积分: 18

Re: 主线Linux用shell命令切换 OTG(分享)tiny200/licheepi nano|zero均可以使用

湘楚浪子 说:
MTLINUX 说:

刚打算要飞usbid线 测试otg,看到这个又省了一个io了。。。
经测试,正常;
感谢raspberryman!

奇怪 我的荔枝派zero V3s linux4.13 不行呢,不知道啥原因。

你要贴上错误信息才能去看原因。

离线

#9 2021-03-08 20:19:16

unturned3
会员
注册时间: 2020-07-01
已发帖子: 262
积分: 300

Re: 主线Linux用shell命令切换 OTG(分享)tiny200/licheepi nano|zero均可以使用

我试了试发现也不行,执行 echo host > ..., echo otg > ..., echo peripheral > ... 等指令都没有任何反应,内核也不打印任何信息。

我用的是aodzip的buildroot包,
https://github.com/aodzip/buildroot-tiny200

这是咋回事呢?dmesg 输出看起来usb设备初始化正常啊,没任何error之类的信息。

...
[    0.142456] usbcore: registered new interface driver usbfs
[    0.142576] usbcore: registered new interface driver hub
[    0.142724] usbcore: registered new device driver usb
...
[    0.930624] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.937159] ehci-platform: EHCI generic platform driver
[    0.942911] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.949220] ohci-platform: OHCI generic platform driver
[    0.954922] usbcore: registered new interface driver usb-storage
[    0.962008] usb_phy_generic usb_phy_generic.0.auto: usb_phy_generic.0.auto supply vcc not found, using dummy regulator
[    0.973873] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[    0.979843] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 1
[    0.988308] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.04
[    0.996574] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.003872] usb usb1: Product: MUSB HDRC host driver
[    1.008889] usb usb1: Manufacturer: Linux 5.4.92 musb-hcd
[    1.014286] usb usb1: SerialNumber: musb-hdrc.1.auto
[    1.020898] hub 1-0:1.0: USB hub found
[    1.024802] hub 1-0:1.0: 1 port detected
...

最近编辑记录 unturned3 (2021-03-08 21:01:39)

离线

#10 2021-03-08 21:09:11

unturned3
会员
注册时间: 2020-07-01
已发帖子: 262
积分: 300

Re: 主线Linux用shell命令切换 OTG(分享)tiny200/licheepi nano|zero均可以使用

啊,发现了为啥了。我不小心把 /etc/init.d/S98uMTPrd 这个脚本给禁用了,怪不得呢……

重新启用了就没问题了

离线

#11 2022-05-13 15:03:49

eckeck
会员
注册时间: 2022-04-17
已发帖子: 2
积分: 2

Re: 主线Linux用shell命令切换 OTG(分享)tiny200/licheepi nano|zero均可以使用

芒果派 R3 可用。
用的是buildroot  https://github.com/mangopi-sbc/buildroot-mangopi-r

离线

#12 2022-11-15 10:13:15

tocurd
会员
注册时间: 2021-08-14
已发帖子: 19
积分: 9

Re: 主线Linux用shell命令切换 OTG(分享)tiny200/licheepi nano|zero均可以使用

v3s 需要改下目录

echo host > /sys/devices/platform/soc/1c19000.usb/musb-hdrc.1.auto/mode 
echo peripheral > /sys/devices/platform/soc/1c19000.usb/musb-hdrc.1.auto/mode 

离线

#13 2023-02-14 22:25:24

vigour1000
会员
注册时间: 2018-11-19
已发帖子: 99
积分: 5

Re: 主线Linux用shell命令切换 OTG(分享)tiny200/licheepi nano|zero均可以使用

牛贴,明天试一下v3s,ADB没跑起来,再次确认是不是usb
otgID问题

离线

#15 2024-01-19 16:28:33

keaihuan21
会员
注册时间: 2024-01-19
已发帖子: 11
积分: 6

Re: 主线Linux用shell命令切换 OTG(分享)tiny200/licheepi nano|zero均可以使用

按照说明操作,我的pc现在可以识别到cdc的一个设备,但是作为host 插入U盘 读卡器之类的还是没有反应,哪位老板给指点一下

离线

#17 2024-03-01 17:56:26

网络孤客
会员
注册时间: 2022-06-09
已发帖子: 20
积分: 5

Re: 主线Linux用shell命令切换 OTG(分享)tiny200/licheepi nano|zero均可以使用

请教我想接USB键盘,linux内核至少需要打开哪些设置?

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn