1e41f4b71Sopenharmony_ci# Thermal Control Customization 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci## Overview 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci### Introduction 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciBy default, OpenHarmony provides the thermal control feature. If a device becomes overheated during usage, thermal control measures need to be taken for the device. For example, if the battery temperature is too high during charging, then thermal control needs to be applied to the charging device. However, thermal control varies according to product specifications. To address this issue, OpenHarmony provides the thermal control 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/blob/master/rk3568) as an example to illustrate thermal control customization. 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci1. Create the `thermal` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568). 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci2. Create a target folder by referring to the [default thermal control configuration folder](https://gitee.com/openharmony/powermgr_thermal_manager/blob/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 control configuration folder. The following table describes the related configuration items. 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci **Table 1** Configuration items for thermal control 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci | Configuration Item| Description| Parameter| Parameter Description| Data Type|Value Range| 44e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | -------- | -------- | 45e41f4b71Sopenharmony_ci | name="airplane" | Airplane mode control| N/A| N/A| N/A| N/A| 46e41f4b71Sopenharmony_ci | name="cpu_big" | Big-core CPU control (big-core CPU frequency)| N/A| N/A| N/A| N/A| 47e41f4b71Sopenharmony_ci | name="cpu_med" | Medium-core CPU control (medium-core CPU frequency)| N/A| N/A| N/A| N/A| 48e41f4b71Sopenharmony_ci | name="cpu_lit" | Small-core CPU control (small-core CPU frequency)| N/A| N/A| N/A| N/A| 49e41f4b71Sopenharmony_ci | name="gpu" | GPU control (GPU frequency)| N/A| N/A| N/A| N/A| 50e41f4b71Sopenharmony_ci | name="boost" | SOCPERF thermal level control| event | - **1**: event sending enabled<br>-**0**: event sending disabled| int | 0 or 1| 51e41f4b71Sopenharmony_ci | name="isolate" | CPU frequency increase control| event | - **1**: event sending enabled<br>-**0**: event sending disabled| int | 0 or 1| 52e41f4b71Sopenharmony_ci | name="lcd" | LCD control (screen brightness)| N/A| N/A| N/A| N/A| 53e41f4b71Sopenharmony_ci | name="volume" | Sound control (volume)| uid | User ID| int | Product-specific| 54e41f4b71Sopenharmony_ci | name="current_xxx" | Charging current control (charging current during fast charging and slow charging)| protocol<br>param | Set **protocol** to **current** and **param** to a supported charging protocol, that is, fast charging (**sc**) or slow charging (**buck**).| string |protocol="current" param="sc" | 55e41f4b71Sopenharmony_ci | name="current_xxx" | Charging current control | event | - **1**: event sending enabled<br>-**0**: event sending disabled| int | 0 or 1| 56e41f4b71Sopenharmony_ci | name="voltage_xxx" | Charging voltage control (charging voltage during fast charging and slow charging)| protocol<br>param | Set **protocol** to **voltage** and **param** to a charging protocol, that is, fast charging (**sc**) or slow charging (**buck**).| string | protocol="voltage" param="buck" | 57e41f4b71Sopenharmony_ci | name="voltage_xxx" | Charging voltage control | event | - **1**: event sending enabled<br>-**0**: event sending disabled| int | 0 or 1| 58e41f4b71Sopenharmony_ci | name="process_ctrl" | Process control (survival status of foreground and background processes)| param | Set **param** to any string.| string | N/A| 59e41f4b71Sopenharmony_ci | name="process_ctrl" | Process control (survival status of foreground and background processes)| event | - **1**: event sending enabled<br>-**0**: event sending disabled<br>If this parameter is not set, the value is defaulted to **0**.| int | 0 or 1| 60e41f4b71Sopenharmony_ci | name="shut_down" | Shutdown control (device shutdown)| event | - **1**: event sending enabled<br>-**0**: event sending disabled| int | 0 or 1| 61e41f4b71Sopenharmony_ci | name="thermallevel" | Thermal level control (thermal level reporting)| event | - **1**: event sending enabled<br>-**0**: event sending disabled| int | 0 or 1| 62e41f4b71Sopenharmony_ci | name="popup" | Pop-up window control (pop-up window display)| N/A| N/A| N/A| N/A| 63e41f4b71Sopenharmony_ci | name="xxx" | Node thermal control action| protocol<br>param | Set **protocol** to **node**.<br>Set **param** to the node path and rollback value, which are separated by a|backslash (\).| string | N/A| 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci ```shell 66e41f4b71Sopenharmony_ci <action> 67e41f4b71Sopenharmony_ci <item name="airplane"/> 68e41f4b71Sopenharmony_ci <item name="cpu_big"/> 69e41f4b71Sopenharmony_ci <item name="cpu_med"/> 70e41f4b71Sopenharmony_ci <item name="cpu_lit"/> 71e41f4b71Sopenharmony_ci <item name="gpu"/> 72e41f4b71Sopenharmony_ci <item name="boost" event="1"/> 73e41f4b71Sopenharmony_ci <item name="isolate" event="1"/> 74e41f4b71Sopenharmony_ci <item name="lcd"/> 75e41f4b71Sopenharmony_ci <item name="volume" uid="2001,2002"/> 76e41f4b71Sopenharmony_ci <item name="current_sc" protocol="current" param="sc" event="1"/> 77e41f4b71Sopenharmony_ci <item name="voltage_buck" protocol="voltage" param="buck" event="1"/> 78e41f4b71Sopenharmony_ci <item name="process_ctrl" param="32,64,128,256" event=""/> 79e41f4b71Sopenharmony_ci <item name="shut_down" event="0"/> 80e41f4b71Sopenharmony_ci <item name="thermallevel" event="1"/> 81e41f4b71Sopenharmony_ci <item name="popup"/> 82e41f4b71Sopenharmony_ci <item name="(action_name)" protocol="node" param="/sys/class/thermal/xxx"/> 83e41f4b71Sopenharmony_ci <item name="test"/> 84e41f4b71Sopenharmony_ci </action> 85e41f4b71Sopenharmony_ci ``` 86e41f4b71Sopenharmony_ci 87e41f4b71Sopenharmony_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 control configuration folder to pack the `thermal_service_config.xml` file to the `/vendor/etc/thermal_config` directory. The configuration is as follows: 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ci ```shell 90e41f4b71Sopenharmony_ci import("//build/ohos.gni") # Reference build/ohos.gni. 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci ohos_prebuilt_etc("thermal_service_config") { 93e41f4b71Sopenharmony_ci source = "thermal_service_config.xml" 94e41f4b71Sopenharmony_ci relative_install_dir = "thermal_config" 95e41f4b71Sopenharmony_ci install_images = [ chipset_base_dir ] # Required configuration for installing the thermal_service_config.xml file in the vendor directory. 96e41f4b71Sopenharmony_ci part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. You can change it as required. 97e41f4b71Sopenharmony_ci } 98e41f4b71Sopenharmony_ci ``` 99e41f4b71Sopenharmony_ci 100e41f4b71Sopenharmony_ci5. Add the build target to `module_list` in [ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build). For example: 101e41f4b71Sopenharmony_ci 102e41f4b71Sopenharmony_ci ```json 103e41f4b71Sopenharmony_ci { 104e41f4b71Sopenharmony_ci "parts": { 105e41f4b71Sopenharmony_ci "product_rk3568": { 106e41f4b71Sopenharmony_ci "module_list": [ 107e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/default_app_config:default_app_config", 108e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/image_conf:custom_image_conf", 109e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/preinstall-config:preinstall-config", 110e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/resourceschedule:resourceschedule", 111e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/etc:product_etc_conf", 112e41f4b71Sopenharmony_ci "//vendor/hihope/rk3568/thermal/profile:thermal_service_config", // Add the configuration for building of thermal_service_config. 113e41f4b71Sopenharmony_ci ] 114e41f4b71Sopenharmony_ci } 115e41f4b71Sopenharmony_ci }, 116e41f4b71Sopenharmony_ci "subsystem": "product_hihope" 117e41f4b71Sopenharmony_ci } 118e41f4b71Sopenharmony_ci ``` 119e41f4b71Sopenharmony_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. 120e41f4b71Sopenharmony_ci 121e41f4b71Sopenharmony_ci6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). 122e41f4b71Sopenharmony_ci 123e41f4b71Sopenharmony_ci ```shell 124e41f4b71Sopenharmony_ci ./build.sh --product-name rk3568 --ccache 125e41f4b71Sopenharmony_ci ``` 126e41f4b71Sopenharmony_ci 127e41f4b71Sopenharmony_ci7. Burn the customized version to the DAYU200 development board. 128e41f4b71Sopenharmony_ci 129e41f4b71Sopenharmony_ci### Debugging and Verification 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ci1. After startup, run the following command to launch the shell command line: 132e41f4b71Sopenharmony_ci ```shell 133e41f4b71Sopenharmony_ci hdc shell 134e41f4b71Sopenharmony_ci ``` 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ci2. Obtain the current thermal control information. 137e41f4b71Sopenharmony_ci ```shell 138e41f4b71Sopenharmony_ci hidumper -s 3303 -a -a 139e41f4b71Sopenharmony_ci ``` 140e41f4b71Sopenharmony_ci 141e41f4b71Sopenharmony_ci The following is the reference thermal control result after customization: 142e41f4b71Sopenharmony_ci ```shell 143e41f4b71Sopenharmony_ci -------------------------------[ability]------------------------------- 144e41f4b71Sopenharmony_ci 145e41f4b71Sopenharmony_ci 146e41f4b71Sopenharmony_ci ----------------------------------ThermalService--------------------------------- 147e41f4b71Sopenharmony_ci name: airplane strict: 0 enableEvent: 0 148e41f4b71Sopenharmony_ci name: cpu_big strict: 0 enableEvent: 0 149e41f4b71Sopenharmony_ci name: cpu_med strict: 0 enableEvent: 0 150e41f4b71Sopenharmony_ci name: cpu_lit strict: 0 enableEvent: 0 151e41f4b71Sopenharmony_ci name: gpu strict: 0 enableEvent: 0 152e41f4b71Sopenharmony_ci name: boost strict: 0 enableEvent: 1 153e41f4b71Sopenharmony_ci name: isolate strict: 0 enableEvent: 1 154e41f4b71Sopenharmony_ci name: lcd strict: 0 enableEvent: 0 155e41f4b71Sopenharmony_ci name: volume uid: 2001,2002 strict: 0 enableEvent: 0 156e41f4b71Sopenharmony_ci name: current_sc params: sc protocol: current strict: 0 enableEvent: 1 157e41f4b71Sopenharmony_ci name: current_buck params: buck protocol: current strict: 0 enableEvent: 1 158e41f4b71Sopenharmony_ci name: voltage_sc params: sc protocol: voltage strict: 0 enableEvent: 1 159e41f4b71Sopenharmony_ci name: voltage_buck params: buck protocol: voltage strict: 0 enableEvent: 1 160e41f4b71Sopenharmony_ci name: process_ctrl params: 32,64,128,256 strict: 0 enableEvent: 0 161e41f4b71Sopenharmony_ci name: shut_down strict: 0 enableEvent: 0 162e41f4b71Sopenharmony_ci name: thermallevel strict: 0 enableEvent: 1 163e41f4b71Sopenharmony_ci name: popup strict: 0 enableEvent: 0 164e41f4b71Sopenharmony_ci name: test strict: 0 enableEvent: 0 165e41f4b71Sopenharmony_ci ``` 166e41f4b71Sopenharmony_ci 167e41f4b71Sopenharmony_ci## Reference 168e41f4b71Sopenharmony_ciDuring development, you can refer to the [default thermal control configuration](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/thermal_service_config.xml). 169e41f4b71Sopenharmony_ci 170e41f4b71Sopenharmony_ciPacking path: `/vendor/etc/thermal_config/hdf` 171e41f4b71Sopenharmony_ci 172e41f4b71Sopenharmony_ci<!--no_check-->