My environment:
Self-developed baseboards based on Jetson Orin Nx core boards
Jetson_Linux_R36.2.0_aarch64.tbz2
VM development environment for sdk - ubuntu20.04
USB pins I used:
Currently my type-C host mode works fine, but I want to use the OTG_ID pin in the schematic to achieve type-C device mode work, how do I modify the device tree?
At present, the usb device tree uses the default configuration of the sdk, and I have not modified it.
Is this possible? Or is there another way to implement otg (host/device)? Thanks
Ideally you would need a type C controller. Only ID pin is not sufficient.
So how do I implement this, modify the device tree?
This is my device tree:
myJetsonOrinNx_20240711.dts.txt (307.7 KB)
I mean you need a hardware design that includes a usb type C controller on your board…
as Orin Nano devkit, it has fusb301 on it to make USB type C work…
We cannot realize the ideal way you said for the time being, and our hardware design has been completed. This port is currently directly connected to the cpu.
Is there another way I can implement the device mode for this port? For example:
-
Detect ID pin in rootfs and manually switch host/device mode
Problem: We can’t find this usb in the toggle debug port
$ find /sys/devices/platform/ -name otg
/sys/devices/platform/bus@0/3550000.usb/udc/3550000.usb/is_otg
It should be similar to:
sudo echo 0 > /sys/devices/platform/soc/xxxxx.usb/otg_mode
-
Modify the driver to use normal gpio instead of TYPEC_ID pin to implement Type-C host/device mode automatic switch
Which way is easier to implement, please help me to look at the problem, or there is another way better
我用中文解釋一下好了… 你的hardware design不足以做出一個功能完全的type C port…
Orin Nano/AGX devkit的type C port都有使用type C controller/PD controller.
你可以先參考Xavier NX的device tree… Xavier NX用的是跟你差不多的設計但是micro USB.
上图是我们的Type-C端口原理图接口部分,这个Type-C的主机模式我们已经实现在用了,如果要使用完整的type-C功能必须要用type C controller/PD controller吗?
Xavier NX的type-C是实现了完整的otg(host/device)吗?我们之前的XavierNx只使用了host,没有做otg
Xavier NX devkit沒有type C, 只有micro USB.
Orin AGX/NX/Nano devkit才有type C.
但是Orin AGX/NX/Nano devkit的設計有使用type C controller/PD controller.
你說你的設計沒有, 所以你只能用看看Xavier NX devkit上面device tree的設定看看…
- Xavier NX devkit的micro USB是否是支持otg的?
因為硬體設計只有ID pin沒有vbus_det 所以他只支援device mode.
-
这个USB0同时也是个烧录口,我们使用它烧录过镜像,是否意味着当前硬件设计是支持device模式的?
Recovery mode是用hardware pin強制讓板子進入device mode. 這跟你的usb port硬體有沒有設計對其實沒有直接關聯. 我們也看過很多用戶的usb port設計上有錯誤, 但flash還是可以執行. 開機進OS之後錯誤就跟著出來了
-
我想在目前的硬件设计基础上,能否调整设备树使otg调试接口暴露出来?eg:
sudo echo 0 > /sys/devices/platform/soc/xxxx.usb/otg_mode
Jetson上的node會是這個樣子 “/sys/class/usb_role/usb2-0-role-switch/role”. 但你的device tree得寫對… 所以才請你先照Xavier NX device tree寫看看…
完整的文件:
https://docs.nvidia.com/jetson/archives/r35.5.0/DeveloperGuide/HR/JetsonModuleAdaptationAndBringUp/JetsonAgxOrinSeries.html?highlight=universal#porting-the-universal-serial-bus
开机之后,进行操作:
# sudo echo device > /sys/class/usb_role/usb2-0-role-switch/role
然后插入usb线连接设备-主机,主机出现虚拟网卡:
dmesg设备信息打印:
[ 8027.078604] tegra-xudc 3550000.usb: EP 5 (type: intr, dir: in) enabled
[ 8027.078632] tegra-xudc 3550000.usb: EP 3 (type: bulk, dir: in) enabled
[ 8027.078648] tegra-xudc 3550000.usb: EP 2 (type: bulk, dir: out) enabled
[ 8027.078760] tegra-xudc 3550000.usb: EP 9 (type: intr, dir: in) enabled
[ 8027.078777] tegra-xudc 3550000.usb: EP 7 (type: bulk, dir: in) enabled
[ 8027.078791] tegra-xudc 3550000.usb: EP 4 (type: bulk, dir: out) enabled
[ 8027.078966] tegra-xudc 3550000.usb: EP 15 (type: intr, dir: in) enabled
[ 8027.078999] tegra-xudc 3550000.usb: EP 11 (type: bulk, dir: in) enabled
[ 8027.079221] tegra-xudc 3550000.usb: EP 6 (type: bulk, dir: out) enabled
[ 8027.079680] IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready
[ 8027.082030] l4tbr0: port 1(usb0) entered blocking state
[ 8027.082044] l4tbr0: port 1(usb0) entered forwarding state
[ 8027.082175] IPv6: ADDRCONF(NETDEV_CHANGE): l4tbr0: link becomes ready
[ 8027.949839] tegra-xudc 3550000.usb: setup request failed: -22
[ 8027.950691] tegra-xudc 3550000.usb: EP 13 (type: bulk, dir: in) enabled
[ 8027.950713] tegra-xudc 3550000.usb: EP 8 (type: bulk, dir: out) enabled
[ 8027.950882] IPv6: ADDRCONF(NETDEV_CHANGE): usb1: link becomes ready
[ 8027.951061] l4tbr0: port 2(usb1) entered blocking state
[ 8027.951070] l4tbr0: port 2(usb1) entered forwarding state
usb0/1设备无法访问,我配置设备和主机的网口同网段仍不能ping通。
我仿照JetsonXavierNx修改了下设备树:
ports {
usb2-0 {
status = "okay";
mode = "otg";
vbus-supply = <0xe9>;
usb-role-switch;
+ connector {
+ compatible = "usb-c-connector";
+ label = "USB-C";
+ data-role = "dual";
+ power-role = "dual";
+ typec-power-opmode = "default";
+ vbus-gpio = <0xe5 0x99 0x00>; //gpio0;
+ id-gpio = <0xf3 0x10 0x01>; //gpio3;
+ };
port {
endpoint {
remote-endpoint = <0xea>;
phandle = <0xf4>;
};
};
};
重新编译设备树并覆盖/boot/dtb/kernel_tegra234-p3768-0000+p3767-0000-nv.dtb并重启后,otg模式的device效果和上面一模一样,仍无法工作。
问题:
1.[ 8027.949839] tegra-xudc 3550000.usb: setup request failed: -22 是usb0/1设备无法工作的原因吗?如果是,如何修改;如果其他原因,帮忙指明及解决方法,谢谢
為什麼會有usb0/usb1? 你的xudc設定寫了什麼?
remote-endpoint = <0xea>; 又是指到哪裡去?
為什麼會有usb0/usb1?
这个是sdk原始配置出来就有两个出来,开发板当时也是这样,我们没做修改
remote-endpoint = <0xea>;
这个好像应该去掉?指到一个usb控制器那里了,我们并无这个设备
我修改之后测试:
myJetsonOrinNx_20240718.dts.txt (308 KB)
现象依旧,且usb0/1不能ping通主机
# dmesg | tail -20
[ 103.021481] loop1: detected capacity change from 0 to 8
[ 229.719927] tegra-xudc 3550000.usb: EP 5 (type: intr, dir: in) enabled
[ 229.719956] tegra-xudc 3550000.usb: EP 3 (type: bulk, dir: in) enabled
[ 229.719972] tegra-xudc 3550000.usb: EP 2 (type: bulk, dir: out) enabled
[ 229.720080] tegra-xudc 3550000.usb: EP 9 (type: intr, dir: in) enabled
[ 229.720097] tegra-xudc 3550000.usb: EP 7 (type: bulk, dir: in) enabled
[ 229.720110] tegra-xudc 3550000.usb: EP 4 (type: bulk, dir: out) enabled
[ 229.720281] tegra-xudc 3550000.usb: EP 15 (type: intr, dir: in) enabled
[ 229.720375] tegra-xudc 3550000.usb: EP 11 (type: bulk, dir: in) enabled
[ 229.720400] tegra-xudc 3550000.usb: EP 6 (type: bulk, dir: out) enabled
[ 229.720474] IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready
[ 229.720656] l4tbr0: port 1(usb0) entered blocking state
[ 229.720661] l4tbr0: port 1(usb0) entered forwarding state
[ 229.720746] IPv6: ADDRCONF(NETDEV_CHANGE): l4tbr0: link becomes ready
[ 229.754167] tegra-xudc 3550000.usb: setup request failed: -22
[ 229.755202] tegra-xudc 3550000.usb: EP 13 (type: bulk, dir: in) enabled
[ 229.755216] tegra-xudc 3550000.usb: EP 8 (type: bulk, dir: out) enabled
[ 229.755316] IPv6: ADDRCONF(NETDEV_CHANGE): usb1: link becomes ready
[ 229.755409] l4tbr0: port 2(usb1) entered blocking state
[ 229.755414] l4tbr0: port 2(usb1) entered forwarding state
我们这个port只用到了usb2.0,没有用到usb3.0
我删除了xudc下面的usb3.0部分,编译并替换dtb后重启设备,效果仍一样: