Migrating evkbimxrt1050_dev_cdc_vnic_bm from Bare Metal (no operating system) to FreeRTOS

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Migrating evkbimxrt1050_dev_cdc_vnic_bm from Bare Metal (no operating system) to FreeRTOS

1,121 Views
evelynsabbag
Contributor II

I've compiled the Virtual Network Interface example evkbimxrt1050_dev_cdc_vnic_bm using the MCUXpresso IDE and the IMXRT1050-EVKB eval board. The example works without an operating system, but I would like to migrate it to FreeRTOS.  I set up a task, started the scheduler but if I replace the usb_osa_bm.c/usb_osa_bm.h files with the appropriate usb_osa_freertos.c/usb_osa_freertos.h files and the corresponding symbols in the project settings (replaced USB_STACK_BM with USB_STACK_FREERTOS, etc.), the example no longer works. It compiles, but the remote device no longer recognizes the RNDIS VNIC.

Has anyone tried this and had success with the migration?

freertos‌ freeRTOS_OSA‌ VNIC_FreeRTOS imxrt1050-evkb‌ 

0 Kudos
Reply
2 Replies

984 Views
evelynsabbag
Contributor II

Thanks for approving the post - writing it up helped me organize my troubleshooting. The issue was a non-interrupt-safe semaphore being invoked in an interrupt. Once I removed that, the example works just fine with FreeRTOS

984 Views
evelynsabbag
Contributor II

More info:

Single stepping through the code reveals that it is hanging at line 977 in the file 'usb_device_cdc_rndis.c' :USB_CDC_RNDIS_MUTEX_LOCK(handle->statusMutex).

This macro expands to: 

void USB_OsaEnterCritical(uint8_t *sr)
{
#if defined(__GIC_PRIO_BITS)
if ((__get_CPSR() & CPSR_M_Msk) == 0x13)
#else
if (__get_IPSR())
#endif
{
*sr = portSET_INTERRUPT_MASK_FROM_ISR();
}
else
{
portENTER_CRITICAL();
}
}

The code is hanging at portENTER_CRITICAL(); as __get_IPSR() returns false and an ASSERT kicks in. 

Not sure why get_IPSR() is returning false as the interrupts are enabled and evkbimxrt1050_dev_cdc_vcom_freertos (another example from the SDK) works fine.

0 Kudos
Reply