This post was last edited by sun63312 on 2021-6-9 23:42
HarmonyOS routine learning record
In the last tutorial, we have obtained the source code in two ways and compiled it in two ways. While continuing to follow the tutorial provided by Xiao Xiong to familiarize myself with HarmonyOS, Huawei also officially released HarmonyOS 2.0 on June 2. So the following is a simple record of the key points and some questions I think during the learning process:
1. Relative path where the routine is stored:
applications\BearPi\BearPi-HM_Nano\sample
2. HarmonyOS compilation tool is based on Ninja. Xiao Xiong said that Ninja pays more attention to compilation speed than Makefile used before. In my use, it is indeed compiled very quickly and it takes about 10 seconds to complete.
3. To compile different routines or add new routines, we need to operate two .gn files
One is to compile the business to build the gn file, in the corresponding routine folder:
The other is to compile the module to build the gn file, which is in the sample folder
A2_kernel_timer is a relative path pointing to the business gn file:
applications\BearPi\BearPi-HM_Nano\sample\A2_kernel_timer\BUILD.gn
timer_example is the target, pointing to applications\BearPi\BearPi-HM_Nano\sample\A2_kernel_timer\BUILD.gn
static_library("timer_example")
4. Also describe the compiled module path Json file (there are many Json files in the entire source code, Xiao Xiong focuses on explaining this)
File relative path: build\lite\product\BearPi-HM_Nano.json
Later, we add folders or modify them ourselves, and modify them under this json (I haven't tried it yet)
Taking applications as an example, the sample:app in it refers to the module compilation and construction gn file
5. In the .c file of the routine, the injection interface APP_FEATURE_INIT() is used to implement the function initialization of the routine.
6. The above is an introduction to how to simply run the routine, so the most important entry point of the code, main() function, is:
vendor\hisi\hi3861\hi3861\app\wifiiot_app\src\app_main.c下的app_main()
7. At the end of app_main(), we will call HOS_SystemInit(), which is the system initialization entry
Relative path: base\startup\services\bootstrap_lite\source\system_init.c
8. SYS_INIT(service); is used to initialize our routine and add the function in APP_FEATURE_INIT() we wrote. However, this initialization code is a bit confusing, I haven't understood it thoroughly, and there are two questions:
①The tutorial says that SYS_INIT() in the figure below is called. Why is the compiler-defined macro __ICCARM__ used?
②The tutorial suddenly said to use SYS_CALL(name,2), and I didn’t understand why 2 was used instead of others. What is the difference between the 5 SYS_CALLs?
summary:
I have started to get a preliminary understanding of HarmonyOS, and there are many things I still don’t understand. I will continue to update as I learn more.