【入门到实战】OpenHarmony南向子系统开发:热等级定制开发指南

往期鸿蒙5.0全套实战文章必看:(文中附带全栈鸿蒙5.0学习资料)


简介

OpenHarmony默认提供了热等级的特性。不同的硬件设备发热量和所能承受的最大温度都不相同,因此需要根据不同器件的温度,来定义系统的热等级标准,从而清晰的表明当前设备的发热状态,给热策略提供输入。但是器件在不同温度下对应的热等级在不同的产品上规格是不同的,产品希望根据产品的设计规格来定制此特性。OpenHarmony提供了热等级的定制方式,产品定制开发者可根据产品的设计规格来定制这些特性。

约束与限制

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

开发指导

搭建环境

设备要求:

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

环境要求:

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

开发步骤

本文以DAYU200为例介绍热等级的定制方法。

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

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

    profile
    ├── BUILD.gn
    ├── thermal_service_config.xml
    
  3. 参考默认热等级的配置文件夹中的thermal_service_config.xml编写定制的thermal_service_config.xml。包含热等级配置说明及定制后的热等级配置如下:

    表1 base配置说明

    配置项配置项描述配置项参数配置项参数描述参数类型参数取值范围
    tag=“history_temp_count”历史上报温度次数标签的名称value历史上报温度次数int>0
    tag=“temperature_query_enum”获取温度的设备列表的标签名称value要获取温度的设备列表enumsoc,battery,shell,cpu,charger,ambient,ap,pa

    表2 sensor_cluster配置说明

    配置项名称配置项描述数据类型取值范围
    name传感器集合名称string
    sensor集合内的传感器stringsoc,battery,shell,cpu,charger,ambient,ap,pa
    aux_sensor集合内的辅助传感器stringsoc,battery,shell,cpu,charger,ambient,ap,pa

    表3 item配置说明

    配置项名称配置项描述数据类型取值范围
    level各传感器集合下定义的热等级int>0
    threshold集合内每个传感器达到对应热等级的温度阈值(默认单位0.001摄氏度,开发者可定制)int根据产品定制
    threshold_clr集合内每个传感器回退到上一热等级的温度阈值int根据产品定制
    temp_rise_rate温度升高频率double根据产品定制
    <thermal version="0.01" product="lya">
    <base>
        <item tag="history_temp_count" value="10"/>
        <item tag="temperature_query_enum" value="soc,battery,shell,cpu,charger,ambient,ap,pa"/>
    </base>
    
    <level>
        <sensor_cluster name="base_safe" sensor="battery,charger,cpu,soc">
            <item level="1" threshold="42000,40000,30000,40000" threshold_clr="38000,36000,28000,38000"/>
            <item level="2" threshold="43000,41000,32000,42000" threshold_clr="41000,39000,30000,40000"/>
            <item level="3" threshold="46000,44000,34000,44000" threshold_clr="44000,42000,32000,42000"/>
            <item level="4" threshold="48000,46000,36000,46000" threshold_clr="46000,44000,34000,44000"/>
        </sensor_cluster>
    </level>
    
  4. 参考默认热等级配置文件夹中的BUILD.gn编写BUILD.gn文件,将thermal_service_config.xml打包到/vendor/etc/thermal_config目录下

    import("//build/ohos.gni")                      # 引用build/ohos.gni
    
    ohos_prebuilt_etc("thermal_service_config") {
        source = "thermal_service_config.xml"
        relative_install_dir = "thermal_config"
        install_images = [ chipset_base_dir ]       # 安装到vendor目录下的必要配置
        part_name = "product_rk3568"                # part_name暂定为product_rk3568,以实现后续编译,产品定制根据需要自行修改
    }
    
  5. 将编译目标添加到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_service_config", // 添加thermal_service_config的编译
                ]
            }
        },
        "subsystem": "product_hihope"
    }
    

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

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

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

调测验证

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

    hdc shell
    
  2. 进入data/service/el0/thermal/sensor/soc/路径:

    cd data/service/el0/thermal/sensor/soc
    
  3. 修改soc的温度:

    echo 42000 > temp
    
  4. 获取当前热等级信息:

    hidumper -s 3303 -a -l
    

    成功获取热等级信息如下:

    -------------------------------[ability]-------------------------------
    
    
    ----------------------------------ThermalService---------------------------------
    name: base_safe	level: 2
    name: cold_safe	level: 0
    name: high_safe	level: 0
    name: warm_5G	level: 0
    name: warm_safe	level: 1

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值