Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Apr 2022 01:53:36 -0400
From:      Farhan Khan <farhan@farhan.codes>
To:        freebsd-usb@freebsd.org, Hans Petter Selasky <hps@selasky.org>
Subject:   Re: Trouble loading firmware to USB device
Message-ID:  <1901464.PYKUYFuaPT@fedora>
In-Reply-To: <05b3c211-2b77-7e59-a9da-d28a21d5b389@selasky.org>
References:  <f47b9415c262267d5c2505463b54f58ceaf76315.camel@farhan.codes> <9ca0e355-d780-f9c0-4d38-b99662f43edd@selasky.org> <05b3c211-2b77-7e59-a9da-d28a21d5b389@selasky.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday, April 27, 2022 3:41:27 AM EDT Hans Petter Selasky wrote:
> Somewhere in the code you are asking for a read of 1024 bytes on the
> interrupt endpoint. That is what usbdump says. That means multiple
> packets will have to be received for it to complete. I'm not sure

Making progress: I got this down to 64 bytes, not 1024, and identified the 
read location.

-----
18:17:30.880855 usbus3.2 SUBM-INTR-EP=00000083,SPD=HIGH,NFR=1,SLEN=0,IVAL=1
 frame[0] READ 64 bytes
 flags 0xa <SHORT_XFER_OK|PIPE_BOF|0>
 status 0xeb023 <OPEN|TRANSFERRING|STARTED|SHORT_XFER_OK|BDMA_ENABLE|
BDMA_SETUP|CURR_DMA_SET|CAN_CANCEL_IMMED|DOING_CALLBACK|0>
-----

The source of this read appears to be after the usbd_transfer_setup(), where I 
send two initial usbd_transfer_start()s, specifically the for the RX Data 
transfer.

usbd_transfer_start(usc->usc_xfer[ATHN_RX_DATA]);

I do this immediately after the usbd_transfer_setup(). I identified this by 
commenting out other lines until I narrowed it down to this single source. 
This line should trigger this callback:

The code is located here: https://github.com/khanzf/freebsd/blob/ar9271/sys/
dev/athn/usb/if_athn_usb.c#L303

I believe earlier in our conversation you advised me to include that transfer. 
Is there something wrong in my callback? The OpenBSD callback is pretty robust 
but for now I was aiming for the minimum necessary to load the firmware.

> printf("FRAME LENGTH = %d\n", usbd_xfer_max_len(xfer));

64 bytes, sounds correct.

> Also make sure there is only one instance of your .ko in /boot/kernel or
> /boot/modules, that you are not loading an old version of the built .ko.

My build script is running make -C /usr/src/sys/modules/athn_usb/ clean, 
cleandepend, then load, I never actually install the module such that it is 
stored in my /boot/modules directory, so I do not anticipate this being an 
issue.

- Farhan






Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1901464.PYKUYFuaPT>