app_main and task core pinning
Posted: Sun Nov 22, 2020 4:47 pm
Is app_main guaranteed to always be run on pro cpu?
The docs seem to suggest this (https://docs.espressif.com/projects/esp ... notes.html) but doesn't explicitly state this.
I was going to look at the functions start_cpu0 and start_cpu1, but they are not actually in components/esp32/cpu_start.c (as stated by the docs). That file actually doesn't exist either (at least at that location). In fact there are two cpu_start.c files, neither in components/esp32/. The first in components/esp_system/port/ which contains call_start_cpu0 and call_start_cpu1 but not start_cpu0 or start_cpu1. The second is found in examples/build_system/cmake/idf_as_lib/stubs/esp32/ and is equally unhelpful.
The reason this is important is that (according to my understanding) gpio_install_isr_service() (and similar functions) 'pin' the interrupt handling to the core that is used for initialization. So I then would need to be certain which core app_main is pinned to when I called these functions.
This leads to the second tangentially related problem. If app_main returns, the main task is deleted, and everything works as expected. But the documentation for xTaskCreatePinnedToCore() states: "Tasks must be implemented to never return (i.e. continuous loop).". So how is it the main task will happily delete itself upon return, but user spawned tasks cannot? And if user spawned tasks cannot return, what is the point of vTaskDelete()?
The docs seem to suggest this (https://docs.espressif.com/projects/esp ... notes.html) but doesn't explicitly state this.
I was going to look at the functions start_cpu0 and start_cpu1, but they are not actually in components/esp32/cpu_start.c (as stated by the docs). That file actually doesn't exist either (at least at that location). In fact there are two cpu_start.c files, neither in components/esp32/. The first in components/esp_system/port/ which contains call_start_cpu0 and call_start_cpu1 but not start_cpu0 or start_cpu1. The second is found in examples/build_system/cmake/idf_as_lib/stubs/esp32/ and is equally unhelpful.
The reason this is important is that (according to my understanding) gpio_install_isr_service() (and similar functions) 'pin' the interrupt handling to the core that is used for initialization. So I then would need to be certain which core app_main is pinned to when I called these functions.
This leads to the second tangentially related problem. If app_main returns, the main task is deleted, and everything works as expected. But the documentation for xTaskCreatePinnedToCore() states: "Tasks must be implemented to never return (i.e. continuous loop).". So how is it the main task will happily delete itself upon return, but user spawned tasks cannot? And if user spawned tasks cannot return, what is the point of vTaskDelete()?