New data logging/tracing toolkit and considerations for integration into FreeRTOS

Hello!

I released the new real-time binary data logging/tracing toolkit a few weeks ago - see the RTEdbg on Github. The toolkit is ready for use on devices with an ARM Cortex-M core. I have added two new drivers that allow it to be used on non-ARM 32-bit devices and checked the compatibility of the data logging library with FreeRTOS before releasing the updated version.

I have a few questions and hope to get answers here, as I expect that some low-level programmers are following the FreeRTOS/Kernel discussions.

Things regarding re-entrancy are pretty straightforward if the CPU core supports mutex (atomic) instructions. I think I also understand how to do this for processor cores like ARM Cortex M0/M0+/M23 that do not support atomic operations. These CPU cores do not allow a non-privileged (normal) task to disable/enable interrupts using the CPS instruction. To check everything, I created a mini-project for an ARM Cortex M0+ based STM32 device using STM32CubeMX. While playing with (debugging) this project, I noticed that

  • the FreeRTOS port for the Cortex M0 executes all tasks in privileged mode (the CPS instruction runs normally), and
  • the portPRIVILEGE_BIT is not used at all in the Cortex M0 version.

If I could use CPS instructions in my logging implementation for these processor families, it would simplify and speed up data logging compared to the version that also requires checking the values of the CONTROL and IPSR processor registers.

My questions are:

  1. Is the interrupt enable/disable (task always executed in privileged mode) only possible for the ARM Cortex M0 FreeRTOS port implementation or is it general for all CPU cores where the interrupts have to be temporarily disabled for the atomic operations? Are such details described somewhere (PDF file, web page, …)?
  2. Is there an existing project (preferably for an STM32 device, e.g. M0, M4, M7) that implements either all or at least most of the logging macros (FreeRTOS Trace Hook Macros)? I want to focus on the design of the macros themselves and not on writing an application to test FreeRTOS activity logging.

Best regards,
Branko

You can disable/enable interrupts on all the ports by using taskDISABLE_INTERRUPTS and taskENABLE_INTERRUPTS macros. Regarding privilege level -

  1. If you use a FreeRTOS port without Memory Protection Unit (MPU) support, all the tasks execute as privileged.
  2. If you use a FreeRTOS port with Memory Protection Unit (MPU) support, the application tasks execute as unprivileged.

In both the cases (MPU and non-MPU), the kernel code always executes as privileged. Assuming that you are implementing FreeRTOS trace macros, which are called from within the kernel, your code would always execute as privileged and you do not need to worry about privilege level.

Trace macros are provided for the tracing applications and you can look at the device code implementation of the tracing tools described here - FreeRTOS-Kernel/.github/third_party_tools.md at main · FreeRTOS/FreeRTOS-Kernel · GitHub.

Thanks for the quick response. It is clear to me regarding the privileged/unprivileged execution. I’ll put together my own test project for FreeRTOS data logging.