自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

鴻蒙的驅(qū)動(dòng)子系統(tǒng)-3-驅(qū)動(dòng)相關(guān)模塊的編譯

系統(tǒng)
本篇帶給大家驅(qū)動(dòng)子系統(tǒng)的編譯相關(guān)內(nèi)容,互相交叉,關(guān)系稍微有點(diǎn)復(fù)雜,我花了一點(diǎn)時(shí)間做了梳理,先把一些要點(diǎn)做一下總結(jié)。

[[418094]]

想了解更多內(nèi)容,請?jiān)L問:

51CTO和華為官方合作共建的鴻蒙技術(shù)社區(qū)

https://harmonyos.51cto.com

打開并查看 //vendor/hisilicon/hispark_taurus/config.json, 這是小型系統(tǒng)Hi3516開發(fā)板的產(chǎn)品配置表,仔細(xì)查看與驅(qū)動(dòng)緊密相關(guān)的子系統(tǒng)和組件有:

  1.        "subsystem""kernel"
  2.        "components": [ 
  3.          { "component""liteos_a""features":[] } 
  4.        ] 
  5.      }, 
  6.  
  7.      { 
  8.        "subsystem""drivers"
  9.        "components": [ 
  10.          { "component""drivers_framework""features":[] }, 
  11.          { "component""adapter_uhdf""features":[] }, 
  12.          { "component""peripheral_display""features":[] }, 
  13.          { "component""peripheral_input""features":[] }, 
  14.          { "component""peripheral_sensor""features":[] }, 
  15.          { "component""peripheral_wlan""features":[] } 
  16.        ] 
  17.      }, 
  18.  
  19.      { 
  20.        "subsystem""vendor"
  21.        "components": [ 
  22.          { "component""hi3516dv300_init""features":[] }, 
  23.          { "component""hardware""features":[] }, 
  24.          { "component""middleware""features":[] } 
  25.        ] 
  26.      }, 

結(jié)合//build/lite/components/目錄下對應(yīng)的 json文件,列出下表:

鴻蒙的驅(qū)動(dòng)子系統(tǒng)-3-驅(qū)動(dòng)相關(guān)模塊的編譯-鴻蒙HarmonyOS技術(shù)社區(qū)

上表包含了整個(gè)驅(qū)動(dòng)子系統(tǒng)的編譯相關(guān)內(nèi)容,互相交叉,關(guān)系稍微有點(diǎn)復(fù)雜,我花了一點(diǎn)時(shí)間做了梳理,先把一些要點(diǎn)做一下總結(jié):

1. //drivers/framework/ 目錄是純代碼目錄,不包含編譯配置腳本文件,對該目錄代碼文件的編譯配置文件都在 //drivers/adapter/目錄下了,分成兩部分:

  • uhdf 部分是編譯framework部署在用戶空間的代碼,見上表中adapter_uhdf部分。
  • khdf 部分是編譯framework部署在內(nèi)核空間的代碼,上表中沒有體現(xiàn)出來,但是在編譯 liteos_a:kernel 的時(shí)候,會(huì)通過kernel模塊的mk去include這里的 ./khdf/liteos/目錄下的mk,從而觸發(fā)khdf部分的編譯。

2. liteos_a:kernel 和framework的khdf部分的編譯,會(huì)由 hi3516dv300_init 組件的編譯來觸發(fā),最終生成了OHOS_Image*四個(gè)鏡像文件。上表只做了簡單地描述,可以去閱讀和分析//device/hisilicon/build/hi3516dv300/ 目錄下的幾個(gè)編譯腳本,順著編譯流程去做理解,下文會(huì)做進(jìn)一步地展開分析。

3. //drivers/peripheral/ 目錄下的幾個(gè)模塊,會(huì)被編譯成對應(yīng)的動(dòng)態(tài)鏈接庫文件,部署到 rootfs/usr/lib/目錄下。

4. hardware和middleware兩個(gè)組件,都是根據(jù)各自目錄下的 BUILD.gn和build.sh腳本,對相關(guān)目錄的代碼進(jìn)行編譯,或者對子目錄下的預(yù)編譯庫文件做選擇,最終將庫文件拷貝到項(xiàng)目輸出根目錄下,打包生成rootfs時(shí),部署到rootfs/usr/lib/目錄下

上面1.uhdf和3/4的編譯輸出,都部署在鴻蒙系統(tǒng)的用戶空間,直接閱讀編譯腳本基本上就可以理解了,本文就不做詳細(xì)分析了。

而1.khdf和2的編譯有密切的相關(guān)性,其輸出一并打包到OHOS系統(tǒng)鏡像中,下面就來詳細(xì)看一下。

從 hi3516dv300_init 組件的編譯腳本 //device/hisilicon/build/hi3516dv300/BUILD.gn 入手:

  1. build_ext_component("hi3516dv300_image") { 
  2.   exec_path = rebase_path(".", root_build_dir) 
  3.   outdir = rebase_path("$root_out_dir"
  4.   command = "./build.sh ${outdir} ${device_path} ${board} ${ohos_kernel_type} ${ohos_build_compiler}" 
  5.   deps = [ "//kernel/liteos_a:kernel" ] 

依賴liteos_a:kernel組件,執(zhí)行這里的build.sh,根據(jù)參數(shù),拷貝一組.so文件后,執(zhí)行make。查看Makefile和hi3516dv300.mak,可以知道這是要編譯 sdk_init和system_init 并打包生成 OHOS_Image 鏡像。

編譯liteos_a:kernel組件,入口則在 //kernel/liteos_a/BUILD.gn,

  1. build_ext_component("make") { 
  2.   exec_path = rebase_path(".", root_build_dir) 
  3.   tee_enable = "false" 
  4.   if (board_name == "hi3516dv300" && enable_tee_ree) { 
  5.     tee_enable = "tee" 
  6.   } 
  7.   prebuilts = "sh build.sh ${board_name} ${ohos_build_compiler} ${root_build_dir} ${ohos_build_type} ${tee_enable} \"${device_company}\" \"${product_path}\"" 
  8.   outdir = rebase_path(get_path_info(".""out_dir")) 
  9.   command = "make clean OUTDIR=$outdir && make rootfs VERSION=\"${ohos_version}\" -j 16 OUTDIR=$outdir" 

根據(jù)build的參數(shù),到 //kernel/liteos_a/tools/build/config/ 目錄下尋找一個(gè)匹配的config文件,拷貝到 //kernel/liteos_a/.config,但這還不是.config的全部,執(zhí)行make時(shí),根據(jù)Kconfig的配置,層層將編譯內(nèi)核的默認(rèn)配置收集匯總到.config文件內(nèi),driver部分就包含了:

  1. ######################## config options os drivers ######################## 
  2. menu "Driver" 
  3. config DRIVERS 
  4.     bool "Enable Driver" 
  5.     default y 
  6.     help 
  7.       Answer Y to enable LiteOS support driver. 
  8.  
  9. source "../../kernel/liteos_a/bsd/dev/usb/Kconfig" 
  10. source "../../drivers/adapter/khdf/liteos/Kconfig" 

 這就把 //drivers/adapter/khdf/ 模塊的編譯配置包含進(jìn)來了,并且由這個(gè)Kconfig關(guān)聯(lián)驅(qū)動(dòng)模塊的其他Kconfig:

  1. source "../../drivers/adapter/khdf/liteos/model/bus/usb/Kconfig" 
  2. source "../../drivers/adapter/khdf/liteos/test/Kconfig" 
  3. source "../../drivers/adapter/khdf/liteos/model/display/Kconfig" 
  4. source "../../drivers/adapter/khdf/liteos/model/input/Kconfig" 
  5. source "../../drivers/adapter/khdf/liteos/model/sensor/Kconfig" 
  6.  
  7. source "../../device/hisilicon/drivers/Kconfig" 

經(jīng)過這一步,編譯內(nèi)核的所有配置項(xiàng)都集中到了.config文件中。

再看 //kernel/liteos_a/config.mk:

  1. -include $(LITEOSTOPDIR)/tools/build/mk/los_config.mk 

打開這個(gè) los_config.mk,找到driver部分:

  1. ################################## Driver Option Begin ################################# 
  2. ifeq ($(LOSCFG_DRIVERS_HDF), y) 
  3. include $(LITEOSTOPDIR)/../../drivers/adapter/khdf/liteos/hdf_lite.mk 
  4. endif 

【*】再打開這個(gè)hdf_lite.mk,找到下面這段:

  1. HAVE_VENDOR_CONFIG := $(shell if [ -d $(LITEOS_SOURCE_ROOT)/vendor/$(patsubst "%",%,$(LOSCFG_DEVICE_COMPANY))/$(patsubst "%",%,$(LOSCFG_PRODUCT_NAME))/config ]; then echo y; else echo n; fi) 
  2. ifeq ($(LOSCFG_DRIVERS_HDF_TEST), y) 
  3. include $(LITEOS_DRIVERS_HDF)/test/test_lite.mk 
  4. # test 
  5.     LITEOS_BASELIB += -lhdf_test 
  6.     LIB_SUBDIRS    += $(LITEOS_DRIVERS_HDF)/test 
  7.  
  8.                                    #//drivers/adapter/khdf/liteos/test,通過Makefile可以編譯驅(qū)動(dòng)子系統(tǒng)的測試文件 
  9.  
  10.     LITEOS_BASELIB += -lhdf_test_config 
  11.     LIB_SUBDIRS += $(LITEOS_SOURCE_ROOT)/vendor/$(LOSCFG_DEVICE_COMPANY)/$(LOSCFG_PRODUCT_NAME)/config/hdf_test 
  12.  
  13.                                 #//vendor/hisilicon/hispark_taurus/config/hdf_test 
  14.  
  15.     #這里并不顯式地去編譯hdf_config,即顯式地執(zhí)行Makefile, 
  16.     #而是通過hdf_test/hdf_test.hcs 里面的 #include "../hdf.hcs" 去將其編譯到 
  17.     # ./out/hispark_taurus/ipcamera_hispark_taurus/obj/kernel/liteos_a/lib/libhdf_test_config.a 里面去 
  18. else 
  19. # config 
  20.     LITEOS_BASELIB += -lhdf_config 
  21. ifeq ($(HAVE_VENDOR_CONFIG), y) 
  22.     LIB_SUBDIRS += $(LITEOS_SOURCE_ROOT)/vendor/$(LOSCFG_DEVICE_COMPANY)/$(LOSCFG_PRODUCT_NAME)/config 
  23.  
  24.     #要是上面LOSCFG_DRIVERS_HDF_TEST是 n,不編譯hdf_test/,這里才會(huì)顯式地編譯 hdf_config,執(zhí)行這個(gè)目錄下的Makefile指令, 
  25.  
  26.     # ./out/hispark_taurus/ipcamera_hispark_taurus/obj/kernel/liteos_a/lib/libhdf_config.a 里面去 
  27. else 
  28.     LIB_SUBDIRS += $(LITEOS_SOURCE_ROOT)/device/$(LOSCFG_DEVICE_COMPANY)/$(LOSCFG_PRODUCT_NAME)/config 
  29. endif 
  30. endif 

通過參數(shù)對路徑下的config進(jìn)行確認(rèn),HAVE_VENDOR_CONFIG 是存在的,也就是y,上面的.config中,LOSCFG_DRIVERS_HDF_TEST也是默認(rèn)配置為y的,會(huì)跑# test這個(gè),而不是# config。

LIB_SUBDIRS += //vendor/hisilicon/hispark_taurus/config/hdf_test

而不是 //device/hisilicon/hispark_taurus/sdk_liteos/config 下的 config 目錄。

【**】進(jìn)入//vendor/hisilicon/hispark_taurus/config/hdf_test/目錄查看 Makefile 文件:

  1. include $(LITEOSTOPDIR)/../../drivers/adapter/khdf/liteos/lite.mk 
  2.  
  3. MODULE_NAME := hdf_test_config 
  4. LOCAL_HCS_ROOT := $(shell pwd) 
  5.  
  6. LOCAL_PLATFORM_HCS_SRC := hdf_test.hcs 
  7.  
  8. include $(HDF_DRIVER) 

再去打開這個(gè)lite.mk,最后面有一句:

  1. HDF_DRIVER = $(HDF_ROOT_DIR)/adapter/khdf/liteos/hdf_driver.mk 

再打開這個(gè)hdf_driver.mk

  1. HAVE_VENDOR_CONFIG := $(shell if [ -d $(LITEOS_SOURCE_ROOT)/vendor/$(patsubst "%",%,$(LOSCFG_DEVICE_COMPANY))/$(patsubst "%",%,$(LOSCFG_PRODUCT_NAME))/config ]; then echo y; else echo n; fi) 
  2.  
  3. ifeq ($(LOCAL_HCS_ROOT),) 
  4. ifeq ($(HAVE_VENDOR_CONFIG), y) 
  5. LOCAL_HCS_ROOT := $(abspath $(LITEOSTOPDIR)/../../vendor/$(patsubst "%",%,$(LOSCFG_DEVICE_COMPANY))/$(patsubst "%",%,$(LOSCFG_PRODUCT_NAME))/config) 
  6. else 
  7. LOCAL_HCS_ROOT := $(abspath $(LITEOSTOPDIR)/../../device/$(patsubst "%",%,$(LOSCFG_DEVICE_COMPANY))/$(patsubst "%",%,$(LOSCFG_PRODUCT_NAME))/config) 
  8. endif 
  9. endif 

所以LOCAL_HCS_ROOT是vendor的://vendor/hisilicon/hispark_taurus/config

而不是device目錄下的 //device/hisilicon/hispark_taurus/sdk_liteos/config

回到上面【**】 //vendor/hisilicon/hispark_taurus/config/hdf_test/Makefile 文件,要編譯 hdf_test.hcs,打開該文件:

  1. #include "../hdf.hcs" 
  2. #include "hdf_test_manager/device_info.hcs" 
  3. #include "gpio_test_config.hcs" 
  4. #include "i2c_test_config.hcs" 
  5. #include "spi_test_config.hcs" 
  6. #include "uart_test_config.hcs" 
  7. #include "hdf_config_test.hcs" 
  8. #include "sdio_test_config.hcs" 
  9. #include "emmc_test_config.hcs" 
  10. #include "pwm_test_config.hcs" 

也就是編譯hdf_test目錄下的 測試相關(guān)的 hcs 之外,還編譯上一級(jí)目錄的 hdf.hcs,再打開這個(gè) hdf.hcs 文件:

  1. #include "../../../../device/hisilicon/hispark_taurus/sdk_liteos/config/i2c/i2c_config.hcs" 
  2. #include "../../../../device/hisilicon/hispark_taurus/sdk_liteos/config/gpio/gpio_config.hcs" 
  3. #include "../../../../device/hisilicon/hispark_taurus/sdk_liteos/config/uart/uart_config.hcs" 
  4. #include "../../../../device/hisilicon/hispark_taurus/sdk_liteos/config/sdio/sdio_config.hcs" 
  5. #include "../../../../device/hisilicon/hispark_taurus/sdk_liteos/config/emmc/emmc_config.hcs" 
  6. #include "../../../../device/hisilicon/hispark_taurus/sdk_liteos/config/watchdog/watchdog_config.hcs" 
  7. #include "../../../../device/hisilicon/hispark_taurus/sdk_liteos/config/usb/usb_config.hcs" 
  8. #include "../../../../device/hisilicon/hispark_taurus/sdk_liteos/config/rtc/rtc_config.hcs" 
  9. #include "../../../../device/hisilicon/hispark_taurus/sdk_liteos/config/spi/spi_config.hcs" 
  10. #include "../../../../device/hisilicon/hispark_taurus/sdk_liteos/config/pwm/pwm_config.hcs" 
  11. #include "../../../../device/hisilicon/hispark_taurus/sdk_liteos/config/dmac/dmac_config.hcs" 
  12.  
  13.   
  14.  
  15. #include "device_info/device_info.hcs" 
  16. #include "wifi/wlan_platform.hcs" 
  17. #include "wifi/wlan_chip_hi3881.hcs" 
  18. #include "lcd/lcd_config.hcs" 
  19. #include "input/input_config.hcs" 
  20. #include "sensor/sensor_config.hcs" 
  21.  
  22.  
  23. #include "../../../../vendor/huawei/hdf/sample/config/uart/uart_config.hcs" 
  24. #include "../../../../vendor/huawei/hdf/sample/config/device_info/device_info.hcs" 

從這里可以看出,//device/hisilicon/hispark_taurus/sdk_liteos/config 目錄下的 hcs 文件,除了device_info、input、lcd、wifi四個(gè)模塊并不參與編譯之外,大部分都會(huì)得到編譯,而這四個(gè)模塊在vendor目錄下都有對應(yīng)的 hcs 來替代。實(shí)際上對比一下device和vendor目錄下的這四個(gè)模塊,差別不大。

最后面的兩句include hdf/sample 的hcs,就是前文《小型系統(tǒng)驅(qū)動(dòng)示例程序的編譯和驗(yàn)證》中添加進(jìn)來的,編譯示例程序的hcs文件。

全工程搜索文件 hdf.hcs 和 device_info.hcs:

  1. ohos@ubuntu:~/Ohos/B_LTS$ find ./ -name hdf.hcs 
  2. ./device/hisilicon/hispark_aries/sdk_liteos/config/hdf.hcs 
  3. ./device/hisilicon/hispark_taurus/sdk_liteos/config/hdf.hcs 【不編譯】 
  4. ./device/qemu/arm_virt/config/hdf.hcs 
  5. ./vendor/hisilicon/hispark_aries/config/hdf.hcs 
  6. ./vendor/hisilicon/hispark_taurus/config/hdf.hcs 【編譯,hdf_test.hcs -->> hdf.hcs】 
  7. ohos@ubuntu:~/Ohos/B_LTS$find ./ -name device_info.hcs 
  8. ./device/hisilicon/hispark_aries/sdk_liteos/config/device_info/device_info.hcs 
  9. ./device/hisilicon/hispark_taurus/sdk_liteos/config/device_info/device_info.hcs【不編譯】 
  10. ./device/qemu/arm_virt/config/device_info/device_info.hcs 
  11. ./vendor/huawei/hdf/sample/config/device_info/device_info.hcs【編譯,device_info.hcs -->> sample/.../device_info.hcs】 
  12. ./vendor/hisilicon/hispark_aries/config/device_info/device_info.hcs 
  13. ./vendor/hisilicon/hispark_aries/config/hdf_test/hdf_test_manager/device_info.hcs 
  14. ./vendor/hisilicon/hispark_taurus/config/device_info/device_info.hcs 【編譯,hdf.hcs -->> device_info.hcs】 
  15. ./vendor/hisilicon/hispark_taurus/config/hdf_test/hdf_test_manager/device_info.hcs 【編譯,hdf_test.hcs -->> hdf_test_manager/device_info.hcs】 

把無關(guān)的先去除,剩下的就是就是上面幾個(gè)了。

上面就是對驅(qū)動(dòng)子系統(tǒng)的驅(qū)動(dòng)配置和設(shè)備樹描述文件(.hcs)的編譯關(guān)系的梳理,上面【*】提到的 hdf_driver.mk 的作用,就是配置編譯工具,將 *.hcs 配置文件編譯成 *_hex.c,再編譯成 *.o和 *.hcb 文件,存放在:項(xiàng)目輸出根目錄下的/obj/kernel/liteos_a/obj/vendor/hisilicon/hispark_taurus/config/hdf_test_config/config/目錄下。

至于驅(qū)動(dòng)子系統(tǒng)部署在內(nèi)核空間部分代碼的編譯,則需要到 //drivers/adapter/khdf/liteos/Makefile 來查看:

  1. include $(LITEOSTOPDIR)/config.mk          #//kernel/liteos_a/config.mk  
  2. include ./lite.mk                                          #HDF_DRIVER = $(HDF_ROOT_DIR)/adapter/khdf/liteos/hdf_driver.mk  上面有展開 
  3.  
  4. MODULE_NAME := hdf 
  5.  
  6. HDF_FRAMEWORKS = ../../../framework 

根據(jù)source,編譯出libhdf.a靜態(tài)鏈接庫文件到 //out/.../obj/kernel/liteos_a/lib/libhdf.a,生成OHOS_Image鏡像時(shí)將其鏈接進(jìn)去。

而//device/hisilicon/drivers/lite.mk 則描述了具體的驅(qū)動(dòng)模塊代碼編譯成對應(yīng)的靜態(tài)庫文件,文件末尾的:

  1. LITEOS_BASELIB += -lhdf_uart_sample 
  2. LIB_SUBDIRS    += $(LITEOSTOPDIR)/../../vendor/huawei/hdf/sample/platform/uart 

就是前文《小型系統(tǒng)驅(qū)動(dòng)示例程序的編譯和驗(yàn)證》添加上去的,讓例子程序的內(nèi)核部分參與編譯,生成靜態(tài)庫文件,生成OHOS_Image鏡像時(shí)將其鏈接進(jìn)去。

想了解更多內(nèi)容,請?jiān)L問:

51CTO和華為官方合作共建的鴻蒙技術(shù)社區(qū)

https://harmonyos.51cto.com

 

責(zé)任編輯:jianghua 來源: 鴻蒙社區(qū)
相關(guān)推薦

2021-09-02 15:27:54

鴻蒙HarmonyOS應(yīng)用

2021-08-03 15:10:26

Linux代碼驅(qū)動(dòng)

2021-08-10 11:30:30

Linux代碼中斷控制器

2021-08-31 11:53:38

Linux inputLinux 系統(tǒng)

2021-12-15 10:02:25

鴻蒙HarmonyOS應(yīng)用

2023-03-09 15:15:21

鴻蒙模塊編譯

2015-10-19 17:36:19

MOST內(nèi)核Linux

2009-12-17 09:56:26

Linux添加驅(qū)動(dòng)模塊

2011-04-11 13:26:25

Linux驅(qū)動(dòng)

2022-06-14 07:22:53

MakefileConfigKconfig

2010-03-19 11:04:20

python模塊

2011-06-14 13:59:09

Qt Qt 4.7.3 MYsql

2011-07-05 09:25:05

Qt MySQL 驅(qū)動(dòng)

2009-07-15 15:30:12

MyEclipse J

2021-04-06 11:18:47

LinuxWWAN子系統(tǒng)驅(qū)動(dòng)

2023-07-03 19:40:21

系統(tǒng)設(shè)計(jì)模式

2021-03-11 12:23:13

Linux驅(qū)動(dòng)開發(fā)

2015-03-12 16:49:44

融合架構(gòu)戴爾云計(jì)算

2015-09-22 13:48:12

數(shù)據(jù)迷思

2019-07-15 08:30:06

Linux 系統(tǒng) 數(shù)據(jù)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)