STM32WB, what might cause CPU2 to FAIL and stuck during initialization?
Hello,
I have a project which contains both: Bootloader (BL) and Application (App.)
The BL is based on minimal devices without interrupts, mainly RS485 - and worked Fine!
The App. is based on "BLE_PERIPHERAL_LITE" example by ST, with my additional freeRTOS integration - Also worked Fine!
After Reset, the control is transferred to the BL then it Jumps successfully to my App. (which is located at address 0x08008000), most of the times App. initialization goes - Fine, and the App. is working OK!!
However sometimes (20% of the cases) the App. initialization doesn't succeed and it stuck in endless loop, but do recover after IWDT timeout.
Below please find my main() code, on 20% of the times, the App. performs the CPU2_Init(); procedure (at line#42) and then stuck at line#48 until next IWDT occur, then my App. successfully recover and RUN!!!
My question are:
- What might cause APP_FLAG_CPU2_INITIALIZED and APP_FLAG_WIRELESS_FW_RUNNING, M0+ flags (at lines #44-45) to remain "0" after Reset, at 20% of the times ?
- What shell I add in order to improve the App. running after reset, to 100%?
Thanks In Advance,
Micha
- /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
- HAL_Init();
- /* USER CODE BEGIN Init */
- /* Tune the HSE internal load capacitors - P-NUCLEO-WB55.Nucleo board */
- // micha removed Tune_HSE();
- // Reset_Device();
- /* Configure the debug support if needed */
- APPD_Init();
- /* USER CODE END Init */
- /* Configure the system clock */
- SystemClock_Config();
- /* USER CODE END SysInit */
- /* Initialize all configured peripherals */
- MX_GPIO_Init();
- MX_DMA_Init();
- MX_USART1_UART_Init();
- MX_RTC_Init();
- MX_RF_Init();
- MX_LPUART1_UART_Init();
- MX_SPI1_Init();
- MX_TIM2_Init();
- MX_TIM1_Init();
- MX_TIM16_Init();
- #ifdef __ENABLE_TOUCH_PAD__
- MX_TSC_Init();
- #endif
- #ifdef __WATCHDOG__
- MX_IWDG_Init(); // already done in BL (bootloader)
- #endif
- /* USER CODE BEGIN 2 */
- /* Initialize all transport layers */
- #ifdef __ENABLE_BLE__
- CPU2_Init();
- /* Wait until the CPU2 gets initialized */ // Micha 2020-12-08 this is a critical trap, after Boot loader initialization!!!
- while((APP_FLAG_GET(APP_FLAG_CPU2_INITIALIZED) == 0) \
- || (APP_FLAG_GET(APP_FLAG_WIRELESS_FW_RUNNING) == 0))
- {
- /* Process pending SYSTEM event coming from CPU2 (if any) */
- SYS_ProcessEvent(); <== Sometimes code stuck here
- }
- /* Configure the CPU2 Debug (Optional) */
- APPD_EnableCPU2();
