system reboot when using gadgetfs

My program is ok on other platform(nanoPC-T3). But when run on TX2, system reboot without any infomation.

The time of rebooting is when the host request for USB string descriptor. The program can’t write the string descriptor to the ep0.

I guess the tegra-xudc drvier must be something wrong.

And I want to know what is the deference between tegra-xudc and tegra-udc ?

Hi mailtowubo,
Please share detail about your case.

We support mass storage mode:
https://devtalk.nvidia.com/default/topic/1014096/jetson-tx2/how-to-set-tx2-otg-usb-as-device-mode-/post/5192587/#5192587
https://devtalk.nvidia.com/default/topic/1014096/jetson-tx2/how-to-set-tx2-otg-usb-as-device-mode-/post/5205500/#5205500

don’t support uvc video mode:
https://devtalk.nvidia.com/default/topic/1023155/jetson-tx1/tegra-xudc-endpoint-transfer-mode/post/5209829/#5209829

I config the gadget driver as follow:
http://7d9p49.com1.z0.glb.clouddn.com/kernel-config.JPG

And I got some kernel log like this:

root@tegra-ubuntu:/home/nvidia# cat /proc/kmsg 
<7>[  121.459984] tegra-xudc-new 3550000.xudc: EVENT: ffffff80097c3170, lo = 0x3190680, hi = 0xff0409, status = 0x1000007, control = 0xfc01
<7>[  126.460366] tegra-xudc-new 3550000.xudc: EVENT: ffffff80097c3180, lo = 0x3190680, hi = 0x20409, status = 0x1000008, control = 0xfc01
<7>[  131.461036] tegra-xudc-new 3550000.xudc: EVENT: ffffff80097c3190, lo = 0x3650680, hi = 0xff0409, status = 0x1000009, control = 0xfc01
<7>[  136.461574] tegra-xudc-new 3550000.xudc: EVENT: ffffff80097c31a0, lo = 0x3650680, hi = 0x20409, status = 0x100000a, control = 0xfc01
<7>[  141.471007] tegra-xudc-new 3550000.xudc: EVENT: ffffff80097c31b0, lo = 0x10900, hi = 0x0, status = 0x100000b, control = 0xfc01
<4>[  144.055013] ------------[ cut here ]------------
<7>[  144.117072] x27: ffffffc0011d4b28 x26: ffffffc0011a22c0 
<7>[  144.127768] x23: 0000000000000000 x22: 0000000000000000 
<7>[  144.138459] x19: ffffffc0011a2248 x18: ffffffc000b76eb8 
<7>[  144.149149] x15: 0000000000000001 x14: 0000000000000007 
<7>[  144.159841] x11: ffffffc0011ec728 x10: ffffffc0013a9e88 
<7>[  144.170534] x7 : ffffffc001214df8 x6 : 0000000000000035 
<7>[  144.181225] x3 : 0000000000000000 x2 : 0000000000010001 
<7>[  144.191916] 
<4>[  144.193417] ---[ end trace b458ed76f322223f ]---
<0>[  144.198037] Call trace:
<7>[  144.200497] [<ffffffc00013c850>] watchdog_timer_fn+0x234/0x340
<7>[  144.206344] [<ffffffc000107278>] __hrtimer_run_queues+0x140/0x350
<7>[  144.218206] [<ffffffc0008c0578>] tegra186_timer_isr+0x24/0x30
<7>[  144.230232] [<ffffffc0000f4d60>] handle_irq_event+0x44/0x74
<7>[  144.241649] [<ffffffc0000f4134>] generic_handle_irq+0x24/0x38
<7>[  144.253238] [<ffffffc0000815dc>] gic_handle_irq+0x5c/0xb4
<7>[  144.263448] [<ffffffc00079fd80>] cpuidle_enter+0x18/0x20
<7>[  144.273996] [<ffffffc0000e7a34>] cpu_startup_entry+0x178/0x33c
<7>[  144.284815] [<ffffffc00108697c>] start_kernel+0x39c/0x3b0
<7>[  153.732277] tegra-xudc-new 3550000.xudc: PRC, PORTSC = 0x600463
<6>[  153.738247] gadgetfs: disconnected
<7>[  153.741659] gadgetfs: event[0] = 2
<7>[  153.745395] tegra-xudc-new 3550000.xudc: PLC, PORTSC = 0x400463
<7>[  153.751322] tegra-xudc-new 3550000.xudc: port suspend
<6>[  153.756378] gadgetfs: suspended from state 2
<7>[  153.760652] gadgetfs: event[1] = 4
<7>[  153.764195] tegra-xudc-new 3550000.xudc: PORTSC = 0x463
<7>[  156.134652] tegra-xudc-new 3550000.xudc: EVENT: ffffff80097c31d0, lo = 0x1000000, hi = 0x0, status = 0x1000000, control = 0x8801
<7>[  156.146241] tegra-xudc-new 3550000.xudc: PRC, PORTSC = 0x200d31
<7>[  156.152182] tegra-xudc-new 3550000.xudc: PORTSC = 0xd31
<7>[  156.187066] tegra-xudc-new 3550000.xudc: EVENT: ffffff80097c31e0, lo = 0x1000000, hi = 0x0, status = 0x1000000, control = 0x8801
<7>[  156.204911] tegra-xudc-new 3550000.xudc: PLC, PORTSC = 0x400463
<7>[  156.210838] tegra-xudc-new 3550000.xudc: port suspend
<6>[  156.215895] gadgetfs: suspended from state 2
<7>[  156.220169] gadgetfs: discard old event[1] 4
<7>[  156.224442] gadgetfs: event[1] = 4
<7>[  156.227978] tegra-xudc-new 3550000.xudc: PORTSC = 0x463
<7>[  156.771518] tegra-xudc-new 3550000.xudc: EVENT: ffffff80097c31f0, lo = 0x1000000, hi = 0x0, status = 0x1000000, control = 0x8801
<7>[  156.783094] tegra-xudc-new 3550000.xudc: PRC, PORTSC = 0x200d31
<7>[  156.789028] tegra-xudc-new 3550000.xudc: PORTSC = 0xd31
<7>[  156.831839] tegra-xudc-new 3550000.xudc: EVENT: ffffff80097c3200, lo = 0x1000000, hi = 0x0, status = 0x1000000, control = 0x8801
<7>[  156.849579] tegra-xudc-new 3550000.xudc: PORTSC = 0xc03
<7>[  156.899148] tegra-xudc-new 3550000.xudc: EVENT: ffffff80097c3210, lo = 0x1000680, hi = 0x400000, status = 0x1000000, control = 0xfc01
<6>[  156.911149] gadgetfs: connected
<7>[  156.914298] gadgetfs: event[0] = 1
<7>[  156.917736] tegra-xudc-new 3550000.xudc: TRANSFER: ffffff800231e0b0, lo = 0x8003b340, hi = 0x0, status = 0x12, control = 0x10c25
<7>[  156.929295] tegra-xudc-new 3550000.xudc: ring doorbell: 0x0
<7>[  156.934956] tegra-xudc-new 3550000.xudc: EVENT: ffffff80097c3220, lo = 0x800130b0, hi = 0x0, status = 0x1000000, control = 0x8001
<7>[  156.946625] tegra-xudc-new 3550000.xudc: trb_in_request: request ffffff800231e0b0 -> ffffff800231e0b0; trb ffffff800231e0b0
<7>[  156.957752] tegra-xudc-new 3550000.xudc: bytes transferred 18 / 18
<7>[  156.963940] tegra-xudc-new 3550000.xudc: completing request ffffffc1bce5b600 on ep 0 with status 0
<7>[  156.972930] tegra-xudc-new 3550000.xudc: TRANSFER: ffffff800231e0c0, lo = 0x0, hi = 0x0, status = 0x0, control = 0x1025
<7>[  156.983708] tegra-xudc-new 3550000.xudc: ring doorbell: 0x0
<7>[  156.989352] tegra-xudc-new 3550000.xudc: EVENT: ffffff80097c3230, lo = 0x800130c0, hi = 0x0, status = 0x1000000, control = 0x8001
<7>[  157.101717] tegra-xudc-new 3550000.xudc: EVENT: ffffff80097c3250, lo = 0x20500, hi = 0x0, status = 0x1000000, control = 0xfc01
<7>[  157.113116] tegra-xudc-new 3550000.xudc: USB_REQ_SET_ADDRESS
<7>[  157.118780] tegra-xudc-new 3550000.xudc: set address: 2
<7>[  157.124021] tegra-xudc-new 3550000.xudc: TRANSFER: ffffff800231e0d0, lo = 0x0, hi = 0x0, status = 0x0, control = 0x11025
<7>[  157.134886] tegra-xudc-new 3550000.xudc: ring doorbell: 0x0
<7>[  157.140547] tegra-xudc-new 3550000.xudc: EVENT: ffffff80097c3260, lo = 0x800130d0, hi = 0x0, status = 0x1000000, control = 0x8001
<7>[  157.193474] gadgetfs: event[0] = 1
<7>[  157.226133] tegra-xudc-new 3550000.xudc: trb_in_request: request ffffff800231e0e0 -> ffffff800231e0e0; trb ffffff800231e0e0
<7>[  157.291996] tegra-xudc-new 3550000.xudc: bytes transferred 0 / 0
<7>[  157.359163] tegra-xudc-new 3550000.xudc: bytes transferred 9 / 9
<7>[  157.413725] tegra-xudc-new 3550000.xudc: bytes transferred 0 / 0
<7>[  157.481059] tegra-xudc-new 3550000.xudc: bytes transferred 32 / 32
<7>[  157.535788] tegra-xudc-new 3550000.xudc: bytes transferred 0 / 0
<7>[  162.522080] tegra-xudc-new 3550000.xudc: EVENT: ffffff80097c3310, lo = 0x3000680, hi = 0x20000, status = 0x1000005, control = 0xfc01
<7>[  167.541749] tegra-xudc-new 3550000.xudc: EVENT: ffffff80097c3320, lo = 0x10900, hi = 0x0, status = 0x1000006, control = 0xfc01
<7>[  179.791218] tegra-xudc-new 3550000.xudc: EVENT: ffffff80097c3330, lo = 0x1000000, hi = 0x0, status = 0x1000000, control = 0x8801

Can you please share steps to reproduce the issue on r28.1? We would like to reproduce the issue for further checking.

We also facing same issue.

Using “http://www.linux-usb.org/gadget/usb.c” program try to set up gadgetfs on Jetson TX2.

Update VID PID:
#define DRIVER_VENDOR_NUM 0x0955
#define DRIVER_PRODUCT_NUM 0x7020

Also update autoconfig function for Nvidia :

[i]/* Nvidia processors, high/full speed */
} else if (stat (DEVNAME = "tegra-xudc", &statb) == 0) {
	HIGHSPEED = 1;
	device_desc.bcdDevice = __constant_cpu_to_le16 (0x0001);

	fs_source_desc.bEndpointAddress
		= hs_source_desc.bEndpointAddress
		= USB_DIR_IN | 1;
	EP_IN_NAME = "ep1in-bulk";
	fs_sink_desc.bEndpointAddress
		= hs_sink_desc.bEndpointAddress
		= USB_DIR_OUT | 2;
	EP_OUT_NAME = "ep2out-bulk";

	source_sink_intf.bNumEndpoints = 3;
	fs_status_desc.bEndpointAddress
		= hs_status_desc.bEndpointAddress
		= USB_DIR_IN | 3;
	EP_STATUS_NAME = "ep3in-int";

} 

[/i]After run program get output at Jetson TX2 terminal:

/dev/gadget/musb_hdrc ep0 configured
serial=“1.3”
** Thu Jan 1 05:19:27
CONNECT high speed
DISCONNECT
CONNECT high speed
SETUP 80.06 v0300 i0000 255

Output log At Linux host PC is:

usb 3-2: new high-speed USB device number 48 using xhci_hcd
usb 3-2: string descriptor 0 read error: -110
usb 3-2: New USB device found, idVendor=0955, idProduct=7020
usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 3-2: can’t set config #2, error -110

After debugging usb.c step by step find that program is stuck into function “handle_control”. Get event of USB_REQ_GET_DESCRIPTOR then USB_DT_STRING is called but after “status = write (fd, buf, tmp);” Jetson TX2 is stuck and reboot.

What is the reason of TX2 stuck & getting error response on host PC?

What transfer mode is used at the time of the failure?

We observe that failure happen at the time of Endpoint zero(enumeration) functionality is called. Means when device & configuration descriptor is write from device to host. So enumeration is happen using control mode.

But in descriptor we define two bulk endpoint & one interrupt endpoint.

After searching related to error -110, we got two different errno.h.

One indicate 110 as :
#define ESHUTDOWN 110 /* Can’t send after socket shutdown */

Second file indicate 110 as :
#define ETIMEDOUT 110 /* Connection timed out */

In both case there is common outcome which is communication between host and device is break because of some reason. So what can be issue for this connection is break?

I can’t help much with further debugging, but the failure in those modes is unexpected (those modes and traffic should work). I have seen references that “power exceeded” may cause this, but this too is a bit odd if the host side is giving that error.

FYI, the host will always attempt to supply power to the device. The device can be self-powered, and thus host won’t need to supply power. I’m guessing something in the power delivery options to be invalid.

Is there an actual device attached to the Jetson (e.g., hard drive) which is consuming power (perhaps too much power)?

Looks to be duplicate of
https://devtalk.nvidia.com/default/topic/1046776/jetson-tx2/usb-3-2-can-t-set-config-1-error-110/post/5312690/#5312690