问题原因
因为之前没有电源线,一直使用OTG口进行供电,找到了条PSP的电源线,发现可以使用,也算是闲置物品再利用吧。测试时发现OTG功能用不了,接下来继续解决。
查看原理图,确认管脚
查看原理图可以确认,OTG部分使用的是USB0模块,并且有IDDET,检测端口,这个端口是用来区分OTG所扮演的角色,是HOST还是Device。电平触发。IDDET管脚连接到芯片的PC6口。
sys_config.fex配置
找到OTG配置项
;--------------------------------
;[usbc0]: usbc0 configuration.
;usb_used: usb controller enable. 0-disable, 1-enable.
;usb_port_type: usb mode. 0-device, 1-host, 2-otg.
;usb_detect_type: usb hotplug detect mode. 0-none, 1-vbus/id detect, 2-id/dpdm detect.
;usb_detect_mode: usb otg switch has two config. 0-thread scan, 1-id gpio interrupt.
;usb_id_gpio: usb id detect IO.
;usb_det_vbus_gpio: USB DET_VBUS has two config. (1)gpio pin; (2)"axp_ctrl", use axp intf.
;usb_drv_vbus_gpio: USB DRY_VBUS has two config. (1)gpio pin; (2)"axp_ctrl", use axp intf.
;--------------------------------
;--------------------------------
;--- USB0 CONFIG
;--------------------------------
[usbc0]
usbc0_used = 1
usb_port_type = 1
usb_detect_type = 1
usb_detect_mode = 0
usb_id_gpio =
usb_det_vbus_gpio =
usb_drv_vbus_gpio = port:PL05<1><0><default><1>
usb_host_init_state = 1
usb_regulator_io = "nocare"
usb_wakeup_suspend = 0
;--- USB Device
usb_luns = 3
usb_serial_unique = 0
usb_serial_number = "20080411"
rndis_wceis = 1
下面解析下每项含义
usbc0_used = 是否使能
usb_port_type = USB端口类型,0-device only,1-host only,2-otg
usb_detect_type = usb hotplug detect mode. 0-none, 1-vbus/id detect, 2-id/dpdm detect.
usb_detect_mode = usb otg switch has two config. 0-thread scan, 1-id gpio interrupt.
usb_id_gpio = usb id pin配置
usb_det_vbus_gpio = usb det vbus pin配置
usb_drv_vbus_gpio = usb drv vbus pin配置
usb_host_init_state = host only模式下,host端口初始化状态,0-初始化后usb不工作,1-初始化后usb工作
usb_regulator_io = usb供电的regulator gpio
usb_wakeup_suspend = 是否支持usb唤醒功能
usb_luns = 使用mass storage功能时盘符数量
usb_serial_unique = usb device的序列号是否唯一:1唯一,使用chip id;0相同,使用usb_serial_number制定
usb_serial_number = usb device的序列号
rndis_wceis = wireless rndis使能标志,1使能;0禁止。
从代码中看到,USB0默认被配置成为host模式,目前没有OTG接头,无法测试Host模式,接下来我们需要按照原理图配置成OTG模式
lemon@ubuntu:~/Develop/OrangePi_Lite2/lichee$ git diff tools/pack/chips/sun50iw6p1/configs/petrel-p1/sys_config.fex
diff --git a/lichee/tools/pack/chips/sun50iw6p1/configs/petrel-p1/sys_config.fex b/lichee/tools/pack/chips/sun50iw6p1/configs/petrel-p1/sys_config.fex
index 0e43e22..dc74d30 100755
--- a/lichee/tools/pack/chips/sun50iw6p1/configs/petrel-p1/sys_config.fex
+++ b/lichee/tools/pack/chips/sun50iw6p1/configs/petrel-p1/sys_config.fex
@@