[go: up one dir, main page]

Menu

#169 Inconsistent handling of libusb_reset_device return value

0.12
closed
nobody
None
2024-04-14
2023-06-03
No

dfu-util -D file -R returns -5 (LIBUSB_ERROR_NOT_FOUND) after successfully programming and resetting my homegrown device.

That -5 comes from libusb_reset_device, and I can see that this particular return value from is specifically ignored in the error reporting following the call, but is nevertheless allowed to bubble up, all the way to the return from main.


Example at src/dfu_load.c:203:

    case DFU_STATE_dfuMANIFEST_WAIT_RST:
        printf("Resetting USB to switch back to runtime mode\n");
        ret = libusb_reset_device(dif->dev_handle);
        if (ret < 0 && ret != LIBUSB_ERROR_NOT_FOUND) {
            fprintf(stderr, "error resetting after download (%s)\n",
                libusb_error_name(ret));
        }
        break;

A proposed patch is attached.

1 Attachments

Discussion

  • Tormod Volden

    Tormod Volden - 2023-06-14
    • Milestone: none --> 0.12
     
  • Tormod Volden

    Tormod Volden - 2023-06-14

    Thanks! This seems to make sense.

     
  • Tormod Volden

    Tormod Volden - 2024-04-14

    I have committed a patch received earlier, in commit 4800abb, and which I believe does the same as your third chunk. Your second chunk seems not needed, because ret will be reset later in any case, it can be considered a "local" variable here.

    Your first chunk seems to make sense, but actually a proper DFU device will never report to be in dfuMANIFEST-WAIT-RESET state, please see section 8 of DFU 1.1. So maybe you should review your homegrown device.

    This is also related to the discussion in https://sourceforge.net/p/dfu-util/dfu-util/merge-requests/17/

     
  • Tormod Volden

    Tormod Volden - 2024-04-14

    I now committed the equivalent of your first chunk in commit 83b4abc.

     
  • Tormod Volden

    Tormod Volden - 2024-04-14
    • status: open --> closed
     

Anonymous
Anonymous

Add attachments
Cancel