This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Semaphore issue in RL-ARM MDK4.

Hi!

I was developing a new firmware based on MDK4 RTX OS with a STM32L053 uC (using the Discovery Kit) and I have found a bizzare behavior on a very simple semaphore arquitecture.

Basically, I need to receive frames (delimited) from an USART. When complete, the ISR handler sends a signal (using semaphores) to a task in order to process the frame.

Then I used os_sem_init, os_sem_wait and isr_sem_send APIs for doing that.

When I had this working, I wanted to push its limits and I started sending very fast frames to the usart just to verify the the arquitecture worked fine.

It worked for several frames, but suddenly the firmware hanged (sometimes it went to a hardfault, other times it just hanged at the WFI in the idle task, and other times it did many bizarre issues).

Initially I doubed about my code (the usart driver, the framing algorithms, and some other), so I reduce the example to the minimum. The ISR handler sends the semaphore and the task waits for it. When I send the semaphore I toggle a GPIO and when the task unblocks I toggle another. I did this in order to monitor the behavior witha logic analyzer.

The result was that when firing the ISR handler very fast, somehow the kernel missed some signals. When it is working, the logic analyzer shows the a correlation between the GPIO toggled by the isr handler, and the GPIO toggled by the task. However, when it fails, one toggle occurs (the ISR one) but the other does not.

The OS ISR queue is big enough to handle all the isr requests. The stacks (tasks stacks and system stack) are big enough as well. 

I tried the same firmware but using CMSIS api over FreeRTOS (the one that came with the STM32CubeIDE), and this doesn't happen.

If anyone has some comment/solution/tip about it, please let me know.

Best regards.

  • UPDATE: I 've created another project using the wizard from keil and setting CMSIS RTOSv1 (that has the same underlying kernel of the RL ARM MDK4 ).

    The functionality is the same. One semaphore. An ISR handler that signals and a task that unblocks with the signal.

    It fails the same.

    Then, I did the same with CMSIS RTOSv2 and it doesn't fail at all.