2026-06-05 4:26 AM
I am trying to use ThreadX/FileX/USBX to read/write files on a USB memory stick.
It appears to work but there is a 10 second delay between initialisation and File access.
I have tracked this down to:
Thread #1 [main] 1 [core: 1] (Suspended : Step)
_ux_host_class_storage_transport_bo() at ux_host_class_storage_transport_bo.c:282 0x8011378
_ux_host_class_storage_transport() at ux_host_class_storage_transport.c:98 0x8011262
_ux_host_class_storage_media_characteristics_get() at ux_host_class_storage_media_characteristics_get.c:126 0x8010d9c
_ux_host_class_storage_device_initialize() at ux_host_class_storage_device_initialize.c:134 0x8010964
_ux_host_class_storage_activate() at ux_host_class_storage_activate.c:191 0x80107b6
_ux_host_stack_configuration_interface_scan() at ux_host_stack_configuration_interface_scan.c:179 0x8012000
_ux_host_stack_class_interface_scan() at ux_host_stack_class_interface_scan.c:106 0x8011d70
_ux_host_stack_new_device_create() at ux_host_stack_new_device_create.c:282 0x80128a6
_ux_host_stack_rh_device_insertion() at ux_host_stack_rh_device_insertion.c:183 0x8012b80
_ux_host_stack_rh_change_process() at ux_host_stack_rh_change_process.c:156 0x8012aba
_ux_host_stack_enum_thread_entry() at ux_host_stack_enum_thread_entry.c:116 0x8012496
_tx_thread_shell_entry() at tx_thread_shell_entry.c:114 0x800ee1c
<signal handler called>() at 0xffffffff This function calls
_ux_host_stack_transfer_request(transfer_request);
then waits for semaphore ux_transfer_request_semaphore with a 10 second timeout.
The wait does timeout so we climb out of the stack of calls, and get on with reading and writing files which seem to be OK.
The problem calls seems to stem from a call a few steps down the stack in _ux_host_class_storage_device_initialize(), which has:
/* Get the media type supported by this storage device. */
status = _ux_host_class_storage_media_characteristics_get(storage);
if (status == UX_HOST_CLASS_MEDIA_NOT_SUPPORTED)
{
...
}
if (status != UX_SUCCESS)
return(status);It looks as if the semaphore should be signalled in:
void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state)
which is called from the ISR. This works for all the other calls, but in this case, urb_state is always URB_NOTREADY so we never reach:
/* Wake up the transfer request thread. */
_ux_host_semaphore_put(&transfer_request -> ux_transfer_request_semaphore);
I could just reduce the timeout but that doesn't really seem like the right solution!
Any thoughts would be appreciated.
CubeMX Version 6.17.0
STM32H573
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.