harmony 鸿蒙热日志定制开发指导

  • 2023-06-24
  • 浏览 (359)

热日志定制开发指导

概述

简介

OpenHarmony默认提供了热日志的特性。热日志是设备器件在使用过程中温度的流水日志。由于热日志输出的内容和路径在不同的产品上规格是不同的,产品希望根据产品的设计规格来定制此特性。OpenHarmony提供了热日志的定制方式,产品定制开发者可根据产品的设计规格来定制这些特性。

约束与限制

产品定制的配置路径,需要根据配置策略决定。本开发指导中的定制路径以/vendor进行举例,请开发者根据具体的产品配置策略,修改定制路径。

开发指导

搭建环境

设备要求:

标准系统开发板,如DAYU200/Hi3516DV300开源套件。

环境要求:

Linux调测环境,相关要求和配置可参考《快速入门》。

开发步骤

本文以DAYU200为例介绍热日志的定制方法。

  1. 在产品目录(/vendor/hihope/rk3568)下创建thermal文件夹。

  2. 参考默认热日志的配置文件夹创建目标文件夹,并安装到//vendor/hihope/rk3568/thermal,文件格式如下:

    profile
    ├── BUILD.gn
    ├── thermal_hdi_config.xml
    
  3. 参考默认热日志的参数配置文件夹创建目标文件夹,并安装到//vendor/hihope/rk3568/thermal,文件格式如下:

    etc
    ├── BUILD.gn
    ├── thermal.para
    ├── thermal.para.dac
    
  4. 参考默认热日志的配置文件夹中的thermal_hdi_config.xml编写定制的thermal_hdi_config.xml。包含热日志配置说明及定制后的热日志配置如下:

    表1 tracing配置说明

|配置项名称|配置项描述|数据类型|取值范围| |——–|——–|——–|——–| |outpath|温度跟踪日志输出的路径|string|无|

**表2** node配置说明

|节点名称|配置项名称|配置项描述| |——–|——–|——–| |title|path|获取thermal zone名称的路径| |title|name|thermal zone名称| |value|path|获取thermal zone温度的路径|

```shell
<tracing outpath="/data/log/thermal-log">
    <node>
        <title path="sys/class/thermal/thermal_zone0/type"/>
        <value path="sys/class/thermal/thermal_zone0/temp"/>
    </node>
    <node>
        <title name="gpu-thermal"/>   
        <value path="sys/class/thermal/thermal_zone1/temp"/>
    </node>
</tracing>
```
  1. 参考默认热日志的参数配置文件夹中的thermal.parathermal.para.dac编写定制的thermal.para和thermal.para.dac。包含定制后的配置如下:

    thermal.para:

    persist.thermal.log.enable=true     # 打开thermal log
    persist.thermal.log.interval=5000   # 温度跟踪日志的时间间隔,单位为毫秒
    persist.thermal.log.width=20        # 温度跟踪日志的宽度,单位为字符
    

    thermal.para.dac:

    persist.thermal.log.="power_host:power_host:500" # 控制访问权限
    
  2. 参考默认热日志配置文件夹中的BUILD.gn编写BUILD.gn文件,将thermal_hdi_config.xml打包到//vendor/etc/thermal_config/hdf目录下:

    import("//build/ohos.gni")
    
    
    ohos_prebuilt_etc("thermal_hdf_config") {
        source = "thermal_hdi_config.xml"
        relative_install_dir = "thermal_config/hdf"
        install_images = [ chipset_base_dir ]       # 安装到vendor目录下的必要配置
        part_name = "product_rk3568"                # part_name暂定为product_rk3568,以实现后续编译,产品定制根据需要自行修改
    }
    
  3. 参考默认热日志的参数配置文件夹的BUILD.gn编写BUILD.gn文件,将thermal.para和thermal.para.dac打包到//vendor/etc/param/thermal.para目录下

    import("//build/ohos.gni")
    
    ## Install thermal.para to /vendor/etc/param/thermal.para
    
    
    ohos_prebuilt_etc("thermal.para") {
        source = "thermal.para"
        relative_install_dir = "param"
        install_images = [ chipset_base_dir ]
        part_name = "product_rk3568"
    }
    
    
    ohos_prebuilt_etc("thermal.para.dac") {
        source = "thermal.para.dac"
        relative_install_dir = "param"
        install_images = [ chipset_base_dir ]
        part_name = "product_rk3568"
    }
    
    
    group("param_files") {
        deps = [
            ":thermal.para",
            ":thermal.para.dac",
        ]
    }
    
  4. 将编译目标添加到ohos.build的”module_list”中,例如:

    {
        "parts": {
            "product_rk3568": {
                "module_list": [
                    "//vendor/hihope/rk3568/default_app_config:default_app_config",
                    "//vendor/hihope/rk3568/image_conf:custom_image_conf",
                    "//vendor/hihope/rk3568/preinstall-config:preinstall-config",
                    "//vendor/hihope/rk3568/resourceschedule:resourceschedule",
                    "//vendor/hihope/rk3568/etc:product_etc_conf",
                    "//vendor/hihope/rk3568/thermal/profile:thermal_hdf_config",  // 添加thermal_hdf_config的编译
                    "//vendor/hihope/rk3568/thermal/etc:param_files"              // 添加thermal.para和thermal.para.dac的编译
                ]
            }
        },
        "subsystem": "product_hihope"
    }
    

    “//vendor/hihope/rk3568/thermal/”为文件夹路径,“profile”、“etc”为创建的文件夹名字,“thermal_hdf_config”、“param_files”为编译目标。

  5. 参考《快速入门》编译定制版本,编译命令如下:

    ./build.sh --product-name rk3568 --ccache
    
  6. 将定制版本烧录到DAYU200开发板中。

调测验证

  1. 开机后,进入shell命令行:

    hdc shell
    
  2. 进入定制后的目录。

    cd /data/log/thermal/
    

    查看热日志。

    cat thermal.000.20170805-175756
    

    成功获取热日志内容

    timestamp                    soc-thermal         gpu-thermal
    2017-08-05 17:57:56          37777               37222
    2017-08-05 17:58:01          38333               37777
    2017-08-05 17:58:06          36666               37222
    2017-08-05 17:58:11          36666               37222
    2017-08-05 17:58:16          36666               37222
    2017-08-05 17:58:21          36111               37222
    2017-08-05 17:58:26          36111               37222
    2017-08-05 17:58:31          36666               37222
    2017-08-05 17:58:36          36111               37222
    2017-08-05 17:58:41          36111               37222
    2017-08-05 17:58:46          36666               36666
    

参考

开发过程中可参考的配置文件路径:默认热日志的配置源码路径默认热日志的参数配置源码路径

打包路径:/vendor/etc/thermal_config/hdf

你可能感兴趣的鸿蒙文章

harmony 鸿蒙子系统开发

harmony 鸿蒙AI框架开发指导

harmony 鸿蒙NNRt接入适配指导

harmony 鸿蒙应用特权配置指南

harmony 鸿蒙开发实例

harmony 鸿蒙搭建环境

harmony 鸿蒙开发指导

harmony 鸿蒙概述

harmony 鸿蒙ArkCompiler开发指导

harmony 鸿蒙窗口标题栏定制开发指导

0  赞