Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Apr 2022 07:57:49 +0200
From:      Hans Petter Selasky <hps@selasky.org>
To:        Farhan Khan <farhan@farhan.codes>, freebsd-usb@freebsd.org
Subject:   Re: Trouble loading firmware to USB device
Message-ID:  <4f9a9bd7-28e4-99c7-6394-27368fafdbb1@selasky.org>
In-Reply-To: <6fd2d680bf9edd969476f4544314235538c7fe41.camel@farhan.codes>
References:  <f47b9415c262267d5c2505463b54f58ceaf76315.camel@farhan.codes> <d27787a2-eb6b-25dc-2d0d-56af4184032b@selasky.org> <9315bf6d-b9a9-89a2-9a32-aca9fd9cc015@farhan.codes> <dfc1cd8a-75a9-6637-e721-83d134910185@selasky.org> <007551144c601a21e2ec8133a8359323de29725f.camel@farhan.codes> <d2253b56-3174-ae31-078c-ba43bb3c7fc2@selasky.org> <6fd2d680bf9edd969476f4544314235538c7fe41.camel@farhan.codes>

next in thread | previous in thread | raw e-mail | index | archive | help
On 4/21/22 06:18, Farhan Khan wrote:
> On Wed, 2022-04-20 at 20:37 +0200, Hans Petter Selasky wrote:
>>
>> Hi,
>>
>> It appears you've programmed the interrupt endpoint to only receive
>> one
>> USB packet, because there is no /* FALLTHROUGH */, but a "break;"
>> statement instead!
>>
>>>                  break;
>>>          case USB_ST_SETUP:
>>
>> Maybe if you change that, it will work.
>>
>> --HPS
> 
> Hi!
> 
> I removed that break and the issue remains.
> 
> I would not expect this to make a difference because the USB_ST_SETUP
> condition is below the USB_ST_TRANSFERRED condition and the
> USB_ST_TRANSFERRED condition is never called. Since I am only getting
> USB_ST_SETUP calls, USB_ST_TRANSFERRED's fallthrough never happens
> anyways.
> 
> The timeline of events is this:
> ----
> 1. athn_data_rx_callback called via usbd_transfer_start() when pipes
> are opened, with USB_ST_SETUP condition - no USB_ST_TRANSFERRED occurs
> 
> 2. athn_usb_intr callback called via usbd_transfer_start(), also when
> pipes are opened. This creates a USB_ST_SETUP condition, but no
> USB_ST_TRANSFFERRED condition.
> 
> 3. Loading firmware content via usbd_do_request_flags()
> 
> 4. Sending final usbd_do_request() with length of 0.
> 
> 5. msleep() called, times out with EWOUDLBLOCK condition. This should
> be woke up by wakeup(9), which would happen if athn_usb_intr with the
> USB_ST_TRANSFERRED condition happened, but it does not.
> 
> 6. Firmware loading failure due to timeout.
> 
> 7. Driver unloaded
> 
> 8. athn_usb_intr called with USB_ST_ERROR/USB_ST_CANCELLED (Why?)

Hi,

8) usbdump will answer this question.

I see some more bugs:

	[ATHN_RX_INTR] = {
		.type = UE_INTERRUPT,
		.endpoint = 0x83, // AR_PIPE_RX_INTR,
		.direction = UE_DIR_ANY,
	                      ^^^^ try to use UE_DIR_RX here, else you might 
bind for TX!

And use UE_DIR_TX for TX. Ditto for the other transfers. Any change?

Second note, is that you should set some buffer size for the 
non-interrupt endpoints, else the buffer size will only be 
wMaxPacketSize bytes big!

--HPS



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4f9a9bd7-28e4-99c7-6394-27368fafdbb1>