cancel
Showing results for 
Search instead for 
Did you mean: 

USBX Mutex does not work - CubeMX code generator BUG

matt-crc
Associate II

Hello, I'm trying to implement a USBX host... and the code generates a lot of runtime errors.  I assume everything is setup properly from CubeMX, but the code always fails. 

mattcrc_3-1741165785810.png

 

1- I see that the mutex was created from the debug session: (ux_system_mutex)

mattcrc_0-1741162907896.png

2- the system fails when trying to initialize the UX system.

mattcrc_1-1741163003693.png

3- The error came from _ux_utility_mutex_on() and generates an error code 0x04

VOID  _ux_utility_mutex_on(UX_MUTEX *mutex)
{

UINT    status;

    /* Call ThreadX to get system mutex.  */
    status =  tx_mutex_get(mutex, TX_WAIT_FOREVER);

    /* Check for status.  */
    if (status != UX_SUCCESS)
    {

        /* Error trap. */
        _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_UTILITY, status);
    }

    /* Return to caller.  */
    return;
}

so, it is trying to get the mutex (ux_system_mutex) and then wait forever....

4- If I look at the AzRTOS manual: 0x04

mattcrc_2-1741163342925.png

5- The base code was auto generated by CubeMX.  So basically it is trying to initialize memory using a mutex before starting the threads....

6- to make matters worse, the error code (status) is not passed to the calling function properly, so it took a lot of time to find this problem, and the ux_error_handlers does absolutely nothing (ie no while(1))

 

2 REPLIES 2
FBL
ST Employee

Hi  @matt-crc 

Would you attach ioc file to reproduce?

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.


matt-crc
Associate II

Hi @FBL 

see attached

Matthew