Skip to main content
Visitor II
May 13, 2024
Question

stm32u575 FreeRTOS

  • May 13, 2024
  • 4 replies
  • 2119 views

Hi,

I have started my hand-on experiments of FreeRTOS using stm32u575 uc with stm32u575zi-q nucleo board as non secure.

I have created 2 task and their handler. With the help of seial viewer, printed some messages.While executing the code,it does nothing.As I am newbiee,Unable to debug what's the exact issue.Kindly help me with it.

Herewith I have attached the github link of my repo for your reference.

https://github.com/soulbee30/FreeRTOS-main.

Thanks In advance.

 

    This topic has been closed for replies.

    4 replies

    ST Employee
    May 14, 2024

    Hello @Kajol30, welcome to ST Community, 

    I cannot see any thread creation in the project you've shared, are you sure this is the complete project? 

    Also, check if the stack size for each task is sufficient and not causing a stack overflow. Your FreeRTOSConfig.h file doesn't currently have stack overflow checking enabled, you can enable it using

     

     #define configCHECK_FOR_STACK_OVERFLOW 2

     

    this will call the vApplicationStackOverflowHook() function if an overflow is detected.

    Please check: Stack usage and Stack Overflow Checking 

     

    Super User
    May 14, 2024

    @Kajol30 wrote:

    As I am newbiee, Unable to debug


    Is that just a newbie to FreeRTOS, or a newbie to embedded firmware development in general? Or to software development in general?

    If (one of) the latter, it might be wise to spend some time gaining experience with the basics - including debugging - before moving on to more advanced topics like RTOS ...

    Also, for getting started with FreeRTOS without the added complications of embedded hardware, there is are simulators (for Windows, et al) :

    https://www.freertos.org/emulation-simulation/

     

    Technical Moderator
    May 14, 2024

    Hello @Kajol30 ,

    Just downloaded your attached project and opened it, there is no FreeRTOS call in your application!

    This is your main, it's almost void : it does almost nothing!:

     

     

    int main(void)
    {
     /* USER CODE BEGIN 1 */
    
     /* USER CODE END 1 */
    
     /* MCU Configuration--------------------------------------------------------*/
    
     /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
     HAL_Init();
    
     /* USER CODE BEGIN Init */
    
     /* USER CODE END Init */
    
     /* Configure the system clock */
     SystemClock_Config();
    
     /* USER CODE BEGIN SysInit */
    
     /* USER CODE END SysInit */
    
     /* Initialize all configured peripherals */
     MX_GPIO_Init();
     /* USER CODE BEGIN 2 */
    
     /* USER CODE END 2 */
    
     /* Infinite loop */
     /* USER CODE BEGIN WHILE */
     while (1)
     {
     /* USER CODE END WHILE */
    
     /* USER CODE BEGIN 3 */
     }
     /* USER CODE END 3 */
    }

     

    Could you please clarify this point?

    ST Employee
    May 15, 2024

    Hi Kajol30,

    I see you're trying to use FreeRTOS on your own without STM32Cube generated code and that is fine it should work also but there are a lot more steps involved.

     

    At first glance, you are creating tasks with very tiny stack depth of 20

     

     status = xTaskCreate(task1handler,"Task1",20,"Hello World from Task1",2,&task1_handler);
     configASSERT(status == pdPASS);
    
     status = xTaskCreate(task2handler,"Task2",20,"Hello World from Task2",2,&task2_handler);
     configASSERT(status == pdPASS);

     

    But in freeRTOS config there is a defined stackdepth macro that you should use if you want a default stack depth

     

    #define configMINIMAL_STACK_SIZE ((uint16_t)128)

     

    You also have no UART implemented so there is nowhere for printf to go, furthermore you need to retarget printf.

    However the issues above alone will not solve your problems, I suggest letting Cube Setup FreeRTOS and start you off with a working default task. 

    I suggest take a look at some of our articles in the knowledge base to get you up to speed. 


    - Retarget printf 

    - FreeRTOS MOOC (YoutTube) 

    To my colleagues the code was on a different branch called task_creation in the linked github repo. 

    Kajol30Author
    Visitor II
    June 23, 2024

    Thank you for taking time for replying.I am using ITM feature with the help of SWO will be able to print the message.SWO and ITM is working properly. While debugging I found that 2 task  are created and the status of both  task creation is success. scheduler is started using vTaskStartScheduler and after that it goes into MemManage_Handler and stuck there in while loop. Does anything is related to the configuration which I missed.Can you help me with it?

    ST Employee
    June 26, 2024

    I can take a look at this, is the updated code in the repo?