I’m running on the RT1052 w/ FreeRTOS Kernel V10.2.1.
If I use the FreeRTOS USB demo for this device, everything works, but the demo only creates a task, and inits USB (no task delete).
If I want to shut down USB, by doing the reverse of the setup seemed to be the obvious way to do things, it works for a while…, but this appears to be leading to memory corruption / over allocation if I repeatedly delete and re-create the tasks.
In my own project, I eventually get an assertion when trying to delete the task:
A memory watchpoint on this (in FreeRTOS heap space) breaks on USB_DeviceStop().
I port this to a basic example (creates & deletes USB tasks when the user hits the button):
The example fails @ xTaskCreate
when repeatedly creating / deleting tasks. While this seems different from what would cause the code to assert at
configASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 );
possibly the same source cause - over allocation???
Example tested on an RT1052 Arch Seeed board: https://github.com/andrewrt/rt1050_cdc_vcom_freertos
Does anyone have insight into the NXP USB port of FreeRTOS and proper task deletion?
Or is this something more basic w/ the FreeRTOS kernel - like I need to somehow wait and confirm a task was completely deleted before that memory is available again?