1# Thermal Control Customization 2 3## Overview 4 5### Introduction 6 7By 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. 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 control 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 control 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: 32 33 ```text 34 profile 35 ├── BUILD.gn 36 ├── thermal_service_config.xml 37 ``` 38 393. 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. 40 41 **Table 1** Configuration items for thermal control 42 43 | Configuration Item| Configuration Item Description| Parameter| Parameter Description| Data Type|Value Range| 44 | -------- | -------- | -------- | -------- | -------- | -------- | 45 | name="cpu_big" | Big-core CPU control (big-core CPU frequency)| N/A| N/A| N/A| N/A| 46 | name="cpu_med" | Medium-core CPU control (medium-core CPU frequency)| N/A| N/A| N/A| N/A| 47 | name="cpu_lit" | Small-core CPU control (small-core CPU frequency)| N/A| N/A| N/A| N/A| 48 | name="gpu" | GPU control (GPU frequency)| N/A| N/A| N/A| N/A| 49 | name="lcd" | LCD control (screen brightness)| N/A| N/A| N/A| N/A| 50 | name="volume" | Sound control (volume)| uid | User ID| int | Product-specific| 51 | name="current" | Charging current control (charging current during fast charging and slow charging)| protocol | Supported charging protocols: fast charging (supercharge) and slow charging (buck)| string | sc or buck| 52 | name="current" | Charging current control | event | - **1**: event sending enabled<br>-**0**: event sending disabled| int | 0 or 1| 53 | name="voltage" | Charging voltage control (charging voltage during fast charging and slow charging)| protocol | Supported charging protocols: fast charging (supercharge) and slow charging (buck)| string | sc or buck| 54 | name="voltage" | Charging voltage control | event | - **1**: event sending enabled<br>-**0**: event sending disabled| int | 0 or 1| 55 | 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| 56 | name="shut_down" | Shutdown control (device shutdown)| event | - **1**: event sending enabled<br>-**0**: event sending disabled| int | 0 or 1| 57 | name="thermallevel" | Thermal level control (thermal level reporting)| event | - **1**: event sending enabled<br>-**0**: event sending disabled| int | 0 or 1| 58 | name="popup" | Pop-up window control (pop-up window display)| N/A| N/A| N/A| N/A| 59 60 ```shell 61 <action> 62 <item name="cpu_big"/> 63 <item name="cpu_med"/> 64 <item name="cpu_lit"/> 65 <item name="gpu"/> 66 <item name="lcd"/> 67 <item name="volume" uid="2001,2002"/> 68 <item name="current" protocol="sc,buck" event="1"/> 69 <item name="voltage" protocol="sc,buck" event="1"/> 70 <item name="process_ctrl" event=""/> 71 <item name="shut_down" event="0"/> 72 <item name="thermallevel" event="0"/> 73 <item name="popup"/> 74 </action> 75 ``` 76 774. 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: 78 79 ```shell 80 import("//build/ohos.gni") # Reference build/ohos.gni. 81 82 ohos_prebuilt_etc("thermal_service_config") { 83 source = "thermal_service_config.xml" 84 relative_install_dir = "thermal_config" 85 install_images = [ chipset_base_dir ] # Required configuration for installing the thermal_service_config.xml file in the vendor directory. 86 part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. You can change it as required. 87 } 88 ``` 89 905. 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: 91 92 ```json 93 { 94 "parts": { 95 "product_rk3568": { 96 "module_list": [ 97 "//vendor/hihope/rk3568/default_app_config:default_app_config", 98 "//vendor/hihope/rk3568/image_conf:custom_image_conf", 99 "//vendor/hihope/rk3568/preinstall-config:preinstall-config", 100 "//vendor/hihope/rk3568/resourceschedule:resourceschedule", 101 "//vendor/hihope/rk3568/etc:product_etc_conf", 102 "//vendor/hihope/rk3568/thermal/profile:thermal_service_config", // Add the configuration for building of thermal_service_config. 103 ] 104 } 105 }, 106 "subsystem": "product_hihope" 107 } 108 ``` 109 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. 110 1116. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). 112 113 ```shell 114 ./build.sh --product-name rk3568 --ccache 115 ``` 116 1177. Burn the customized version to the DAYU200 development board. 118 119### Debugging and Verification 120 1211. After startup, run the following command to launch the shell command line: 122 ```shell 123 hdc shell 124 ``` 125 1262. Obtain the current thermal control information. 127 ```shell 128 hidumper -s 3303 -a -a 129 ``` 130 131 The following is the reference thermal control result after customization: 132 ```shell 133 -------------------------------[ability]------------------------------- 134 135 136 ----------------------------------ThermalService--------------------------------- 137 name: cpu_big strict: 0 enableEvent: 0 138 name: cpu_med strict: 0 enableEvent: 0 139 name: cpu_lit strict: 0 enableEvent: 0 140 name: gpu strict: 0 enableEvent: 0 141 name: boost strict: 0 enableEvent: 0 142 name: lcd strict: 0 enableEvent: 0 143 name: volume uid: 2001,2002 strict: 0 enableEvent: 0 144 name: current protocol: sc,buck strict: 0 enableEvent: 1 145 name: voltage protocol: sc,buck strict: 0 enableEvent: 1 146 name: process_ctrl strict: 0 enableEvent: 0 147 name: shut_down strict: 0 enableEvent: 0 148 name: thermallevel strict: 0 enableEvent: 0 149 name: popup strict: 0 enableEvent: 0 150 ``` 151 152## Reference 153During 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). 154 155Packing path: `/vendor/etc/thermal_config/hdf` 156