Code: Select all
sduStart(&SDU1, &serusbcfg);
usbStart(serusbcfg.usbp, &usbcfg);
usbConnectBus(serusbcfg.usbp);
while (serusbcfg.usbp->state != USB_ACTIVE)
chThdSleepMilliseconds(1000);
//this string is successfully written
chSequentialStreamWrite((BaseSequentialStream*)&SDU1, (void*)test_string, strlen(test_string));
//when I comment the sleep out, both writes succeed
chThdSleepMilliseconds(1000);
//when the thread resumes after the sleep, the second write fails and causes a hard fault
chSequentialStreamWrite((BaseSequentialStream*)&SDU1, (void*)test_string, strlen(test_string));
I took all the usb configuration, events/callbacks (including the new SOF), etc. right out of the HAL usb test and am using a STM32F411RE-Nucleo board with pretty much all of the stock settings from halconf.h, mcuconf.h, and chconf.h. Stepping through the code before the fault shows that the problem occurs during osalSysUnlock() towards the end of the obqWriteTimeout() function. I've tried turning on CORTEX_SIMPLIFIED_PRIORITY but that didn't solve the problem either. Any ideas what could be causing the problem or how I might get to the bottom of this?? Thanks so much.