When I first started coding decades ago, every program in C began with main(). Having gotten back in after decades off and working in the ESP IDF, all applications begin with app_main().
Is there a main() that calls app_main(), and if not, what calls app_main()? What does this caller do? I've grepped for "main()" in the IDF and was surprised at how many results there were. Which is the main(), if that is the first routine called that calls app_main(), and what does it do? I'm guessing it starts the scheduler as I see "Scheduler started" for both CPUs in my log traces. Is app_main just another task within FreeRTOS?
Is there anywhere where all this pre-application run-time setup is explained?
Thanks for any enlightenment.
When I was knee-high to Kernigan and Ritchie.......
Re: When I was knee-high to Kernigan and Ritchie.......
https://docs.espressif.com/projects/esp ... notes.html covers the boot process in pretty good detail.
Jason
Jason
Re: When I was knee-high to Kernigan and Ritchie.......
Jason,
Thank you. Your link put me on exactly the right path. Do you know off the top if all tasks created in app_main() will continue to run if app_main() returns? This was implied but not explicitly stated at the link you steered me to.
Thank you. Your link put me on exactly the right path. Do you know off the top if all tasks created in app_main() will continue to run if app_main() returns? This was implied but not explicitly stated at the link you steered me to.
Re: When I was knee-high to Kernigan and Ritchie.......
Yep, they continue to run. My app, for instance, starts several tasks in app_main() and then returns.
In general, any FreeRTOS task that is started is expected to run forever. Returning is normally "bad", but the ESP initialization code handles a return from app_main() correctly by calling vTaskDelete on it. If you have tasks that need to exit, make sure to call vTaskDelete on them to free memory allocated when you xTaskCreate.
Jason
Re: When I was knee-high to Kernigan and Ritchie.......
Thanks Jason for the great explanation.
The decision to name the "main" routine "app_main" is because it doesn't behave the same as C standard main() - it runs in an RTOS task, and it is safe to return from. Will add a specific section about these differences on the "general notes" page that Jason linked to.
The decision to name the "main" routine "app_main" is because it doesn't behave the same as C standard main() - it runs in an RTOS task, and it is safe to return from. Will add a specific section about these differences on the "general notes" page that Jason linked to.
Who is online
Users browsing this forum: Bing [Bot], dzungpv, ESP_Roland, Google [Bot] and 100 guests