FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [August 2013 Threads] task in stuck in running queue stm32f407Posted by https://www.google.com/accounts on August 24, 2013 Hello, I am using stm32f407 with freertos 7.5.0. I have an ethernet task (it has the highest priority) which gets stuck in running queue and is not getting executed anymore. All other tasks with lower priority are actually running in the system. Selected portion of the code is displayed below. On startup i have created a binary semaphore which is given by the interrupt handler whenever a packet is received. I have tried to implement a NAPI sort of behaviour so i am disabling the interrupt and it is reenabled later when descriptor chain is traversed. There is a high priority task running which takes the above mentioned semaphore and calls a function to traverse the descriptor chain. After some time, 15-20 minutes of packet processing (flood ping), my ethernet thread which was supposedly waiting on the semaphore stops responding i.e. my led 2 stops blinking and since my function which enables ethernet interrupt is not called, so does my interrupts. Now there is a low priority blinker task which is responsible for blinking another led. That keeps on running. Via gdb i can see idle task getting scheduled regularly. the state of all the tasks as reported by vTaskList() is Eth_if R 4 302 2 IDLE R 0 38 6 tcpip_thr B 3 858 1 blinker B 0 93 3 Tmr Svc B 2 224 7 server S 0 39 4 data_hand S 4 38 5
xSemaphoreHandle eth_Semaphore = NULL;
//ethernet interrupt handler void ETH_handler(void) { uint32_t tmp,tmp2; signed portBASE_TYPE sem_ret; portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
tmp = ETHDMA->SR; /* Frame received */ if ( tmp & ETH_DMASR_RS) { //received a packet /* Give the semaphore to wakeup LwIP task */ ETH_STATS(stats.ints.rs); sem_ret = xSemaphoreGiveFromISR( eth_Semaphore, &xHigherPriorityTaskWoken ); if (sem_ret == pdPASS) { eth_int_ds++; NVIC_DISABLE_INT(ETH_IRQn); } } if( xHigherPriorityTaskWoken != pdFALSE ) { portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ); } }
void ethernetif_input( void * pvParameters ) // task named eth_if { struct pbuf *p,*n; char i=0; eth_start(); // enables the ethernt interrupt and creates a binary semaphore vSemaphoreCreateBinary(eth_Semaphore);
for( ;; ) { if (xSemaphoreTake( eth_Semaphore, 100)==pdTRUE) //blocking time is 100 ticks { //traverse the descriptors and send to lwip from here //currently lwip code is commented out to debug the problem } if (i%2) led_off(LED_RED2); else led_on(LED_RED2); } }
RE: task in stuck in running queue stm32f407Posted by https://www.google.com/accounts on August 24, 2013 Forgot to add priorities of various taks and interrupt
#define configUSE_PREEMPTION 1 #define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 ) #define configIDLE_SHOULD_YIELD 1 #define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
NVIC_SET_PRIORITY(ETH_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
xTaskCreate(ethernetif_input, (signed char*) "Eth_if", 350 , NULL, 4, NULL) ;
RE: task in stuck in running queue stm32f407Posted by MEdwards on August 24, 2013 “I am using stm32f407 with freertos 7.5.0” If you are using the ST peripheral drivers then you should update to 7.5.2. 7.5.2 is just for STM32 users. See the change history http://www.freertos.org/History.txt “if( xHigherPriorityTaskWoken != pdFALSE ) { portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ); }” You don't need the if(){} because that is done for you inside the portEND_SWITCHING_ISR() macro. When the ethernet task gets stuck, place a break point in the ethernet interrupt to see if it is still getting called. It might be that its interrupt was never enabled again.
RE: task in stuck in running queue stm32f407Posted by MEdwards on August 24, 2013 “NVIC_SET_PRIORITY(ETH_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);” Where is that function coming from? Again if you are using the STM32 peripheral driver libraries you also need to set the mapping of priority bits so all bits are preemption priority. The ST libraries crash if you leave it at its default value. See the red text on this link http://www.freertos.org/RTOS-Cortex-M3-M4.html Do that, and also set configASSERT() to a null loop if you have not done so already. If you are using V7.5.2 that will trap any configuration mistake.
RE: task in stuck in running queue stm32f407Posted by https://www.google.com/accounts on August 24, 2013 Hi, thanks for helping me. below is the defination of the NVIC_SET_PRIORITY Also as stm32f407 has 4 bits of priority, i am using a priority group value of 3 instead of 4. A value of 3 means 4 bits are being used for group priority (arm reference manual). And my code does work for some time before it dies out. #define __NVIC_PRIO_BITS 4
static inline void NVIC_SET_PRIORITY(IRQn_Type IRQn, uint32_t priority) { if(IRQn < 0) { SCB->SHPR[((uint32_t)(IRQn) & 0xF)-4] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for Cortex-M System Interrupts */ else { NVIC->IPR[((uint32_t)(IRQn)/4)] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for device specific Interrupts */ }
RE: task in stuck in running queue stm32f407Posted by MEdwards on August 24, 2013 NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 ); sets the value to 3, so it sounds like you have it right. Are you using V7.5.2 yet? If so you will know if you have it wrong. “And my code does work for some time before it dies out.” That is what would happen if you had it wrong.
RE: task in stuck in running queue stm32f407Posted by https://www.google.com/accounts on August 25, 2013 Hi,
upgraded to 7.5.2. it seems that problem was in the NVIC_SET_PRIORITY. fixed that and system seems stable thanks
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|