1e41f4b71Sopenharmony_ci# Thermal Level Customization 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci## Overview 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci### Introduction 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciBy default, OpenHarmony provides the thermal level feature. Different hardware devices generate different amounts of heat and can tolerate different maximum temperatures. Therefore, for different components, the thermal level standard needs to be defined based on their temperatures to clearly indicate the thermal status and provide input for thermal control. However, the thermal level of components at different temperatures varies according to product specifications. To address this issue, OpenHarmony provides the thermal level customization function. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci### Constraints 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ciThe 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. 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci## How to Develop 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci### Setting Up the Environment 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci**Hardware requirements:** 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ciDevelopment board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite. 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci**Environment requirements:** 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ciFor details about the requirements on the Linux environment, see [Quick Start](../quick-start/quickstart-overview.md). 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci### Getting Started with Development 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ciThe following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate thermal level customization. 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci1. Create the `thermal` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568). 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci2. Create a target folder by referring to the [default thermal level configuration folder](https://gitee.com/openharmony/powermgr_thermal_manager/tree/master/services/native/profile), and install it in `//vendor/hihope/rk3568/thermal`. The content is as follows: 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci ```text 34e41f4b71Sopenharmony_ci profile 35e41f4b71Sopenharmony_ci ├── BUILD.gn 36e41f4b71Sopenharmony_ci ├── thermal_service_config.xml 37e41f4b71Sopenharmony_ci ``` 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci3. Write the custom `thermal_service_config.xml` file by referring to the [thermal_service_config.xml](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/thermal_service_config.xml) file in the default thermal level configuration folder. The following tables describe the related configuration items. 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci **Table 1** Description of the base configuration 42e41f4b71Sopenharmony_ci | Configuration Item| Description| Parameter| Parameter Description| Type| Value Range| 43e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | -------- | -------- | 44e41f4b71Sopenharmony_ci | tag="history_temp_count" | Name of the tag indicating the number of historical temperature reporting times.| value | Number of historical temperature reporting times.| int | >0 | 45e41f4b71Sopenharmony_ci | tag="temperature_query_enum" | Tag name of the device list for obtaining the temperature.| value | Device list for obtaining the temperature.| enum | soc, battery, shell, cpu, charger, ambient, ap, and pa| 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ci **Table 2** Description of the sensor_cluster configuration 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ci | Configuration Item | Description | Data Type | Value Range | 51e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 52e41f4b71Sopenharmony_ci | name | Sensor cluster name | string | None | 53e41f4b71Sopenharmony_ci | sensor | Sensors in the cluster | string | soc, battery, shell, cpu, charger, ambient, ap, and pa | 54e41f4b71Sopenharmony_ci | aux_sensor | Auxiliary sensors in the cluster | string | soc, battery, shell, cpu, charger, ambient, ap, and pa | 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ci **Table 3** Description of the item configuration 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ci | Configuration Item | Description | Data Type | Value Range | 59e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 60e41f4b71Sopenharmony_ci | level | Thermal level defined for each sensor cluster | int | >0 | 61e41f4b71Sopenharmony_ci | threshold | Temperature threshold for each sensor in the cluster to reach the corresponding thermal level. The value is in unit of 0.001°C by default and can be changed as needed. | int | Product-specific | 62e41f4b71Sopenharmony_ci | threshold_clr | Temperature threshold for each sensor in the cluster to roll back to the previous thermal level. | int | Product-specific | 63e41f4b71Sopenharmony_ci | temp_rise_rate | Temperature rise frequency. | double | Product-specific | 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci ```shell 66e41f4b71Sopenharmony_ci <thermal version="0.01" product="lya"> 67e41f4b71Sopenharmony_ci <base> 68e41f4b71Sopenharmony_ci <item tag="history_temp_count" value="10"/> 69e41f4b71Sopenharmony_ci <item tag="temperature_query_enum" value="soc,battery,shell,cpu,charger,ambient,ap,pa"/> 70e41f4b71Sopenharmony_ci </base> 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci <level> 73e41f4b71Sopenharmony_ci <sensor_cluster name="base_safe" sensor="battery,charger,cpu,soc"> 74e41f4b71Sopenharmony_ci <item level="1" threshold="42000,40000,30000,40000" threshold_clr="38000,36000,28000,38000"/> 75e41f4b71Sopenharmony_ci <item level="2" threshold="43000,41000,32000,42000" threshold_clr="41000,39000,30000,40000"/> 76e41f4b71Sopenharmony_ci <item level="3" threshold="46000,44000,34000,44000" threshold_clr="44000,42000,32000,42000"/> 77e41f4b71Sopenharmony_ci <item level="4" threshold="48000,46000,36000,46000" threshold_clr="46000,44000,34000,44000"/> 78e41f4b71Sopenharmony_ci </sensor_cluster> 79e41f4b71Sopenharmony_ci </level> 80e41f4b71Sopenharmony_ci ``` 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci4. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/BUILD.gn) file in the default thermal level configuration folder to pack the `thermal_service_config.xml` file to the `/vendor/etc/thermal_config` directory. The configuration is as follows: 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci ```shell 85e41f4b71Sopenharmony_ci import("//build/ohos.gni") # Reference build/ohos.gni. 86e41f4b71Sopenharmony_ci 87e41f4b71Sopenharmony_ci ohos_prebuilt_etc("thermal_service_config") { 88e41f4b71Sopenharmony_ci source = "thermal_service_config.xml" 89e41f4b71Sopenharmony_ci relative_install_dir = "thermal_config" 90e41f4b71Sopenharmony_ci install_images = [ chipset_base_dir ] # Required configuration for installing the thermal_service_config.xml file in the vendor directory. 91e41f4b71Sopenharmony_ci part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. You can change it as required. 92e41f4b71Sopenharmony_ci } 93e41f4b71Sopenharmony_ci ``` 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_ci5. 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: 96e41f4b71Sopenharmony_ci 97e41f4b71Sopenharmony_ci ```json 98e41f4b71Sopenharmony_ci { 99e41f4b71Sopenharmony_ci "parts": { 100e41f4b71Sopenharmony_ci "product_rk3568": { 101e41f4b71Sopenharmony_ci "module_list": [ 102e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/default_app_config:default_app_config", 103e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/image_conf:custom_image_conf", 104e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/preinstall-config:preinstall-config", 105e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/resourceschedule:resourceschedule", 106e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/etc:product_etc_conf", 107e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/thermal/profile:thermal_service_config", // Add the configuration for building of thermal_service_config. 108e41f4b71Sopenharmony_ci ] 109e41f4b71Sopenharmony_ci } 110e41f4b71Sopenharmony_ci }, 111e41f4b71Sopenharmony_ci "subsystem": "product_hihope" 112e41f4b71Sopenharmony_ci } 113e41f4b71Sopenharmony_ci ``` 114e41f4b71Sopenharmony_ci In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` is the folder name, and `thermal_service_config` is the build target. 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). 117e41f4b71Sopenharmony_ci 118e41f4b71Sopenharmony_ci ```shell 119e41f4b71Sopenharmony_ci ./build.sh --product-name rk3568 --ccache 120e41f4b71Sopenharmony_ci ``` 121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_ci7. Burn the customized version to the DAYU200 development board. 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_ci### Debugging and Verification 125e41f4b71Sopenharmony_ci 126e41f4b71Sopenharmony_ci1. After startup, run the following command to launch the shell command line: 127e41f4b71Sopenharmony_ci ```shell 128e41f4b71Sopenharmony_ci hdc shell 129e41f4b71Sopenharmony_ci ``` 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ci2. Go to the `data/service/el0/thermal/sensor/soc/` directory. 132e41f4b71Sopenharmony_ci ```shell 133e41f4b71Sopenharmony_ci cd data/service/el0/thermal/sensor/soc 134e41f4b71Sopenharmony_ci ``` 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ci3. Change the SOC temperature. 137e41f4b71Sopenharmony_ci ```shell 138e41f4b71Sopenharmony_ci echo 42000 > temp 139e41f4b71Sopenharmony_ci ``` 140e41f4b71Sopenharmony_ci 141e41f4b71Sopenharmony_ci4. Obtain the current thermal level information. 142e41f4b71Sopenharmony_ci ```shell 143e41f4b71Sopenharmony_ci hidumper -s 3303 -a -l 144e41f4b71Sopenharmony_ci ``` 145e41f4b71Sopenharmony_ci 146e41f4b71Sopenharmony_ci The following is the reference thermal level information after customization: 147e41f4b71Sopenharmony_ci ```shell 148e41f4b71Sopenharmony_ci -------------------------------[ability]------------------------------- 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci 151e41f4b71Sopenharmony_ci ----------------------------------ThermalService--------------------------------- 152e41f4b71Sopenharmony_ci name: base_safe level: 2 153e41f4b71Sopenharmony_ci name: cold_safe level: 0 154e41f4b71Sopenharmony_ci name: high_safe level: 0 155e41f4b71Sopenharmony_ci name: warm_5G level: 0 156e41f4b71Sopenharmony_ci name: warm_safe level: 1 157e41f4b71Sopenharmony_ci ``` 158e41f4b71Sopenharmony_ci 159e41f4b71Sopenharmony_ci## Reference 160e41f4b71Sopenharmony_ciDuring development, you can refer to the [default thermal level configuration](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/thermal_service_config.xml). 161e41f4b71Sopenharmony_ci 162e41f4b71Sopenharmony_ciPacking path: `/vendor/etc/thermal_config/hdf` 163