cancel
Showing results for 
Search instead for 
Did you mean: 

WiFi Initialization Issues on STM32H7B3I-DK along with TouchGFX and FreeRTOS

Ayoub_Bnina
Associate III

Title: Seeking Community Assistance: WiFi Initialization Issues on STM32H7B3I-DK with TouchGFX and FreeRTOS

Introduction:
I am currently facing challenges with initializing WiFi on the STM32H7B3I-DK board following the clock and weather example provided by STMicroelectronics. The main issue arises when attempting to initialize WiFi WIFI_Init() before starting the FreeRTOS kernel (`osKernelStart()`). This results in the program getting stuck in an infinite loop, possibly due to a semaphore-related function `wait_spi_tx_event()` defined in the `net_conf_es_wifi_spi` file. Furthermore, when trying to initialize WiFi within a task, I encounter `NET_ERROR_NO_MEMORY` errors during memory allocation (`malloc()`), even after increasing the heap size.

Problem Analysis:
1. Infinite Loop Issue: The program gets stuck in an infinite loop, likely due to WiFi initialization occurring before starting the TouchGFX task. This situation leads to problems with the semaphore related to SPI transmission (`spi_tx_sem`), which is referenced in the `wait_spi_tx_event()` function.

The SEM_WAIT is Defined in the DedicatedBufferVideoController File as shown.

Ayoub_Bnina_0-1707345105637.png

Ayoub_Bnina_1-1707345170611.png

 

 

2. Memory Allocation Errors: Despite increasing the heap size, attempting to initialize WiFi within a task results in memory allocation errors (`NET_ERROR_NO_MEMORY`). This indicates insufficient memory available for WiFi initialization and operation.

Ayoub_Bnina_2-1707345581225.png

Ayoub_Bnina_3-1707345611466.png


I am reaching out for assistance in resolving these WiFi initialization issues on the STM32H7B3I-DK board with TouchGFX and FreeRTOS (CMSIS V2).

Any advice, guidance, or assistance from community members or ST Employees would be highly appreciated.

Thank you for your support.

1 ACCEPTED SOLUTION

Accepted Solutions
Pavel A.
Evangelist III

Yes, possible - when the malloc (the C runtime library function, or whatever "malloc" is in your project) is correctly integrated with the multi-threading and with the MCU project (the heap is allocated in the proper RAM area).

 

View solution in original post

6 REPLIES 6
Pavel A.
Evangelist III

 the clock and weather example provided by STMicroelectronics. 

Do you build and run the example as is, or made any changes?

 

Actually I didn't run it because I had an error in the debug of the clock and weather, but I Initialized the wifi seperately without activating the FreeRTOS nor TouchGFX and it worked smoothly, so the problem is obvious but I couldn't determine how to approach it. Discussing changes, I only copied the Network Library files and added paths

Pavel A.
Evangelist III

If you do something before starting the RTOS scheduler (osKernelStart) the RTOS timer does not tick, semaphores and other locks don't work... if the wi-fi code uses these RTOS services, it's no go.

 

Ayoub_Bnina
Associate III

Yes I understand but what I found in the Clock and Wheather example that there is no DedicatedBufferVideoController file where the SEM_WAIT is defined, In Addition the latter have Initialized the WIFI before the kernelStart I suppose.

Ayoub_Bnina
Associate III

Is it possible to use malloc inside a running task and avoiding getting NET_ERROR_NO_MEMORY ?

Pavel A.
Evangelist III

Yes, possible - when the malloc (the C runtime library function, or whatever "malloc" is in your project) is correctly integrated with the multi-threading and with the MCU project (the heap is allocated in the proper RAM area).