Open liuyq opened 2 years ago
on property:sys.usb.ffs.ready=1 && property:sys.usb.config=adb && property:sys.usb.configfs=1
write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb"
symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1
write /config/usb_gadget/g1/UDC ${sys.usb.controller}
setprop sys.usb.state ${sys.usb.config}
properties, some property should not be set when the otg cable plugged out?
console:/ # getprop |egrep "sys.usb.ffs.ready|sys.usb.config|sys.usb.configfs"
[persist.sys.usb.config]: [adb]
[sys.usb.config]: [adb]
[sys.usb.configfs]: [1]
[sys.usb.controller]: [ff100000.dwc3]
[sys.usb.ffs.aio_compat]: [1]
[sys.usb.ffs.ready]: [1]
[sys.usb.mtp.device_type]: [3]
[sys.usb.state]: [adb]
console:/ #
one workaround is to stop adbd, but need to echo "none" >/config/usb_gadget/g1/UDC
to start adbd again without reboot
init.usb.configfs.rc:23) took 0ms and failed: Unable to write to file '/config/usb_gadget/g1/UDC': Unable to write file contents: Device or resource busy
s[ 6111.342202][ T2137] read descriptors
[ 6111.345882][ T2137] read strings
[ 6111.350690][ T1] init: processing action (sys.usb.config=adb && sys.usb.configfs=1 && sys.usb.ffs.ready=1) from (/system/etc/init/hw/init.usb.configfs.rc:20)
[ 6111.365786][ T1] init: Command 'symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1' action=sys.usb.config=adb && sys.usb.configfs=1 && sys.usb.ffs.ready=1 (/system/etc/init/hw/init.usb.configfs.rc:22) took 0ms and failed: symlink() failed: File exists
[ 6111.391454][ T1] init: Command 'write /config/usb_gadget/g1/UDC ${sys.usb.controller}' action=sys.usb.config=adb && sys.usb.configfs=1 && sys.usb.ffs.ready=1 (/system/etc/init/hw/init.usb.configfs.rc:23) took 0ms and failed: Unable to write to file
/config/usb_gadget/g1/UDC': Unable to write file contents: Device or resource busy
top ad[ 6112.390208][ T2137] read descriptors
[ 6112.393856][ T2137] read strings
[ 6112.398650][ T1] init: processing action (sys.usb.config=adb && sys.usb.configfs=1 && sys.usb.ffs.ready=1) from (/system/etc/init/hw/init.usb.configfs.rc:20)
[ 6112.413746][ T1] init: Command 'symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1' action=sys.usb.config=adb && sys.usb.configfs=1 && sys.usb.ffs.ready=1 (/system/etc/init/hw/init.usb.configfs.rc:22) took 0ms and failed: symlink() failed: File exists
[ 6112.439415][ T1] init: Command 'write /config/usb_gadget/g1/UDC ${sys.usb.controller}' action=sys.usb.config=adb && sys.usb.configfs=1 && sys.usb.ffs.ready=1 (/system/etc/init/hw/init.usb.configfs.rc:23) took 0ms and failed: Unable to write to file '/config/usb_gadget/g1/UDC': Unable to write file contents: Device or resource busy
console:/ # [ 7029.462634][ T78] xhci-hcd xhci-hcd.1.auto: remove, state 4
[ 7029.463503][ T279] usb 1-1: USB disconnect, device number 2
[ 7029.468483][ T78] usb usb2: USB disconnect, device number 1
[ 7029.474274][ T279] usb 1-1.1: USB disconnect, device number 3
[ 7029.479881][ T78] usb 2-1: USB disconnect, device number 2
[ 7029.491965][ T190] ueventd: LoadWithAliases was unable to load usb:v0424p5734d0202dc09dsc00dp03ic09isc00ip00in00
[ 7029.492796][ T409] healthd: battery l=85 v=3600 t=35.0 h=2 st=2 chg=au
[ 7029.493187][ T272] type=1400 audit(1647193713.567:287): avc: denied { getattr } for comm="health@2.1-serv" path="/sys/devices/platform/soc/ffd72000.i2c/i2c-1/1-004e/power_supply/tcpm-source-psy-1-004e/online" dev="sysfs" ino=30174 scontext=u:r:hal_health_default:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=0
[ 7029.493338][ T272] type=1400 audit(1647193713.567:288): avc: denied { getattr } for comm="health@2.1-serv" path="/sys/devices/platform/soc/ffd72000.i2c/i2c-1/1-004e/power_supply/tcpm-source-psy-1-004e/type" dev="sysfs" ino=30180 scontext=u:r:hal_health_default:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=0
[ 7029.493407][ T272] type=1400 audit(1647193713.567:289): avc: denied { getattr } for comm="health@2.1-serv" path="/sys/devices/platform/soc/ffd72000.i2c/i2c-1/1-004e/power_supply/tcpm-source-psy-1-004e/current_max" dev="sysfs" ino=30178 scontext=u:r:hal_health_default:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=0
[ 7029.493471][ T272] type=1400 audit(1647193713.567:290): avc: denied { getattr } for comm="health@2.1-serv" path="/sys/devices/platform/soc/ffd72000.i2c/i2c-1/1-004e/power_supply/tcpm-source-psy-1-004e/voltage_max" dev="sysfs" ino=30175 scontext=u:r:hal_health_default:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=0
[ 7029.493493][ T78] xhci-hcd xhci-hcd.1.auto: USB bus 2 deregistered
[ 7029.493511][ T78] xhci-hcd xhci-hcd.1.auto: remove, state 1
[ 7029.493520][ T78] usb usb1: USB disconnect, device number 1
[ 7029.505089][ T190] ueventd: LoadWithAliases was unable to load usb:v1D6Bp0003d0518dc09dsc00dp03ic09isc00ip00in00
[ 7029.509050][ T409] audit: audit_lost=116 audit_rate_limit=5 audit_backlog_limit=64
[ 7029.509535][ T272] type=1400 audit(1647193713.583:291): avc: denied { getattr } for comm="health@2.1-serv" path="/sys/devices/platform/soc/ffd72000.i2c/i2c-1/1-004e/power_supply/tcpm-source-psy-1-004e/online" dev="sysfs" ino=30174 scontext=u:r:hal_health_default:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=0
[ 7029.509686][ T272] type=1400 audit(1647193713.583:292): avc: denied { getattr } for comm="health@2.1-serv" path="/sys/devices/platform/soc/ffd72000.i2c/i2c-1/1-004e/power_supply/tcpm-source-psy-1-004e/type" dev="sysfs" ino=30180 scontext=u:r:hal_health_default:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=0
[ 7029.714596][ T409] audit: rate limit exceeded
[ 7029.720719][ T190] ueventd: LoadWithAliases was unable to load input:b0003v275Dp0BA6e0111-e0,1,2,4,k110,111,112,r0,1,8,B,am4,lsfw
[ 7029.732900][ T190] ueventd: LoadWithAliases was unable to load hid:b0003g0001v0000275Dp00000BA6
[ 7029.732965][ T279] usb 1-1.5: USB disconnect, device number 4
[ 7029.741752][ T190] ueventd: LoadWithAliases was unable to load usb:v275Dp0BA6d0100dc00dsc00dp00ic03isc01ip02in00
[ 7029.758344][ T190] ueventd: LoadWithAliases was unable to load usb:v0424p2740d0200dc00dsc00dp00icFFiscFFipFFin00
[ 7029.765906][ T78] xhci-hcd xhci-hcd.1.auto: USB bus 1 deregistered
[ 7029.769070][ T190] ueventd: LoadWithAliases was unable to load usb:v0424p2734d0202dc09dsc00dp02ic09isc00ip02in00
[ 7029.785972][ T190] ueventd: LoadWithAliases was unable to load usb:v1D6Bp0002d0518dc09dsc00dp01ic09isc00ip00in00
[ 7029.796841][ T190] ueventd: Loading module /vendor/lib/modules/xhci-hcd.ko with args ''
[ 7029.836078][ T190] xhci_hcd: exports duplicate symbol __SCK__tp_func_xhci_dbg_quirks (owned by kernel)
[ 7029.883380][ T78] udc ff100000.dwc3: failed to start g1: -19
[ 7029.889377][ T78] dwc3 ff100000.dwc3: failed to add gadget
[ 7029.896168][ T78] dwc3 ff100000.dwc3: failed to initialize peripheral
[ 7029.896605][ T190] ueventd: Failed to insmod '/vendor/lib/modules/xhci-hcd.ko' with args '': Exec format error
[ 7029.912918][ T190] ueventd: LoadWithAliases was unable to load /vendor/lib/modules/xhci-hcd.ko
[ 7029.921635][ T190] ueventd: LoadWithAliases was unable to load platform:xhci-hcd
[ 7030.459339][ T409] healthd: battery l=85 v=3600 t=35.0 h=2 st=2 chg=au
[ 7031.464262][ T409] healthd: battery l=85 v=3600 t=35.0 h=2 st=2 chg=au
[ 7031.465265][ T272] type=1400 audit(1647193715.539:303): avc: denied { getattr } for comm="health@2.1-serv" path="/sys/devices/platform/soc/ffd72000.i2c/i2c-1/1-004e/power_supply/tcpm-source-psy-1-004e/online" dev="sysfs" ino=30174 scontext=u:r:hal_health_default:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=0
[ 7031.471038][ T409] audit: audit_lost=126 audit_rate_limit=5 audit_backlog_limit=64
[ 7031.499355][ T272] type=1400 audit(1647193715.539:304): avc: denied { getattr } for comm="health@2.1-serv" path="/sys/devices/platform/soc/ffd72000.i2c/i2c-1/1-004e/power_supply/tcpm-source-psy-1-004e/type" dev="sysfs" ino=30180 scontext=u:r:hal_health_default:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=0
[ 7031.506851][ T409] audit: rate limit exceeded
[ 7031.539571][ T272] type=1400 audit(1647193715.539:305): avc: denied { getattr } for comm="health@2.1-serv" path="/sys/devices/platform/soc/ffd72000.i2c/i2c-1/1-004e/power_supply/tcpm-source-psy-1-004e/current_max" dev="sysfs" ino=30178 scontext=u:r:hal_health_default:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=0
[ 7031.568460][ T272] type=1400 audit(1647193715.539:306): avc: denied { getattr } for comm="health@2.1-serv" path="/sys/devices/platform/soc/ffd72000.i2c/i2c-1/1-004e/power_supply/tcpm-source-psy-1-004e/voltage_max" dev="sysfs" ino=30175 scontext=u:r:hal_health_default:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=0
[ 7031.597242][ T272] type=1400 audit(1647193715.543:307): avc: denied { getattr } for comm="health@2.1-serv" path="/sys/devices/platform/soc/ffd72000.i2c/i2c-1/1-004e/power_supply/tcpm-source-psy-1-004e/online" dev="sysfs" ino=30174 scontext=u:r:hal_health_default:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=0
console:/ #
4.14-stable does not have such problem, serial log output when the type-c is unplugged:
console:/ $
console:/ $ [ 186.390162] [I/hisi_pd] TPC-I:[CC_Alert] 0/0
[ 186.395532] [I/hisi_pd] [TCPC-I]ps_change=1
[ 186.399876] [I/hisi_pd] TPC-I:** UnattachWait.PE
[ 186.404642] [I/hisi_pd] TPC-I:Attached-> NULL
[ 186.409116] [E/hisi_pd] pd_dpm_handle_pe_event:!!!,event=7,+++
[ 186.414979] [I/hisi_pd] pd_dpm_set_typec_state = 1
[ 186.419813] [I/hisi_pd] [TCPC-I]usb_port_detached
[ 186.424645] [I/hisi_pd] TPC-I:[CC_Change] 0/0
[ 186.429108] [E/hisi_pd] typec_wait_ps_change: typec_wait_ps_change!!!+++++++++++
[ 186.436546] [E/hisi_pd] typec_wait_ps_change: typec_wait_ps_change!!!-----------
[ 186.443955] [E/hisi_pd] typec_wait_ps_change: typec_wait_ps_change!!!+++++++++++
[ 186.451369] [E/hisi_pd] typec_wait_ps_change: typec_wait_ps_change!!!-----------
[ 186.458781] [E/hisi_pd] typec_unattached_power_entry:!!!+++++++++++
[ 186.465090] [E/hisi_pd] pd_dpm_handle_pe_event:!!!,event=8,+++
[ 186.465103] [I/hisi_pd] pd_dpm_report_device_detach
[ 186.465333] [E/hisi_pd] tcpci_disable_vbus_control: !!!++++++++
[ 186.465335] [E/hisi_pd] pd_dpm_handle_pe_event:!!!,event=0,+++
[ 186.465338] [E/hisi_pd] typec_unattached_power_entry:!!!-----------
[ 186.465349] [E/GPIO_HUB] gpio_hub_switch_to_hub: switch to hub
[ 186.465353] [I/GPIO_HUB] gpio_hub_change_typec_power: typec power no change
[ 186.465363] [USB3][hisi_usb_otg_event]hisi_usb_otg_event in:1
[ 186.465366] [USB3][hisi_usb_otg_event]hisi_usb_otg_event in otg:1
[ 186.465369] [USB3][hisi_usb_otg_event]event: 1
[ 186.465379] [USB3][hisi_usb_otg_event]hisi_usb_otg_event in:2
[ 186.465381] [USB3][hisi_usb_otg_event]hisi_usb_otg_event in otg:2
[ 186.465383] [USB3][hisi_usb_otg_event]event: 2
[ 186.465386] [USB3][hisi_usb_otg_event]schedule event_work wait:2]
[ 186.465390] [USB3][event_work]+
[ 186.465392] [I/hisi_pd] TPC-I:** Unattached.SNK
[ 186.465394] [USB3][handle_event][handle_event] type: 1
[ 186.465398] [dwc3_otg_work]+
[ 186.465398] evt = 4
[ 186.465401] [dwc3_otg_stop_peripheral]+
[ 186.465818] [dwc3_otg_stop_peripheral]-
[ 186.465820] [dwc3_suspend_device] +
[ 186.466028] [dwc3_suspend_device] -
[ 186.466030] [dwc3_otg_work]-
[ 186.466032] [I/hisi_pd] pd_dpm_report_bc12 : PD_WAKE_UNLOCK
[ 186.466036] [I/hisi_pd] pd_dpm_report_bc12 : event (4)
[ 186.466037] [E/hisi_pd] pd_dpm_vbus_notifier_call: pd_dpm_vbus_notifier_call!!!,++++
[ 186.466040] [USB3][hisi_dwc3_wake_unlock]usb otg wake unlock
[ 186.466042] [USB3][handle_event]hisi usb status: DEVICE -> OFF
[ 186.466044] [USB3][handle_event][handle_event] type: 2
[ 186.466046] [USB3][set_vbus_power]set port power 1
[ 186.466047] [dwc3_otg_work]+
[ 186.466047] evt = 2
[ 186.466049] [dwc3_resume_device] +
[ 186.468821] android_work: sent uevent USB_STATE=DISCONNECTED
[ 186.471659] [dwc3_resume_device] -
[ 186.476046] [E/hisi_pd] pd_dpm_vbus_notifier_call: pd_dpm_vbus_notifier_call!!!,++++
[ 186.481989] [dwc3_otg_start_host]+
[ 186.580584] android_work: did not send uevent (0 0 (null))
[ 186.583257] ueventd: LoadWithAliases was unable to load platform:xhci-hcd
[ 186.606346] xhci-hcd xhci-hcd.0.auto: xHCI Host Controller
[ 186.668534] xhci-hcd xhci-hcd.0.auto: new USB bus registered, assigned bus number 1
[ 186.679205] read descriptors
[ 186.679217] android_work: did not send uevent (0 0 (null))
[ 186.680121] xhci-hcd xhci-hcd.0.auto: hcc params 0x0220fe65 hci version 0x110 quirks 0x0000000000010010
[ 186.680145] xhci-hcd xhci-hcd.0.auto: irq 102, io mem 0xff100000
[ 186.680290] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[ 186.680294] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 186.680297] usb usb1: Product: xHCI Host Controller
[ 186.680300] usb usb1: Manufacturer: Linux 4.14.282-00288-g0b60c8b1c4cc xhci-hcd
[ 186.680303] usb usb1: SerialNumber: xhci-hcd.0.auto
[ 186.682103] read strings
[ 186.682677] hub 1-0:1.0: USB hub found
[ 186.682947] init: processing action (sys.usb.config=adb && sys.usb.configfs=1 && sys.usb.ffs.ready=1) from (/system/etc/init/hw/init.usb.configfs.rc:20)
[ 186.683703] init: Command 'symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1' action=sys.usb.config=adb && sys.usb.configfs=1 && sys.usb.ffs.ready=1 (/system/etc/init/hw/init.usb.configfs.rc:22) took 0ms and failed: symlink() failed: File exists
[ 186.685592] dwc3 ff100000.dwc3: failed to enable ep0out
[ 186.786200] ueventd: LoadWithAliases was unable to load usb:v1D6Bp0002d0414dc09dsc00dp01ic09isc00ip00in00
[ 186.790390] hub 1-0:1.0: 1 port detected
[ 186.800754] xhci-hcd xhci-hcd.0.auto: xHCI Host Controller
[ 186.801241] ueventd: LoadWithAliases was unable to load usb:v1D6Bp0002d0414dc09dsc00dp01ic09isc00ip00in00
[ 186.806260] xhci-hcd xhci-hcd.0.auto: new USB bus registered, assigned bus number 2
[ 186.823547] xhci-hcd xhci-hcd.0.auto: Host supports USB 3.0 SuperSpeed
[ 186.830303] usb usb2: We don't know the algorithms for LPM for this host, disabling LPM.
[ 186.838517] usb usb2: New USB device found, idVendor=1d6b, idProduct=0003
[ 186.845346] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 186.852584] usb usb2: Product: xHCI Host Controller
[ 186.857470] usb usb2: Manufacturer: Linux 4.14.282-00288-g0b60c8b1c4cc xhci-hcd
[ 186.864801] usb usb2: SerialNumber: xhci-hcd.0.auto
[ 186.869939] hub 2-0:1.0: USB hub found
[ 186.871135] ueventd: LoadWithAliases was unable to load usb:v1D6Bp0003d0414dc09dsc00dp03ic09isc00ip00in00
[ 186.873703] hub 2-0:1.0: 1 port detected
[ 186.887714] [dwc3_otg_start_host]-
[ 186.888614] ueventd: LoadWithAliases was unable to load usb:v1D6Bp0003d0414dc09dsc00dp03ic09isc00ip00in00
[ 186.891184] [dwc3_otg_work]-
[ 186.901571] ueventd: LoadWithAliases was unable to load platform:xhci-hcd
[ 186.903617] [USB3][hisi_dwc3_wake_lock]usb otg wake lock
[ 186.915718] [USB3][handle_event]hisi usb_status: OFF -> HOST
[ 186.921379] [USB3][event_work]-
[ 187.055722] usb 1-1: new high-speed USB device number 2 using xhci-hcd
[ 187.233264] usb 1-1: New USB device found, idVendor=0424, idProduct=2734
[ 187.240218] alloc_contig_range: [20c8c, 20c8d) PFNs busy
[ 187.245691] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 187.252841] usb 1-1: Product: USB2734
[ 187.256521] usb 1-1: Manufacturer: Microchip Tech
[ 187.264801] alloc_contig_range: [20c8c, 20c8d) PFNs busy
[ 187.270382] alloc_contig_range: [20ca0, 20ca1) PFNs busy
[ 187.275887] alloc_contig_range: [20c8c, 20c8d) PFNs busy
[ 187.281263] alloc_contig_range: [20ca0, 20ca1) PFNs busy
[ 187.312654] ueventd: LoadWithAliases was unable to load usb:v0424p2734d0202dc09dsc00dp02ic09isc00ip01in00
[ 187.322380] hub 1-1:1.0: USB hub found
[ 187.326495] hub 1-1:1.0: 5 ports detected
[ 187.330673] alloc_contig_range: [20c8c, 20c8d) PFNs busy
[ 187.336101] alloc_contig_range: [20ca0, 20ca1) PFNs busy
[ 187.341924] alloc_contig_range: [20c8c, 20c8d) PFNs busy
[ 187.347297] alloc_contig_range: [20ca0, 20ca1) PFNs busy
[ 187.386260] ueventd: LoadWithAliases was unable to load usb:v0424p2734d0202dc09dsc00dp02ic09isc00ip02in00
[ 187.401915] usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd
[ 187.428724] usb 2-1: New USB device found, idVendor=0424, idProduct=5734
[ 187.435453] usb 2-1: New USB device strings: Mfr=2, Product=3, SerialNumber=0
[ 187.442616] usb 2-1: Product: USB5734
[ 187.446293] usb 2-1: Manufacturer: Microchip Tech
[ 187.455863] ueventd: LoadWithAliases was unable to load usb:v0424p5734d0202dc09dsc00dp03ic09isc00ip00in00
[ 187.465689] hub 2-1:1.0: USB hub found
[ 187.469767] hub 2-1:1.0: 5 ports detected
[ 187.475665] ueventd: LoadWithAliases was unable to load usb:v0424p5734d0202dc09dsc00dp03ic09isc00ip00in00
[ 187.597943] alloc_contig_range: [20ca0, 20ca1) PFNs busy
[ 187.681574] usb 1-1.1: new low-speed USB device number 3 using xhci-hcd
[ 187.800050] usb 1-1.1: New USB device found, idVendor=093a, idProduct=2510
[ 187.806992] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 187.814345] usb 1-1.1: Product: USB Optical Mouse
[ 187.819058] usb 1-1.1: Manufacturer: PixArt
[ 187.861356] input: PixArt USB Optical Mouse as /devices/platform/soc/ff200000.hisi_usb/ff100000.dwc3/xhci-hcd.0.auto/usb1/1-1/1-1.1/1-1.1:1.0/0003:093A:2510.0001/input/input1
[ 187.883003] hid-generic 0003:093A:2510.0001: input,hidraw0: USB HID v1.11 Mouse [PixArt USB Optical Mouse] on usb-xhci-hcd.0.auto-1.1/input0
[ 187.977684] usb 1-1.5: new high-speed USB device number 4 using xhci-hcd
[ 188.083785] usb 1-1.5: New USB device found, idVendor=0424, idProduct=2740
[ 188.090930] usb 1-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 188.098584] usb 1-1.5: Product: Hub Controller
[ 188.103053] usb 1-1.5: Manufacturer: Microchip Tech
console:/ # getprop |grep usb
console:/ #
console:/ # getprop |grep usb
console:/ #
https://www.21ic.com/evm/evaluate/MCU/201706/724733_2.htm
hikey960-usb connections HiKey960_Schematics.pdf
when the usb otg cable plugged out, it shows the "Unable to write to file '/config/usb_gadget/g1/UDC'" message infinitely on the kernel console side.