RTOS SDK app_main 在哪里定义为启动函数?

RTOS SDK Where is app_main defined as startup function?

使用 rtos SDK 我能够开发并 运行 成功了一些简单的示例,但我需要理解。

通常一个 c / c++ 程序以 main(...) 开头(我不记得确切的签名)

RTOS 项目似乎几乎都以 app_main() 开始,一些在线示例以 user_init()

开始

对所有来源进行文本搜索对我没有帮助。似乎有一个 startup.c 依次调用 app_main 但这并不能解释为什么一些 other 示例(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 function start_cpu0 found in components/esp_system/startup.c. Other cores will also complete port-layer initialization and call start_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 function start_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 link 到旧版 IDF-SDK v4.2 中的 app_main 调用。