1e41f4b71Sopenharmony_ci# Thermal Policy Customization 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci## Overview 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci### Introduction 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciBy default, the OpenHarmony provides the thermal policy feature. Various components on a device can generate heat. Therefore, for different components, the thermal policy needs to be defined based on their thermal levels and thermal scenes. However, thermal control at different thermal levels varies according to product specifications. To address this issue, OpenHarmony provides the thermal policy 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 policy 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 policy 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 policy configuration folder. The following tables describe the related configuration items. 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci **Table 1** Description of the config configuration 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci | Configuration Item| Description| Type| Value Range| 44e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 45e41f4b71Sopenharmony_ci | name | Name of the sensor cluster corresponding to the thermal policy.| string | Corresponding to the sensor cluster name defined in [Thermal Level](../subsystems/subsys-thermal_level.md).| 46e41f4b71Sopenharmony_ci | level | Thermal level corresponding to the thermal policy.| int | Corresponding to the thermal level defined for the sensor cluster in [Thermal Level](../subsystems/subsys-thermal_level.md).| 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ci **Table 2** Description of configuration items 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ci | Configuration Item| Description| Type| Value Range| 51e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 52e41f4b71Sopenharmony_ci | scene | Application scenario.| string | Corresponding to the application scenario defined in [Thermal Scene](../subsystems/subsys-thermal_scene.md).| 53e41f4b71Sopenharmony_ci | charge | Charging status.| int | The value **1** indicates charging, and the value **0** indicates the opposite.| 54e41f4b71Sopenharmony_ci | screen | Screen status.| int | The value **1** indicates that the screen is on, and the value **0** indicates the opposite.| 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ci **Table 3** Description of the node configuration 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ci | Node| Value Type| Value Range| Description| 59e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 60e41f4b71Sopenharmony_ci | lcd | double | 0.00~1.00 | Percentage of the screen brightness (represented by a floating point number).| 61e41f4b71Sopenharmony_ci | cpu_big | int | Product-specific| CPU big core frequency.| 62e41f4b71Sopenharmony_ci | cpu_med | int | Product-specific| CPU medium-core frequency.| 63e41f4b71Sopenharmony_ci | cpu_lit | int | Product-specific| CPU small-core frequency.| 64e41f4b71Sopenharmony_ci | process_ctrl | enum | 1: KILL_FG_PROCESS_APP<br>2: KILL_BG_PROCESS_APP<br>3: KILL_ALL_PROCESS_APP| Process control.| 65e41f4b71Sopenharmony_ci | gpu | int | Product-specific| GPU frequency.| 66e41f4b71Sopenharmony_ci | thermallevel | int | Corresponding to **level** defined in the **config** node| Thermal level.| 67e41f4b71Sopenharmony_ci | current_sc | int | Product-specific| Fast charging current.| 68e41f4b71Sopenharmony_ci | current_buck | int | Product-specific| Slow charging current.| 69e41f4b71Sopenharmony_ci | voltage_sc | int | Product-specific| Fast charging voltage.| 70e41f4b71Sopenharmony_ci | voltage_buck | int | Product-specific| Slow charging voltage.| 71e41f4b71Sopenharmony_ci | volume | double | 0.00~1.00 | Volume percentage (represented by a floating point number).| 72e41f4b71Sopenharmony_ci 73e41f4b71Sopenharmony_ci ```shell 74e41f4b71Sopenharmony_ci <policy> 75e41f4b71Sopenharmony_ci <config name="base_safe" level="1"> 76e41f4b71Sopenharmony_ci <lcd>1.00</lcd> 77e41f4b71Sopenharmony_ci <lcd scene="cam">0.99</lcd> 78e41f4b71Sopenharmony_ci <lcd scene="call">0.98</lcd> 79e41f4b71Sopenharmony_ci <lcd scene="game">0.95</lcd> 80e41f4b71Sopenharmony_ci <cpu_big>1992000</cpu_big> 81e41f4b71Sopenharmony_ci <cpu_med>1991500</cpu_med> 82e41f4b71Sopenharmony_ci <cpu_lit>1991200</cpu_lit> 83e41f4b71Sopenharmony_ci <process_ctrl>3</process_ctrl> 84e41f4b71Sopenharmony_ci <cpu_big scene="cam" charge="1">1991800</cpu_big> 85e41f4b71Sopenharmony_ci <cpu_big scene="cam" charge="0">1991600</cpu_big> 86e41f4b71Sopenharmony_ci <gpu screen="0">524288</gpu> 87e41f4b71Sopenharmony_ci <gpu screen="1">512000</gpu> 88e41f4b71Sopenharmony_ci <thermallevel>1</thermallevel> 89e41f4b71Sopenharmony_ci <current_sc>1800</current_sc> 90e41f4b71Sopenharmony_ci <current_sc scene="cam">1200</current_sc> 91e41f4b71Sopenharmony_ci <current_buck>1200</current_buck> 92e41f4b71Sopenharmony_ci <voltage_sc>4000</voltage_sc> 93e41f4b71Sopenharmony_ci <voltage_buck>3000</voltage_buck> 94e41f4b71Sopenharmony_ci <volume>1.0</volume> 95e41f4b71Sopenharmony_ci </config> 96e41f4b71Sopenharmony_ci <policy> 97e41f4b71Sopenharmony_ci <config name="base_safe" level="2"> 98e41f4b71Sopenharmony_ci <lcd>0.90</lcd> 99e41f4b71Sopenharmony_ci <lcd scene="cam">0.89</lcd> 100e41f4b71Sopenharmony_ci <lcd scene="call">0.88</lcd> 101e41f4b71Sopenharmony_ci <lcd scene="game">0.87</lcd> 102e41f4b71Sopenharmony_ci <cpu_big>1991000</cpu_big> 103e41f4b71Sopenharmony_ci <cpu_med>1990500</cpu_med> 104e41f4b71Sopenharmony_ci <cpu_lit>1990200</cpu_lit> 105e41f4b71Sopenharmony_ci <process_ctrl>2</process_ctrl> 106e41f4b71Sopenharmony_ci <cpu_big scene="cam" charge="1">1990800</cpu_big> 107e41f4b71Sopenharmony_ci <cpu_big scene="cam" charge="0">1990600</cpu_big> 108e41f4b71Sopenharmony_ci <gpu screen="0">499712</gpu> 109e41f4b71Sopenharmony_ci <gpu screen="1">487424</gpu> 110e41f4b71Sopenharmony_ci <thermallevel>2</thermallevel> 111e41f4b71Sopenharmony_ci <current_sc>1500</current_sc> 112e41f4b71Sopenharmony_ci <current_sc scene="cam">1000</current_sc> 113e41f4b71Sopenharmony_ci <current_buck>1000</current_buck> 114e41f4b71Sopenharmony_ci <voltage_sc>3000</voltage_sc> 115e41f4b71Sopenharmony_ci <voltage_buck>2000</voltage_buck> 116e41f4b71Sopenharmony_ci <volume>0.8</volume> 117e41f4b71Sopenharmony_ci </config> 118e41f4b71Sopenharmony_ci </policy> 119e41f4b71Sopenharmony_ci ``` 120e41f4b71Sopenharmony_ci 121e41f4b71Sopenharmony_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 policy configuration folder to pack the `thermal_service_config.xml` file to the `/vendor/etc/thermal_config` directory. The configuration is as follows: 122e41f4b71Sopenharmony_ci 123e41f4b71Sopenharmony_ci ```shell 124e41f4b71Sopenharmony_ci import("//build/ohos.gni") # Reference build/ohos.gni. 125e41f4b71Sopenharmony_ci 126e41f4b71Sopenharmony_ci ohos_prebuilt_etc("thermal_service_config") { 127e41f4b71Sopenharmony_ci source = "thermal_service_config.xml" 128e41f4b71Sopenharmony_ci relative_install_dir = "thermal_config" 129e41f4b71Sopenharmony_ci install_images = [ chipset_base_dir ] # Required configuration for installing the thermal_service_config.xml file in the vendor directory. 130e41f4b71Sopenharmony_ci part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. You can change it as required. 131e41f4b71Sopenharmony_ci } 132e41f4b71Sopenharmony_ci ``` 133e41f4b71Sopenharmony_ci 134e41f4b71Sopenharmony_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: 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ci ```json 137e41f4b71Sopenharmony_ci { 138e41f4b71Sopenharmony_ci "parts": { 139e41f4b71Sopenharmony_ci "product_rk3568": { 140e41f4b71Sopenharmony_ci "module_list": [ 141e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/default_app_config:default_app_config", 142e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/image_conf:custom_image_conf", 143e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/preinstall-config:preinstall-config", 144e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/resourceschedule:resourceschedule", 145e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/etc:product_etc_conf", 146e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/thermal/profile:thermal_service_config", // Add the configuration for building of thermal_service_config. 147e41f4b71Sopenharmony_ci ] 148e41f4b71Sopenharmony_ci } 149e41f4b71Sopenharmony_ci }, 150e41f4b71Sopenharmony_ci "subsystem": "product_hihope" 151e41f4b71Sopenharmony_ci } 152e41f4b71Sopenharmony_ci ``` 153e41f4b71Sopenharmony_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. 154e41f4b71Sopenharmony_ci 155e41f4b71Sopenharmony_ci6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). 156e41f4b71Sopenharmony_ci 157e41f4b71Sopenharmony_ci ```shell 158e41f4b71Sopenharmony_ci ./build.sh --product-name rk3568 --ccache 159e41f4b71Sopenharmony_ci ``` 160e41f4b71Sopenharmony_ci 161e41f4b71Sopenharmony_ci7. Burn the customized version to the DAYU200 development board. 162e41f4b71Sopenharmony_ci 163e41f4b71Sopenharmony_ci### Debugging and Verification 164e41f4b71Sopenharmony_ci 165e41f4b71Sopenharmony_ci1. After startup, run the following command to launch the shell command line: 166e41f4b71Sopenharmony_ci ```shell 167e41f4b71Sopenharmony_ci hdc shell 168e41f4b71Sopenharmony_ci ``` 169e41f4b71Sopenharmony_ci 170e41f4b71Sopenharmony_ci2. Obtain the current thermal policy information. 171e41f4b71Sopenharmony_ci ```shell 172e41f4b71Sopenharmony_ci hidumper -s 3303 -a -p 173e41f4b71Sopenharmony_ci ``` 174e41f4b71Sopenharmony_ci 175e41f4b71Sopenharmony_ci The following is the reference thermal policy result after customization: 176e41f4b71Sopenharmony_ci ```shell 177e41f4b71Sopenharmony_ci -------------------------------[ability]------------------------------- 178e41f4b71Sopenharmony_ci 179e41f4b71Sopenharmony_ci 180e41f4b71Sopenharmony_ci ----------------------------------ThermalService--------------------------------- 181e41f4b71Sopenharmony_ci name: base_safe level: 1 182e41f4b71Sopenharmony_ci actionName: lcd actionValue: 1.00 isProp: 0 183e41f4b71Sopenharmony_ci actionName: lcd actionValue: 0.99 scene: cam isProp: 1 184e41f4b71Sopenharmony_ci actionName: lcd actionValue: 0.98 scene: call isProp: 1 185e41f4b71Sopenharmony_ci actionName: lcd actionValue: 0.95 scene: game isProp: 1 186e41f4b71Sopenharmony_ci actionName: cpu_big actionValue: 1992000 isProp: 0 187e41f4b71Sopenharmony_ci actionName: cpu_med actionValue: 1991500 isProp: 0 188e41f4b71Sopenharmony_ci actionName: cpu_lit actionValue: 1991200 isProp: 0 189e41f4b71Sopenharmony_ci actionName: process_ctrl actionValue: 3 isProp: 0 190e41f4b71Sopenharmony_ci actionName: cpu_big actionValue: 1991800 charge: 1 scene: cam isProp: 1 191e41f4b71Sopenharmony_ci actionName: cpu_big actionValue: 1991600 charge: 0 scene: cam isProp: 1 192e41f4b71Sopenharmony_ci actionName: gpu actionValue: 524288 screen: 0 isProp: 1 193e41f4b71Sopenharmony_ci actionName: gpu actionValue: 512000 screen: 1 isProp: 1 194e41f4b71Sopenharmony_ci actionName: thermallevel actionValue: 1 isProp: 0 195e41f4b71Sopenharmony_ci actionName: current_sc actionValue: 1800 isProp: 0 196e41f4b71Sopenharmony_ci actionName: current_sc actionValue: 1200 scene: cam isProp: 1 197e41f4b71Sopenharmony_ci actionName: current_buck actionValue: 1200 isProp: 0 198e41f4b71Sopenharmony_ci actionName: voltage_sc actionValue: 4000 isProp: 0 199e41f4b71Sopenharmony_ci actionName: voltage_buck actionValue: 3000 isProp: 0 200e41f4b71Sopenharmony_ci actionName: volume actionValue: 1.0 isProp: 0 201e41f4b71Sopenharmony_ci actionName: boost actionValue: 1 isProp: 0 202e41f4b71Sopenharmony_ci 203e41f4b71Sopenharmony_ci level: 2 204e41f4b71Sopenharmony_ci actionName: lcd actionValue: 0.90 isProp: 0 205e41f4b71Sopenharmony_ci actionName: lcd actionValue: 0.89 scene: cam isProp: 1 206e41f4b71Sopenharmony_ci actionName: lcd actionValue: 0.88 scene: call isProp: 1 207e41f4b71Sopenharmony_ci actionName: lcd actionValue: 0.87 scene: game isProp: 1 208e41f4b71Sopenharmony_ci actionName: cpu_big actionValue: 1991000 isProp: 0 209e41f4b71Sopenharmony_ci actionName: cpu_med actionValue: 1990500 isProp: 0 210e41f4b71Sopenharmony_ci actionName: cpu_lit actionValue: 1990200 isProp: 0 211e41f4b71Sopenharmony_ci actionName: process_ctrl actionValue: 2 isProp: 0 212e41f4b71Sopenharmony_ci actionName: cpu_big actionValue: 1990800 charge: 1 scene: cam isProp: 1 213e41f4b71Sopenharmony_ci actionName: cpu_big actionValue: 1990600 charge: 0 scene: cam isProp: 1 214e41f4b71Sopenharmony_ci actionName: gpu actionValue: 499712 screen: 0 isProp: 1 215e41f4b71Sopenharmony_ci actionName: gpu actionValue: 487424 screen: 1 isProp: 1 216e41f4b71Sopenharmony_ci actionName: thermallevel actionValue: 2 isProp: 0 217e41f4b71Sopenharmony_ci actionName: current_sc actionValue: 1500 isProp: 0 218e41f4b71Sopenharmony_ci actionName: current_sc actionValue: 1000 scene: cam isProp: 1 219e41f4b71Sopenharmony_ci actionName: current_buck actionValue: 1000 isProp: 0 220e41f4b71Sopenharmony_ci actionName: voltage_sc actionValue: 3000 isProp: 0 221e41f4b71Sopenharmony_ci actionName: voltage_buck actionValue: 2000 isProp: 0 222e41f4b71Sopenharmony_ci actionName: volume actionValue: 0.8 isProp: 0 223e41f4b71Sopenharmony_ci actionName: boost actionValue: 1 isProp: 0 224e41f4b71Sopenharmony_ci ``` 225e41f4b71Sopenharmony_ci 226e41f4b71Sopenharmony_ci## Reference 227e41f4b71Sopenharmony_ciDuring development, you can refer to the [default thermal policy configuration](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/thermal_service_config.xml). 228e41f4b71Sopenharmony_ci 229e41f4b71Sopenharmony_ciPacking path: `/vendor/etc/thermal_config/hdf` 230