[go: up one dir, main page]

Menu

#221 dfu-util hangs about 25% of the time when run in parallel via python subprocess

none
open
nobody
None
2025-10-14
2025-08-18
Mark Ward
No

Computer environment: Intel desktop computer running Oracle Linux 9.4 UEK
dfu-version: dfu-util 0.11-dev
device: TI AM243x
outptut from dfu-util -l

dfu-util 0.11-dev

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to https://sourceforge.net/p/dfu-util/tickets/

Found DFU: [0451:6165] ver=0200, devnum=89, cfg=1, intf=0, path="3-6", alt=0, name="bootloader", serial="01.00.00.00"
Found DFU: [0451:6165] ver=0200, devnum=89, cfg=1, intf=0, path="3-6", alt=1, name="SocId", serial="01.00.00.00"

command line:

sudo dfu-util -a 0 -i 0 -D <firmware file> -p 3-6 -vvv

I am running dfu-util to program multiple AM243x MCU that are connected to the same system (5 is my current test set, but I want to double or triple the number of target devices). About 75% of the time this command runs with no errors. 25% of the time it hangs with no indication as to the failure.

21:04:47 428 [INFO] Script start ----------------------------------------
        core:main:1082, core:invoke:1697, core:invoke:1697, core:invoke:1443, core:invoke:788, am243x:program_am243x:269, am243x:_program_rtm:228, am243x:_usb_program_rtm:88

21:05:47 492 [ERROR] Script failed with timeout - Command '['python3', '/home/markwar/workspaces/calamari/calamari/am243x/usb_dfu_uniflash.py', '--cfg', '/home/markwar/workspaces/calamari/tmp_prgm_3-6_ttyUSB4.cfg', '-p', '3-6']' timed out after 60.0 seconds
21:05:47 492 [INFO] Results of script:
dfu-util 0.11-dev

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to https://sourceforge.net/p/dfu-util/tickets/

dfu-util: Warning: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release
Opening DFU capable USB device...
Device ID 0451:6165
Device DFU version 0110
Claiming USB DFU Interface...
Setting Alternate Interface #0 ...
Determining device status...
DFU state(2) = dfuIDLE, status(0) = No error condition is present
DFU mode device DFU version 0110
Device returned transfer size 512
Copying data from PC to DFU device

Download    [                         ]   0%            0 bytes
Download    [=                        ]   4%        14336 bytes
Download    [==                       ]   8%        28160 bytes
Download    [===                      ]  12%        42496 bytes
Download    [====                     ]  16%        56320 bytes
Download    [=====                    ]  20%        70656 bytes
Download    [======                   ]  24%        84480 bytes
Download    [=======                  ]  28%        98816 bytes
Download    [========                 ]  32%       112640 bytes
Download    [=========                ]  36%       126976 bytes
Download    [==========               ]  40%       140800 bytes
Download    [===========              ]  44%       155136 bytes
Download    [============             ]  48%       168960 bytes
Download    [=============            ]  52%       183296 bytes
Download    [=============            ]  53%       188416 bytes
Download    [==============           ]  56%       197120 bytes
Download    [===============          ]  60%       210944 bytes
Download    [================         ]  64%       225280 bytes
Download    [=================        ]  68%       239104 bytes
Download    [==================       ]  72%       253440 bytes
Download    [===================      ]  76%       267264 bytes
Download    [====================     ]  80%       281600 bytes
Download    [=====================    ]  84%       295424 bytes
Download    [======================   ]  88%       309760 bytes
Download    [=======================  ]  92%       323584 bytes
Download    [======================== ]  96%       337920 bytes
Download    [=========================] 100%       351004 bytes
Download done.
DFU state(6) = dfuMANIFEST-SYNC, status(0) = No error condition is present
DFU state(2) = dfuIDLE, status(0) = No error condition is present
Done!

21:05:47 492 [INFO] Script end (/home/markwar/workspaces/calam) ----------------------------------------

21:05:47 493 [WARNING] Failed Erase and Program AM243x RTM on attempt 1 of 3

This step in the Python script I use to execute usually only takes 26-28 seconds. and doesn't timeout until 60 seconds.
I have tried to put a fcnt.flock around the dfu-util call so that only one device is going through this step at a time, but that hasn't fixed the issue.

Discussion

  • Mark Ward

    Mark Ward - 2025-08-19

    This is the detailed log file from the hung dfu-util programming of AM243x - above was same failure without -vvv.

     
  • Mark Ward

    Mark Ward - 2025-08-19

    The failure looks to be hanging after the first block of data is transferred and before we enumerate the device again:
    Failing system

    [ 1.901426] [002f018d] libusb: debug [libusb_free_transfer] transfer 0x1cbf8ab0
    DFU state(2) = dfuIDLE, status(0) = No error condition is present
    Done!
    [ 1.901440] [002f018d] libusb: debug [libusb_close]  
    [ 1.901447] [002f018d] libusb: debug [usbi_remove_event_source] remove fd 7
    [ 1.901492] [002f018d] libusb: debug [libusb_exit]  
    [ 1.901567] [002f018e] libusb: debug [linux_udev_event_thread_main] udev event thread exiting
    [ 1.901706] [002f018d] libusb: debug [libusb_unref_device] destroy device 9.1
    [ 1.901711] [002f018d] libusb: debug [libusb_unref_device] destroy device 10.1
    [ 1.901715] [002f018d] libusb: debug [libusb_unref_device] destroy device 8.1
    [ 1.901719] [002f018d] libusb: debug [libusb_unref_device] destroy device 7.1
    [ 1.901723] [002f018d] libusb: debug [libusb_unref_device] destroy device 6.1
    [ 1.901726] [002f018d] libusb: debug [libusb_unref_device] destroy device 5.1
    [ 1.901729] [002f018d] libusb: debug [libusb_unref_device] destroy device 4.1
    [ 1.901732] [002f018d] libusb: debug [libusb_unref_device] destroy device 3.75
    [ 1.901736] [002f018d] libusb: debug [libusb_unref_device] destroy device 3.87
    [ 1.901739] [002f018d] libusb: debug [libusb_unref_device] destroy device 3.86
    [ 1.901742] [002f018d] libusb: debug [libusb_unref_device] destroy device 3.85
    [ 1.901745] [002f018d] libusb: debug [libusb_unref_device] destroy device 3.84
    [ 1.901748] [002f018d] libusb: debug [libusb_unref_device] destroy device 3.83
    [ 1.901752] [002f018d] libusb: debug [libusb_unref_device] destroy device 3.1
    [ 1.901755] [002f018d] libusb: debug [libusb_unref_device] destroy device 2.1
    [ 1.901759] [002f018d] libusb: debug [libusb_unref_device] destroy device 1.3
    [ 1.901762] [002f018d] libusb: debug [libusb_unref_device] destroy device 1.1
    [ 1.901767] [002f018d] libusb: debug [usbi_remove_event_source] remove fd 4
    [ 1.901774] [002f018d] libusb: debug [usbi_remove_event_source] remove fd 3
    

    working example - which does not hang:

    [ 2.087074] [002f040b] libusb: debug [libusb_free_transfer] transfer 0x129b4b90
    DFU state(2) = dfuIDLE, status(0) = No error condition is present
    Done!
    [ 2.087088] [002f040b] libusb: debug [libusb_close]  
    [ 2.087096] [002f040b] libusb: debug [usbi_remove_event_source] remove fd 7
    [ 2.087141] [002f040b] libusb: debug [libusb_exit]  
    [ 2.087272] [002f040c] libusb: debug [linux_udev_event_thread_main] udev event thread exiting
    [ 2.087404] [002f040b] libusb: debug [libusb_unref_device] destroy device 9.1
    [ 2.087409] [002f040b] libusb: debug [libusb_unref_device] destroy device 10.1
    [ 2.087413] [002f040b] libusb: debug [libusb_unref_device] destroy device 8.1
    [ 2.087416] [002f040b] libusb: debug [libusb_unref_device] destroy device 7.1
    [ 2.087419] [002f040b] libusb: debug [libusb_unref_device] destroy device 6.1
    [ 2.087422] [002f040b] libusb: debug [libusb_unref_device] destroy device 5.1
    [ 2.087431] [002f040b] libusb: debug [libusb_unref_device] destroy device 4.1
    [ 2.087437] [002f040b] libusb: debug [libusb_unref_device] destroy device 3.77
    [ 2.087441] [002f040b] libusb: debug [libusb_unref_device] destroy device 3.87
    [ 2.087444] [002f040b] libusb: debug [libusb_unref_device] destroy device 3.86
    [ 2.087447] [002f040b] libusb: debug [libusb_unref_device] destroy device 3.85
    [ 2.087450] [002f040b] libusb: debug [libusb_unref_device] destroy device 3.84
    [ 2.087454] [002f040b] libusb: debug [libusb_unref_device] destroy device 3.83
    [ 2.087457] [002f040b] libusb: debug [libusb_unref_device] destroy device 3.1
    [ 2.087460] [002f040b] libusb: debug [libusb_unref_device] destroy device 2.1
    [ 2.087464] [002f040b] libusb: debug [libusb_unref_device] destroy device 1.3
    [ 2.087467] [002f040b] libusb: debug [libusb_unref_device] destroy device 1.1
    [ 2.087471] [002f040b] libusb: debug [usbi_remove_event_source] remove fd 4
    [ 2.087480] [002f040b] libusb: debug [usbi_remove_event_source] remove fd 3
    dfu-util 0.11-dev
    
    Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
    Copyright 2010-2021 Tormod Volden and Stefan Schmidt
    This program is Free Software and has ABSOLUTELY NO WARRANTY
    Please report bugs to https://sourceforge.net/p/dfu-util/tickets/
    
    libusb version 1.0.26 (11724)
    dfu-util: Warning: Invalid DFU suffix signature
    dfu-util: A valid DFU suffix will be required in a future dfu-util release
    [timestamp] [threadID] facility level [function call] <message>
    --------------------------------------------------------------------------------
    [ 0.013989] [002f0439] libusb: debug [libusb_get_device_list]  
    [ 0.013998] [002f0439] libusb: debug [discovered_devs_append] need to increase capacity
    
     
  • Tormod Volden

    Tormod Volden - 2025-08-19

    I remember having seen, many years ago, an issue with a program running via Python's subprocess. I will try to recall or find back to it.

    You said that you added a lock that assures only one invocation of dfu-util is running at a time, but that didn't help. It therefore seems to me that the problem is not running dfu-util in parallel, but something else.

     
  • Mark Ward

    Mark Ward - 2025-08-20

    I may have found the issue. In the script there are individual steps to programming the bootloader and application (the script being written by TI called usb_dfu_uniflash.py, in that scrip it checks the status of the target device using dfu-util -l between steps to check enumeration of the device to make sure it is ready for the next step. It looks like the -p <path> can change between steps and the script can't handle that. I am going to modify TI's script and see if I can make this more reliable.

     
  • Anonymous

    Anonymous - 2025-10-14
    Post awaiting moderation.

Anonymous
Anonymous

Add attachments
Cancel