2015-04-13 03:11 AM
2015-06-05 09:24 PM
Hello,
I'm curious if you resolved this issue? I am debugging the same problem on an stm32L0. I used stmCube to create a DFU image which I have flashed and the device does appear in DFU mode. dfu-util -l outputs the following:Found DFU: [0483:df11] ver=0200, devnum=35, cfg=1, intf=0, alt=0, name=''UNKNOWN'', serial=''00000000001A'' However, when I try to actually flash I get the same message:dfu-util: Could not read name, sscanf returned 0I've tracked down why this is happening and why the string is ''UNKNOWN'' but I'm trying to understand why it is happenning. If I do lsb -v I get this info(trimmed) Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 0 bInterfaceClass 254 Application Specific Interface bInterfaceSubClass 1 Device Firmware Update bInterfaceProtocol 2 iInterface 6 The key here is the last line, 'iInterface 6'. I have read this is supposed to be the index of the interface name. dfu-util calls the libusb function to get the name: if (intf->iInterface != 0) ret = libusb_get_string_descriptor_ascii(devh, intf->iInterface, (void *)alt_name, MAX_DESC_STR_LEN);where intf->iInterface is 6.This ends up running the following function in the stm32 firmware:static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev , USBD_SetupReqTypedef *req)<snip>case USB_DESC_TYPE_STRING: switch ((uint8_t)(req->wValue)) { case USBD_IDX_INTERFACE_STR: pbuf = pdev->pDesc->GetInterfaceStrDescriptor(pdev->dev_speed, &len); break; default:#if (USBD_SUPPORT_USER_STRING == 1) pbuf = pdev->pClass->GetUsrStrDescriptor(pdev, (req->wValue) , &len); break;#else USBD_CtlError(pdev , req); return;#endif static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev , USBD_SetupReqTypedef *req)So for me, the lower byte of req->wValue is 6 but the value ofUSBD_IDX_INTERFACE_STR is 0x5. So the incoming request for theinterace name always gets an error and thus dfu-util fails. Also it look like dfu-util expects the name in a specific format for dfuse devices: ret = sscanf(intf_desc, ''@%[^/]%n'', name, &scanned); if (ret < 1) { free(name); warnx(''Could not read name, sscanf returned %d'', ret); return NULL; }And the name generated by Cube doesn't match that format:#define USBD_INTERFACE_STRING_FS ''DFU Interface'' So I've got a couple more things to dig into but wanted to see if you found anything while debugging this issue. thanks,jeff2015-11-08 05:30 AM
Were you able to find a solution for this?
I also think it has something to do with the name='UNKOWN' . (when using dfu-utils 0.5 it says name='UNDEFINED' ) . I've seen other devices where it usually has the format name=''@Some name'' . Is there any workaround for this?2015-11-09 02:35 AM
The STM32F42x DFU bootloader in ROM violates the USB spec, according to WireShark and TotalPhase Beagle, causing an issue with libUSB. DFU-util is fine.
Here's a patch for libusb-1.0.19:https://github.com/axoloti/axoloti/blob/master/platform_osx/src/libusb.stdfu.patch
This workaround works on Windows, OSX and Linux.