AnsweredAssumed Answered

KDS/KSDK K20 USB Driver Mutex Problem

Question asked by Sean Bolton on Jan 21, 2016

Hi

 

I am using KDS 3.0.0 and KSDK 1.3.0 on a Windows 10 platform developing for a Kinetis K20   MK20DX256VLK10

 

When I select the Processor Expert Demo USB HID code the resultant code always crashes on startup when calling OSA_MutexLock()

 

The processor is halted in the asset(pMutex);   as the pMutex pointer is NULL.

 

If I add some code to check for and bypass null pMutex pointers then the code runs fine and the USB Demo works as expected.

 

This is the code I added to the start of the Lock and Unlock functions.

 

osa_status_t OSA_MutexLock(mutex_t *pMutex, uint32_t timeout)

{

#if 1

  // SEAN:  Check for null pointer and return as otherwise CPU hangs in the assert

    if ( pMutex == NULL )

    {

    nullMutexLockCounter++ ;

    return kStatus_OSA_Idle;

    }

#endif

 

#if (FSL_OSA_BM_TIMER_CONFIG != FSL_OSA_BM_TIMER_NONE)

    uint32_t currentTime;

#endif

 

    assert(pMutex);

 

 

osa_status_t OSA_MutexUnlock(mutex_t *pMutex)

{

#if 0

  // SEAN:  Check for null pointer and return as otherwise CPU hangs in the assert

    if ( pMutex == NULL )

    {

    nullMutexUnlockCounter++ ;

    return kStatus_OSA_Success;

    }

#endif

 

assert(pMutex);

 

 

I can also see from the counters I added that the Lock and Unlock is called continously with a null pointer.  This would suggest a mutex needed by the FSL USB Driver is not getting created on initialisation.

 

Attached is a screenshot showing the stack trace when the processor crashes in the mutex call.  Also my modified fsl_os_abstraction_bm.c  file.

 

This problem might be related to my other USB Issue (that of adding a 2nd endpoint) as described in thread 384023  USB Driver Issues on K20 with KDS/KSK demo code

 

My workaround works but could there be an underlying problem if the USB Driver cannot correctly create and use its mutex?

 

regards


Sean

Original Attachment has been moved to: fsl_os_abstraction_bm_modified.c.zip

Attachments

Outcomes