Re: Trouble loading firmware to USB device

From: Farhan Khan <farhan_at_farhan.codes>
Date: Thu, 21 Apr 2022 17:51:47 UTC
On Thu, 2022-04-21 at 07:57 +0200, Hans Petter Selasky wrote:
> 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

Hi Hans!

I did both, but there is no change in the behavior,

The usb_config is listed below. I got the bufsize's by running `lsusb`
on Linux, but it should be the same basic output from FreeBSD tools. A
link to my latest commit is here:
https://github.com/khanzf/freebsd/blob/30fe0bd7677f07fd290e4150ccec620b7b09d532/sys/dev/athn/usb/if_athn_usb.c#L249

Still not working :/

- Farhan

-----
static const struct usb_config athn_config_common[ATHN_N_TRANSFERS] = {
	[ATHN_TX_DATA] = {
		.type = UE_BULK,
		.endpoint = 0x01, // AR_PIPE_TX_DATA,
		.direction = UE_DIR_TX,
		.flags = {
			.short_xfer_ok = 1,
//			.force_short_xfer = 1,
			.pipe_bof = 1
		},
		.callback = athn_data_tx_callback,
		.bufsize = 0x200,
	},
	[ATHN_RX_DATA] = {
		.type = UE_BULK,
		.endpoint = 0x82, //AR_PIPE_RX_DATA,
		.direction = UE_DIR_RX,
		.flags = {
			.short_xfer_ok = 1,
//			.force_short_xfer = 1,
			.pipe_bof = 1
		},
		.callback = athn_data_rx_callback,
		.bufsize = 0x200,
	},
	[ATHN_RX_INTR] = {
		.type = UE_INTERRUPT,
		.endpoint = 0x83, // AR_PIPE_RX_INTR,
		.direction = UE_DIR_RX,
		.flags = {
			.short_xfer_ok = 1,
//			.force_short_xfer = 1,
			.pipe_bof = 1
		},
		.callback = athn_usb_intr,
		.bufsize = 0x40,
//		.callback = athn_intr_rx_callback,
	},
	[ATHN_TX_INTR] = {
		.type = UE_INTERRUPT,
		.endpoint = 0x04, //AR_PIPE_TX_INTR,
		.direction = UE_DIR_TX,
		.flags = {
			.short_xfer_ok = 1,
//			.force_short_xfer = 1,
			.pipe_bof = 1
		},
		.callback= athn_intr_tx_callback,
		.bufsize = 0x40,
	}
};

-----