Re: USBDMSC emulated device does not work on FreeBSD

From: Hans Petter Selasky <hps_at_selasky.org>
Date: Fri, 12 Nov 2021 12:49:24 UTC
On 11/12/21 12:34, Milan Obuch wrote:
> On Fri, 12 Nov 2021 12:20:45 +0100
> Hans Petter Selasky <hps@selasky.org> wrote:
> 
>> On 11/12/21 12:18, Milan Obuch wrote:
>>> On Fri, 12 Nov 2021 12:11:38 +0100
>>> Hans Petter Selasky <hps@selasky.org> wrote:
>>>    
>>>> Hi,
>>>>   
>>>>> kernel: ugen1.3: <Microchip Inc PolarFireSoc-FlashDrive> at usbus1
>>>>>
>>>>> line in console (and later in dmesg). Relevant line in output of
>>>>> 'usbconfig show_ifdrv' command is
>>>>>
>>>>> ugen1.3: <Microchip Inc PolarFireSoc-FlashDrive> at usbus1,
>>>>> cfg=255 md=HOST spd=HIGH (480Mbps) pwr=ON (100mA)
>>>>
>>>> cfg=255 means something very low level USB failed. It was not able
>>>> to set the configuration number.
>>>>
>>>> Try:
>>>>
>>>> usbconfig -d ugen1.3 set_config 0
>>>>
>>>> --HPS
>>>>   
>>>
>>> I tried, basically no change (no output on console, no change in
>>> output of 'usbconfig show_ifdrv' command).
>>>
>>> Also, I tried 'usbconfig -d ugen1.3 dump_all_desc' just out of
>>> curiosity, output is
>>>
>>> ugen1.3: <Microchip Inc PolarFireSoc-FlashDrive> at usbus1, cfg=255
>>> md=HOST spd=HIGH (480Mbps) pwr=ON (100mA)
>>>
>>>     bLength = 0x0012
>>>     bDescriptorType = 0x0001
>>>     bcdUSB = 0x0200
>>>     bDeviceClass = 0x0000  <Probed by interface class>
>>>     bDeviceSubClass = 0x0000
>>>     bDeviceProtocol = 0x0000
>>>     bMaxPacketSize0 = 0x0008
>>>     idVendor = 0x1514
>>>     idProduct = 0x0001
>>>     bcdDevice = 0x3000
>>>     iManufacturer = 0x0001  <retrieving string failed>
>>>     iProduct = 0x0002  <retrieving string failed>
>>>     iSerialNumber = 0x0003  <retrieving string failed>
>>>     bNumConfigurations = 0x0001
>>>    
>>
>> Hi,
>>
>> I suspect the USB implementation in this device is buggy and not
>> fully spec. compliant.
>>
>> You may try to set the UQ_NO_STRINGS quirk on this device and re-plug:
>>
>> usbconfig -d ugen1.3 add_quirk UQ_NO_STRINGS
>>
>> Then physically re-plug the device.
>>
>> --HPS
>>
> 
> I agree this device has buggy USB implementation - there is
> 
> __assert_func(): services/mmc/mmc_api.c:214: HSS_MMC_ReadBlock() Assertion failed: ((size_t)srcOffset & (HSS_MMC_SECTOR_SIZE-1)) == 0u
> 
> soon after 'usbdmsc' command execution (when connected to FreeBSD box).
> That could explain it does not work :)
> 
> Trying the command you wrote I get just
> 
> Adding quirk 'UQ_NO_STRINGS' failed, continuing.
> 
> I tested this on both 11.4 and 12.2 boxes. So I think something FreeBSD
> did in early stage after discovering new device on USB bus disturbs
> this device's USB stack badly and somehow it crashes (I need reset in
> order to continue working with it).
> 
> Regards,
> Milan
> 

There is also "usbdump -i usbus1 -f 3 -s 65536 -vvv"

which may point at the exact command which is failing.

-_HPS