STM32WB55RG – How to Integrate BLE with FreeRTOS (CMSIS-RTOS2) in an Existing Project?
Hi everyone,
I am working on a project using the STM32WB55RG and would appreciate some guidance on integrating the STM32WB BLE stack into an existing FreeRTOS-based application.
Current Setup
My project currently uses:
- MCU: STM32WB55RG
- RTOS: FreeRTOS with the CMSIS-RTOS2 API
- Configuration/code generation: STM32CubeMX
- An existing firmware application that is already functional and uses multiple FreeRTOS tasks, semaphores, flags, etc.
At this stage of the project, changing to another RTOS or converting the application to bare-metal is unfortunately not an option, so I need to integrate BLE into the existing FreeRTOS/CMSIS-RTOS2 architecture.
BLE Requirements
I would like the STM32WB55 to support:
- BLE advertising
- Another BLE device should be able to connect to the STM32WB55 and retrieve data from it, most likely through a custom GATT service/characteristic.
Problem
I enabled BLE using STM32CubeMX and generated the required BLE code.
However, I am having problems when initializing the BLE application using:
MX_APPE_Init();
When I call MX_APPE_Init() in main() before the FreeRTOS initialization/startup, the system does not initialize my FreeRTOS tasks, semaphores, event flags, etc. correctly, and the system eventually resets/reboots.
Without the BLE initialization, the existing FreeRTOS application works correctly.
I have found some older STM32WB forum discussions regarding compatibility/integration issues between the STM32WB BLE stack and FreeRTOS, but most of the discussions I found are around 2–3 years old. Therefore, I am not sure what the currently recommended architecture is.
Question
What is the recommended way to use the STM32WB BLE stack together with FreeRTOS and CMSIS-RTOS2 in an existing application?
In particular:
- Is there a current STM32CubeWB example that demonstrates BLE + FreeRTOS/CMSIS-RTOS2 on the STM32WB55?
- Are there known conflicts between the BLE stack/middleware and FreeRTOS that could explain why the system resets during or after
MX_APPE_Init()?
My main goal is to keep the existing FreeRTOS/CMSIS-RTOS2 application architecture while adding BLE advertising and a GATT connection that allows another BLE device to connect and retrieve data.
Any guidance would be greatly appreciated.
Thanks!
