Openharmony 添加内核驱动(L1)

系统 OpenHarmony
此文章以openharmony 3.1代码基础,介绍liteos-a ipcamera_hispark_taurus上添加khdf步骤。

​想了解更多内容,请访问:​

​51CTO和华为官方合作共建的鸿蒙技术社区​

​https://ost.51cto.com​

简介

此文章以openharmony 3.1代码基础

  • 介绍liteos-a ipcamera_hispark_taurus上添加khdf步骤。
  • 介绍驱动的简单调用(3516开发板:HiSpark_AI_Hi3516D_One_Light_VER.B开发板上测试。

驱动添加

驱动目录结构

驱动代码见附件。

驱动目录以外的文件配置

文件drivers\adapter\khdf\liteos\hdf_lite.mk。

# my sample test
ifeq ($(LOSCFG_DRIVERS_HDF_MY_SAMPLE_DRIVER), y)
LITEOS_BASELIB += -lmy_sample_driver
LIB_SUBDIRS += $(LITEOS_DRIVERS_HDF)/my_sample_driver
endif

文件drivers\adapter\khdf\liteos\Kconfig。

source "../../drivers/adapter/khdf/liteos/my_sample_driver/Kconfig"

文件drivers\adapter\khdf\liteos\BUILD.gn。

文件vendor\hisilicon\hispark_taurus\hdf_config\device_info\device_info.hcs。

  my_sample :: host {
hostName = "my_sample_host";
device_mysample :: device {
device0 :: deviceNode { // DeviceNode of the sample driver
policy = 2; // Driver service release policy. For details, see section Driver Service Management.
priority= 10; // Driver startup priority (0-200). A larger value indicates a lower priority. The default value 100 is recommended. If the priorities are the same, the device loading sequence is random.
preload = 0; // On-demand loading of the driver. For details, see "NOTE" at the end of this section.
permission = 0664; // Permission for the driver to create device nodes.
moduleName = "my_sample_driver"; // Driver name. The value of this field must be the same as the value of moduleName in the driver entry structure.
serviceName = "my_sample_service"; // Name of the service released by the driver. The name must be unique.
}
}
}

驱动编译配置

从代码根目录切换到kernel/liteos_a/。

cd kernel/liteos_a/

执行make menuconfig。

选择driver。

选择framework support。

选择my_sample driver。

按q,保存退出。

驱动调用可执行程序

目录结构

驱动调用代码。

驱动调用可执行程序详细代码见附件。

代码目录结构之外的文件配置

文件build\lite\components\myapp.json。

{
"components": [
{
"component": "myapp",
"description": "my app",
"optional": "false",
"dirs": [
"myapp"
],
"targets": [
"//myapp:myapp"
],
"rom": "",
"ram": "",
"output": [
],
"adapted_kernel": [
"liteos_a",
"liteos_m"
],
"features": [],
"deps": {
"third_party": [
"bounds_checking_function"
],
"components": []
}
}
]
}

文件vendor\hisilicon\hispark_taurus\config.json。

 {
"subsystem": "myapp",
"components": [
{ "component": "myapp", "features":[] }
]
}

编译

编译环境参考:​​3516应用调用到驱动实践​​。

执行下面2条命令。

hb set
.

执行hb build -f。

烧录测试

烧录步骤参考:​​3516应用调用到驱动实践​​。

切换到/bin目录下执行:./my_sample_driver_test。

结果如图:

​官网文档​

​想了解更多内容,请访问:​

​51CTO和华为官方合作共建的鸿蒙技术社区​

​https://ost.51cto.com​

责任编辑:jianghua 来源: 鸿蒙社区
相关推荐

2023-02-28 15:49:09

鸿蒙应用开发

2022-02-17 17:52:00

openharmon项目开发鸿蒙

2021-10-20 19:14:30

缓存CacheCPU

2012-10-09 10:57:57

光纤iODN宽带

2023-01-31 09:12:16

CPU芯片缓存

2023-10-10 15:33:55

机器学习相似性度量

2022-01-07 21:12:46

鸿蒙HarmonyOS应用

2022-08-26 14:58:43

区块链比特币架构

2022-01-06 16:16:21

鸿蒙HarmonyOS应用

2023-02-01 16:28:30

Linux内核鸿蒙

2023-04-10 09:44:22

内核鼠标调试鸿蒙

2023-11-08 15:51:00

AGI人工智能

2022-02-17 16:47:40

OpenharmonIPC通信鸿蒙

2022-04-01 15:18:04

HarmonyHDF 驱动鸿蒙

2022-03-21 15:42:36

智能家居物联网MQTT

2023-08-18 14:28:18

UART异步通信

2021-11-26 15:34:27

鸿蒙HarmonyOS应用

2022-06-22 09:14:23

事件打点HiSysEvent

2022-02-21 15:38:57

Openharmon操作系统鸿蒙

2022-04-21 11:26:31

鸿蒙操作系统
点赞
收藏

51CTO技术栈公众号