justinh109 wrote on Saturday, September 07, 2019:
Hello all,
I am new to the forum, and fairly new to RTOS as well. I am working on a project that uses RTOS 8.2.3 with heap 4 paired with the LWIP socket API and I have run into an issue that has completely stumped me.
I’m running a simple TCP echo test where I issue the processor a prompt, it generates a response, in this case a 251 byte messages and sends it back to my python server. This test runs well for a while but then it fails!
The GMAC_Handler calls xQueueGiveFromISR, and after a few hours this function is throwing an assert, if I disable the assert a hard fault will result. I also noticed that I can force the error sooner if I spam UDP packets at the device.
/* xQueueGenericSendFromISR() should be used instead of xQueueGiveFromISR()
if the item size is not 0. */
configASSERT( pxQueue->uxItemSize == 0 );
I’ve tried using ‘xQueueGenericSendFromISR instead of xQueueGiveFromISR,’ but this also resulted in a hard fault. The 2 things I think I am doing correctly are heap allocation and IRQ settings. I’ve made sure all the tasks have a highwater mark over 1000 and I double checked my IRQ priorites:
- #define configPRIOBITS NVICPRIOBITS
- #define configLIBRARYLOWESTINTERRUPTPRIORITY 0x07*
- #define configLIBRARYMAXSYSCALLINTERRUPTPRIORITY 4*
-
#define configKERNELINTERRUPTPRIORITY (configLIBRARYLOWESTINTERRUPTPRIORITY << (8 - configPRIOBITS))
#define configMAXSYSCALLINTERRUPTPRIORITY (configLIBRARYMAXSYSCALLINTERRUPTPRIORITY << (8 - configPRIOBITS))
#define GMACIRQNPRIO configMAXSYSCALLINTERRUPTPRIORITY*
The two functions using the semaphore are below, and for sake of space I attached an snip of the tcpip thread, in addition I am running a thread to manage the socket connection.
//GMAC ISR
static void gmac_task(void *pvParameters)
{
struct gmac_device ps_gmac_dev = pvParameters;
while (1) {
//get high water mark for this task
rtosStats.gmacHighWaterMark = uxTaskGetStackHighWaterMark( NULL );
sys_arch_sem_wait(&ps_gmac_dev->rx_sem, 0); // Wait for the RX notification semaphore.
/ Process the incoming packet. */
ethernetif_input(ps_gmac_dev->netif);
}
}
//Gmac task
static void gmac_task(void *pvParameters)
{
struct gmac_device ps_gmac_dev = pvParameters;
while (1) {
//get high water mark for this task
rtosStats.gmacHighWaterMark = uxTaskGetStackHighWaterMark( NULL );
sys_arch_sem_wait(&ps_gmac_dev->rx_sem, 0); // Wait for the RX notification semaphore.
/ Process the incoming packet. */
ethernetif_input(ps_gmac_dev->netif);
}
}
Unfortunately I’m all alone on this project and I’ve run out of ideas here, I’m totally stumped!
Why does the queue->uxItemSize zero sometimes but not always, how do I prevent this?
Any suggestions or insights would be tremendously appreciated.
incase it is relevant, I’m using an ATSAME70N19 with Atmel studio and ASF.
Thanks in advance!