adityas wrote on Tuesday, August 06, 2019:
I have been tasked with migrating to FreeRTOS 10.0.0 on my Atmel SAM4E8C(A) chip which was originally running the 7.3.0 kernel. It has not been as out-of-box replacement as my initial research impressed on me, but bear with me, as I am new to RTOS. I have updated the Atmel Software Framework (ASF) to 3.40 (from 3.34) to upgrade to FreeRTOS 10.0.0 (it does not seem like the ASF supports 10.2.1 yet, otherwise I would have gone for that, though the release notes do not indicate I am missing out for my MCU core). Atmel Studio 7 is my IDE, and I am using the standard Atmel ICE for debugging.
- Issue: The local_uart_handler() has a xSemaphoreGiveFromISR macro that used to be defined as xQueueGenericSendFromISR (7.3.0) and is now xQueueGiveFromISR. While I think this makes sense, the following ASSERT condition is failing.
configASSERT( !( ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) && ( pxQueue->pxMutexHolder != NULL ) ) );
Both the checks evaluate to TRUE, and hence the ASSERT fails. What am I supposed to do here, as these are 3rd party files that I really don’t want to hack around?
- Issue: I am also failing the Assert condition in the use of vPortEnterCritical().
configASSERT( ( portNVIC_INT_CTRL_REG & portVECTACTIVE_MASK ) == 0 );
What extra items need to be in place for this to pass in 10.0 that were not required in 7.3.0?
I don’t feel this is relevant, but recognising gaps in my understanding: I found the ASF update did not acquire the correct type folder in …\env\atmel\src\ASF\thirdparty\freertos\freertos-10.0.0\Source\portable\GCC. The original import was for ‘ARM_CM3’, while this should have been ‘ARM_CM4F’ (my verification being that the #ifndef VFP_FP check triggered a fail when switched to #ifdef). I directly copied this folder in at the relevant location and pointed the library search path to this.
Any help or suggestions would be much appreciated. Thanks.
richard_damon wrote on Wednesday, August 07, 2019:
A Mutex inherently should be taken and then given back by the same task, its owner. I beleive earlier versions of FreeRTOS did not enforce this restriction, but some changes in how priority inhertance worked required it, It really makes no sense for an ISR to give a Mutex, is it doesn’t make sense for it to take it in the first place.
The second assert looks to be using a non-ISR API function inside an ISR.
adityas wrote on Tuesday, August 13, 2019:
Thank you Richard, especially for the quick response. You are correct. It was actually some interface files provided by Atmel ASF for FreeRTOS that were incorrect in their previous version. In fact, most issues seem to be related to ASF files rather than FreeRTOS. I’ve had to spend a few days sourcing and refactoring these files, and understanding the code structure to a point I can (somewhat) follow what is going on.
For the second issue, the code was using vPortEnterCritical()/vPortExitCritical() in an ISR, so swapped that out for portSET_INTERRUPT_MASK_FROM_ISR() / portCLEAR_INTERRUPT_MASK_FROM_ISR().
rtel wrote on Tuesday, August 13, 2019:
The simplest change would be to use a binary semaphore instead of a
mutex - that just requires the function used to create the semaphore to
adityas wrote on Friday, September 20, 2019:
Hi, I thought it best to continue this thread, as my question is a resultant of work on this. Hopefully it is explained well enough below.
We have a structure on which activity is commenced in a task (after acquiring a mutex) and activity on it is completed in an interrupt handler (which is where the mutex was being released). With 10.0.0, Mutex is not allowed to be given in an interrupt with the newer version of FreeRTOS. But, as far as I can tell right now, conversion to binary semaphore instead of mutex will not be a good idea. I do want to protect the access ot this structure, and ensure completion before it is reset.
I have been unable to find (perhaps understand) similar situations. One thought I have is using a deferred interrupt handling that uses a task notification to release the mutex. But this is essentially ending up using a binary semaphore to release a mutex. Is there a better solution?
rtel wrote on Friday, September 20, 2019:
The only difference between a binary semaphore and a mutex is that
mutexes implement a priority inheritance mechanism and binary semaphores
don’t. You can protect access to a resource using a binary semaphore too.
adityas wrote on Monday, September 30, 2019:
Thanks Richard. I probably made a mistake earlier with the give and take of the semaphore. The main line function needing the semaphore is taking now. Though it does seem the timing of my application is a little different from the mutex method from FreeRTOS 7.3.0, based on the debug messages I am getting. I will be implementing a trace facility to verify this.
The other problem I had been having turned out (again) to be a bug in the Atmel ASF driver file.