cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop the freertos scheduler and execute the code from while of main function?

AMull.11
Associate II

Hi Guys,

I am working on one of the project using STM32H743, where code will update from the UART.

The Application code is based on the FreeRTOS.

So, when I want to update the firmware i need to stop the FreeRTOS scheduler and get back to the while loop of main function.

I had tried with the vTaskEndScheduler() API, but still code is not coming to while loop of main function.

If any one knows please help me to solve this issue.

Any kind of help will be appreciated.

Thank You.

11 REPLIES 11
Osto
Senior

Dear AMull,

Its not possible to continue the main. You can stop the scheduler and call your own function to continue with FW update. I don't know the structure of your main function. If there is no call to RTOS functions then you can also call the main yourself.

I hope this helps.

Osto

hs2
Senior

Why not using vTaskSuspendAll or disable all interrupts and proceed ? However, it depends on what you want to do (next) in your update procedure.

AMull.11
Associate II

Thank you Osto,

Can give me some inputs how to do this.

Once i get the command to update the firmware then i won't get back to the freertos.

Thank you hs2,

Yeah i did that also, still code is not coming t while of main.

In update I just want to store TouchGFX assets in External flash and then i'll jump to the System Bootloader to update the application code.

You don’t need to go back to main (which is not possible resp. supported). Why do you want that ?

Just stop scheduling (and maybe ISRs by disabling all interrupts) as described before if needed and run the code you want.

When you call ending scheduler or suspend all tasks then your system is like a bare metal system. You can continue your job in the same fuction or call another function to do that. From that time, that's your problem to manage everything at time. The whole system (RTOS related) is frozen but everythig else should work as initialized before supension or you can reinitialize them. You need to stop all activities which has to do with RTOS. Call to such functions would stuck or do nothing or generate exception/faults. In this situation its more luck than knwoledge when its working when you make calls to RTOS. Do nothing which has to do with RTOS. You can still use the CMSIS functions like HAL_Delay instead of xTaskDelay.

I dont know your eaxct situation but normally when I make a firmware update, after success, I reset the system to boot with my new firmware. If you want to start new firmware without reseting the system, thean you need to either uninitialize every thing and call the reset handler yourself or make sure that your firmware deinitialize everything first and then continue with setting everything.

Flashing a new firmware and start RTOS again makes no sense because you have no idea if everything is in the same place as before. The new firmware could have new static variables then the new variable could shift everything few bytes up. Then your new firmware uses locations which dont belongs to the save variables. I wouldn't expect that strongly.

I hope this will answer all you questions. Else please give me more information to help you.

Osto

Pavel A.
Evangelist III

FreeRTOS documentation says that vTaskEndScheduler is implemented only in x86 port.

https://www.freertos.org/a00133.html

--pa

You are right. So you can use only vTaskSuspendAll.

Hi Osto, Thank you for info

I will describe brief idea of project,

In this Firmware has Application code, Touch GFX application code and TouchGFX assets.

Where Application code and TouchGFX application code has to be store in Internal flash.

And TouchGFX assets has to be store in External Flash.

So in Application there is 4 threads.

So when I want to Update the firmware, first I need to update the TouchGFX assets from the Application .

And after that I'll jump to system bootloader, then I'll update the Application code and TouchGFX application code and reset the board the plane new Firmware has to be run.

This is actual idea​.

But when I want to update the ​TouchGFX assets I want to exit from the freertos and run the one funnction from where I'll update the TouchGFX assets and once it completed then I'll Jump to System bootloader.

Give some idea how can I do this, or if you know other way suggest me. ​