使用 rtos SDK,我能够成功开发并运行一些简单的示例,但我需要理解。
通常 c/c++ 程序以 main(...) 开头(我不记得确切的签名)
RTOS 项目似乎几乎都是从 app_main() 开始的,一些在线示例是从 user_init() 开始的
对所有来源的文本搜索对我没有帮助。似乎有一个startup.c依次调用app_main,但这并不能解释为什么一些其他示例(我没有尝试过的https://github.com/espressif/esp8266-rtos-sample-code/blob/master/03Wifi/Soft_AP_DEMO/user/user_main.c)有另一个入口点。
有人可以解释一下它的结构吗? “谁是 调用app_main?
最佳答案
ESP32 ESP-IDF SDK 启动过程在 Application Startup Flow - Application startup 中有相当详尽的描述。 。 ESP8266 RTOS SDK启动类似。
ESP-IDF application entry point is
call_start_cpu0
function found in components/esp_system/port/cpu_start.c. This function is executed by the second stage bootloader, and never returns.. . . <skip> . . .
Once
call_start_cpu0
completes running, it calls the “system layer” initialization functionstart_cpu0
found in components/esp_system/startup.c. Other cores will also complete port-layer initialization and callstart_other_cores
found in the same file.. . . <skip> . . .
The main system initialization function is
start_cpu0
. By default, this function is weak-linked to the functionstart_cpu0_default
. This means that it’s possible to override this function to add some additional initialization steps.. . . <skip> . . .
After all other components are initialized, the main task is created and the FreeRTOS scheduler starts running.
After doing some more initialization tasks (that require the scheduler to have started), the main task runs the application-provided function
app_main
in the firmware.
最后一部分最近已重构。 Here's旧版 IDF-SDK v4.2 中 app_main
调用的链接。
关于sdk - RTOS SDK app_main在哪里定义为启动函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68708553/