本文來(lái)源電子發(fā)燒友社區(qū),作者:李先生, 帖子地址:https://bbs.elecfans.com/jishu_2307381_1_1.html
前言
磨刀不誤砍材工,為了方便后面開(kāi)發(fā),先對(duì)照著打印信息和代碼,對(duì)啟動(dòng)過(guò)程進(jìn)行分析,對(duì)程序執(zhí)行過(guò)程有個(gè)大致了解。
程序入口點(diǎn),內(nèi)核啟動(dòng)
device/soc/esp/esp32/components/esp_system/port/cpu_start.c
call_start_cpu0
打印如下
I (370) cpu_start: Pro cpu up.
I (376) cpu_start: Single core mode
device/soc/esp/esp32/components/esp_system/startup.c
start_cpu0_default
打印如下
I (371) cpu_start: Pro cpu start user code
I (373) cpu_start: cpu freq: 160000000
I (378) cpu_start: Application information:
I (380) cpu_start: Project name: spp_client_demo
I (383) cpu_start: App version: 1
I (389) cpu_start: Compile time: Sep 23 2022 21:28:08
I (393) cpu_start: ELF file SHA256: aa63348688c93d38...
I (394) cpu_start: ESP-IDF: v4.3.1-dirty
device/soc/esp/esp32/components/heap/heap_caps_init.c
heap_caps_init
打印如下
I (94) heap_init: Initializing. RAM available for dynamic allocation:
I (118) heap_init: At 3FF80000 len 00002000 (8 KiB): RTCRAM
I (118) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (118) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
I (118) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (118) heap_init: At 3FFC5128 len 0001AED8 (107 KiB): DRAM
I (118) heap_init: At 3FFE0440 len 0001FBC0 (126 KiB): D/IRAM
I (118) heap_init: At 40078000 len 00008000 (32 KiB): IRAM
I (118) heap_init: At 400905E0 len 0000FA20 (62 KiB): IRAM
kernel/liteos_m/kernel/src/los_init.c
LOS_KernelInit
打印如下
entering kernel init...
kernel/liteos_m/kernel/src/los_sched.c
OsSchedStart
打印如下
Entering scheduler
系統(tǒng)初始化
deviceboardopenvalleyniobeu4liteos_mtargetsrctarget_startup.c
OHOS_SystemInitEntry ->
int err;
printf("Code Build Time:%s %sn", __DATE__, __TIME__);
before_ohos_run();
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
nvs_flash_erase();
ret = nvs_flash_init();
}
DeviceWifiStart();
init_trace_system();
err = DeviceManagerStart();
if (err) {
printf("DeviceManagerStart.ret=0x%Xn", err);
}
OHOS_SystemInit();
ohos_app_main();
return NULL;
l 先打印編譯時(shí)間
l before_ohos_run調(diào)用鉤子函數(shù)BEFORE_OHOS_RUN_FUNC_ENTRY
該函數(shù)由#define BEFORE_OHOS_RUN(func) void *BEFORE_OHOS_RUN_FUNC_ENTRY = (func)宏定義,實(shí)際是一個(gè)全局函數(shù)指針變量
l nvs_flash_init進(jìn)行flash初始化
對(duì)應(yīng)打印如下
l DeviceWifiStart
l init_trace_system 注冊(cè)打印輸出接口g_hilogOutputProc賦值為HilogProc_Impl
OutputLog即調(diào)用該函數(shù)打印輸出
l DeviceManagerStart
l OHOS_SystemInit
l ohos_app_main調(diào)用用戶代碼
Code Build Time:Sep 23 2022 21:52:39
I (321) spi_flash: detected chip: generic
I (218) spi_flash: flash io: dio
I (18) wifi:wifi driver task: 6, prio:23, stack:6656, core=0
I (56) system_api: Base MAC address is not set
I (156) system_api: read default base MAC address from EFUSE
I (18) wifi:wifi firmware version: 88c8747
I (28) wifi:wifi certification version: v7.0
I (28) wifi:config NVS flash: disabled
I (28) wifi:config nano formating: disabled
I (38) wifi:Init data frame dynamic rx buffer num: 32
I (38) wifi:Init management frame dynamic rx buffer num: 32
I (48) wifi:Init management short buffer num: 32
I (48) wifi:Init dynamic tx buffer num: 32
I (48) wifi:Init static rx buffer size: 1600
I (58) wifi:Init static rx buffer num: 10
I (58) wifi:Init dynamic rx buffer num: 32
I (141) wifi_init: rx ba win: 6
I (145) wifi_init: tcpip mbox: 32
I (146) wifi_init: udp mbox: 6
I (147) wifi_init: tcp mbox: 6
I (148) wifi_init: tcp tx win: 5744
I (149) wifi_init: tcp rx win: 5744
I (150) wifi_init: tcp mss: 1440
I (157) wifi_init: WiFi IRAM OP enabled
hilog will init.
hievent will init.
hievent init success.
01-01 00:00:00.247 0 48 D 0/HIVIEW: log limit init success.
Littlefs.mount=/Openvalley addr=0x312000 size=832K OK!!!
01-01 00:00:00.257 0 48 I 1/SAMGR: Bootstrap core services(count:1).
01-01 00:00:00.263 0 48 I 1/SAMGR: Init service:0x3f401224
hiview init success.
01-01 00:00:00.269 0 112 I 1/SAMGR: Init service 0x3f401224 20ms> success!
01-01 00:00:00.277 0 112 I 1/SAMGR: Initialized all core system services!
01-01 00:00:00.283 0 112 I 1/SAMGR: Goto next boot step return code:-6
用戶代碼執(zhí)行
用戶代碼中,例如
OHOS_APP_RUN(Niobeu4HelloWorld);
定義全局函數(shù)指針變量OHOS_APP_FUNC_ENTRY
,并賦值。
其宏定義如下
#define OHOS_APP_RUN(func) void *OHOS_APP_FUNC_ENTRY = (func)
在如下
deviceboardopenvalleyniobeu4liteos_mtargetsrctarget_startup.c
ohos_app_main
調(diào)用OHOS_APP_FUNC_ENTRY
即調(diào)用Niobeu4HelloWorld
。
對(duì)應(yīng)打印如下
<--------------- OHOS Application Start Here --------------->
---
* [Openvalley/Niobeu4] *
* Hello world. *
---
-
開(kāi)鴻智谷
+關(guān)注
關(guān)注
2文章
125瀏覽量
1151 -
NiobeU4
+關(guān)注
關(guān)注
3文章
31瀏覽量
508
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
評(píng)論