1# Thermal Detection Customization 2 3## Overview 4 5### Introduction 6 7By default, OpenHarmony provides the thermal detection feature. A component, for example, the CPU or battery, generates heat while it is running. In this case, the component reports its temperature in real time through the corresponding temperature sensor. The thermal detection feature detects the temperature of components in real time and provides temperature input for the thermal management module. However, thermal detection on components varies according to product specifications. To address this issue, OpenHarmony provides the thermal detection customization function. 8 9### Constraints 10 11The configuration path for battery level customization is subject to the [configuration policy](https://gitee.com/openharmony/customization_config_policy). In this development guide, `/vendor` is used as an example of the configuration path. During actual development, you need to modify the customization path based on the product configuration policy. 12 13## How to Develop 14 15### Setting Up the Environment 16 17**Hardware requirements:** 18 19Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite. 20 21**Environment requirements:** 22 23For details about the requirements on the Linux environment, see [Quick Start](../quick-start/quickstart-overview.md). 24 25### Getting Started with Development 26 27The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate thermal detection customization. 28 291. Create the `thermal` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568). 30 312. Create a target folder by referring to the [default thermal detection configuration folder](https://gitee.com/openharmony/drivers_peripheral/tree/master/thermal/interfaces/hdi_service/profile), and install it in `//vendor/hihope/rk3568/thermal`. The content is as follows: 32 33 ```text 34 profile 35 ├── BUILD.gn 36 ├── thermal_hdi_config.xml 37 ``` 38 393. Write the custom `thermal_hdi_config.xml` file by referring to the [thermal_hdi_config.xml](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/interfaces/hdi_service/profile/thermal_hdi_config.xml) file in the default thermal detection configuration folder. The following table describes the related configuration items. 40 41 **Table 1** Configuration items for thermal detection 42 43 |Node| Configuration Item| Description| Value Type| 44 | -------- | -------- | -------- | -------- | 45 | item | tag | Temperature flag name of an actual or simulated node.| string | 46 | item | value | Temperature flag value. Value **1** means to obtain the temperature of a simulated node, and the value **0**, means to obtain the temperature of an actual node.| int | 47 | group | name | Name of the actual or simulated node group.| string | 48 | group | interval | Polling interval, in ms (default).| int | 49 | thermal_zone | type | Thermal zone name.| string | 50 | thermal_zone | path | Path for obtaining the thermal zone temperature of an actual node.| string | 51 | thermal_node | type | Thermal node name.| string | 52 | thermal_node | path | Path for obtaining the thermal node temperature of a simulated node.| string | 53 54 ```shell 55 <base> 56 <item tag="sim_tz" value="0"/> 57 </base> 58 59 <polling> 60 <group name="actual" interval="30000"> 61 <thermal_zone type="soc-thermal" path="sys/class/thermal/thermal_zone0/temp"/> 62 <thermal_zone type="gpu-thermal" path="sys/class/thermal/thermal_zone0/temp"/> 63 </group> 64 <group name="sim" interval="30000"> 65 <thermal_node type="soc" path="data/service/el0/thermal/sensor/soc/temp"/> 66 <thermal_node type="cpu" path="data/service/el0/thermal/sensor/cpu/temp"/> 67 <thermal_node type="ap" path="data/service/el0/thermal/sensor/ap/temp"/> 68 <thermal_node type="pa" path="data/service/el0/thermal/sensor/pa/temp"/> 69 <thermal_node type="ambient" path="data/service/el0/thermal/sensor/ambient/temp"/> 70 <thermal_node type="charger" path="data/service/el0/thermal/sensor/charger/temp"/> 71 <thermal_node type="battery" path="data/service/el0/thermal/sensor/battery/temp"/> 72 <thermal_node type="shell" path="data/service/el0/thermal/sensor/shell/temp"/> 73 </group> 74 </polling> 75 ``` 76 For details about the path for obtaining the actual node temperature, see the path for obtaining the thermal zone temperature in [Thermal Log](../subsystems/subsys-thermal_log.md). For details about the path for obtaining the simulated node temperature, see [Default Thermal Detection Configuration](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/interfaces/hdi_service/profile/thermal_hdi_config.xml). 77 785. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/interfaces/hdi_service/profile/BUILD.gn) file in the default thermal detection configuration folder to pack the `thermal_hdi_config.xml` file to the `//vendor/etc/thermal_config/hdf` directory. The configuration is as follows: 79 80 ```shell 81 import("//build/ohos.gni") 82 83 ohos_prebuilt_etc("thermal_hdf_config") { 84 source = "thermal_hdi_config.xml" 85 relative_install_dir = "thermal_config/hdf" 86 install_images = [ chipset_base_dir ] # Required configuration for installing the thermal_hdi_config.xml file in the vendor directory. 87 part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. You can change it as required. 88 } 89 ``` 90 916. Add the build target to `module_list` in [ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build) in the `/vendor/hihope/rk3568` directory. For example: 92 93 ```json 94 { 95 "parts": { 96 "product_rk3568": { 97 "module_list": [ 98 "//vendor/hihope/rk3568/default_app_config:default_app_config", 99 "//vendor/hihope/rk3568/image_conf:custom_image_conf", 100 "//vendor/hihope/rk3568/preinstall-config:preinstall-config", 101 "//vendor/hihope/rk3568/resourceschedule:resourceschedule", 102 "//vendor/hihope/rk3568/etc:product_etc_conf", 103 "//vendor/hihope/rk3568/thermal/profile:thermal_hdf_config", // Add the configuration for building of thermal_hdf_config. 104 ] 105 } 106 }, 107 "subsystem": "product_hihope" 108 } 109 ``` 110 In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` is the folder name, and `thermal_hdf_config` is the build target. 111 1127. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). 113 114 ```shell 115 ./build.sh --product-name rk3568 --ccache 116 ``` 117 1188. Burn the customized version to the DAYU200 development board. 119 120### Debugging and Verification 121 1221. After startup, run the following command to launch the shell command line: 123 ```shell 124 hdc shell 125 ``` 126 1272. Obtain the thermal detection result of the thermal zone. 128 ```shell 129 hidumper -s 3303 -a -t 130 ``` 131 132 The following is the reference thermal detection result of the thermal zone. The value of **Temperature** is in unit of 0.001°C by default. 133 ```shell 134 -------------------------------[ability]------------------------------- 135 136 137 ----------------------------------ThermalService--------------------------------- 138 ········· (Only the thermal detection result is displayed here. Other information is omitted.) 139 Type: gpu-thermal 140 Temperature: 35555 141 Type: soc-thermal 142 Temperature: 35000 143 ······ 144 ``` 145 146## Reference 147During development, you can refer to the [default thermal detection configuration](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/interfaces/hdi_service/profile/thermal_hdi_config.xml). 148 149Packing path: `/vendor/etc/thermal_config/hdf` 150