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

标签 sdk esp8266 esp32 rtos

使用 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 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旧版 IDF-SDK v4.2 中 app_main 调用的链接。

关于sdk - RTOS SDK app_main在哪里定义为启动函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68708553/

相关文章:

c - 这里映射一行 URL WLAN 地理位置

arduino - 使用 ESP8266 连接到强制门户 wifi

c - 使用 ESP32 的 S7735R LCD 字体

android - 从 sdk 23 降级到 22 android

sdk - 如何使用远程资源创建 JS 库?

android - 我找不到 debug.keystore 文件

使用 openssl 中间证书连接到 AWS MQTT 代理

c++ - ESP8266WiFi.h : No such file or directory

java - 有没有办法在 ESP32 上使用 JMS(java 消息服务)?

google-cloud-platform - 错误: (gcloud. auth.print-identity-token)无法从当前凭据获取身份 token