Skip to main content
Associate III
Question

USBX Debug Logging

Hi,

Running USBX/ThreadX with MSC and HUB host classes, on an STM32H573.

 

I enabled  UX_ENABLE_DEBUG_LOG to get some USBX debug info from the software stack, and

it doesn’t compile. Fixed the compile error in usbx/common/core/src/ux_utility_debug_log.c, and then

set a breakpoint in the logging function _ux_utility_debug_log(), and it never gets called?

 

Can someone provide some history here, was this feature deprecated at some point?

Lots of online troubleshooting guides indicate that this is a useful debug technique?

I grep’d the code and found two instances where the stack actually calls UX_DEBUG_LOG(),

and both are in the host_class_CDC software, which my product does not use.

Thanks

Ken

 

5 replies

ST Technical Moderator

Hi ​@microcoder 

Thank you for reporting this and for investigating the call sites.

Enabling UX_ENABLE_DEBUG_LOG enables the logging macro, but it does not automatically add diagnostic messages throughout USBX.

Could you share:

  • Your STM32CubeH5 and USBX versions, including any separately installed middleware package.
  • The change you made in  ux_utility_debug_log.c.
  • the issue you are facing? 

For the MSC/HUB issue you are investigating, useful starting points are checking USBX API return values, setting a breakpoint in _ux_system_error_handler() where that error reporting path is enabled, 

Could you also describe the original issue you are trying to diagnose? 

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL
ST Technical Moderator

Hi ​@microcoder 

Coming back to the issue,

First, I recommend leave debug logging disabled during this investigation to narrow down issues. So, I suggest leaving UX_ENABLE_DEBUG_LOG disabled because the local workaround has not been validated and the existing logging calls do not cover the MSC/HUB paths we need to investigate. This is not a proposed fix for the storage issue. Instead, let us capture the storage/media mapping, insertion/removal events, and exact FileX error statuses.

But your expectation is understandable: the name suggests that enabling it would produce diagnostic messages throughout USBX. In practice, it enables the logging infrastructure, but messages are generated only where the code explicitly calls UX_DEBUG_LOG().
Now followup is in the next thread Two drives appear to be represented by the same FileX media pointer, and access fails after an overcurrent event. | Community

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL
Andrew Neil
Super User

But your expectation is understandable: the name suggests that enabling it would produce diagnostic messages throughout USBX. 

I agree!

 

In practice, it enables the logging infrastructure, but messages are generated only where the code explicitly calls UX_DEBUG_LOG().

So is that something that ST would be expected to provide, or should it come from the ThreadX/USBX project ?

 

PS:

It could be better documented in ST’s guide here.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Andrew Neil
Super User

​@microcoder 
it doesn’t compile. Fixed the compile error in usbx/common/core/src/ux_utility_debug_log.c,

Are you referring to this GitHub Issue?

https://github.com/STMicroelectronics/stm32-mw-usbx/issues/9

 

Lots of online troubleshooting guides indicate that this is a useful debug technique?

Are you talking about the use of debug logs in general, or USBX logs specifically ?

In general, they are certainly a very useful technique!

eg, see here.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
ST Technical Moderator

Hi ​@Andrew Neil 

I’ve submitted an internal ticket to the dedicated team to clarify how USBX debug logging works and how to use it. The ticket number is CDM0067948 and is for ST employees’ reference only.

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL