• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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| 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_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" |
52    | name="current_xxx" | Charging current control | event | - **1**: event sending enabled<br>-**0**: event sending disabled| int | 0 or 1|
53    | 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" |
54    | name="voltage_xxx" | 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    | 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 comma (,).| string | N/A|
60
61    ```shell
62    <action>
63        <item name="cpu_big"/>
64        <item name="cpu_med"/>
65        <item name="cpu_lit"/>
66        <item name="gpu"/>
67        <item name="lcd"/>
68        <item name="volume" uid="2001,2002"/>
69        <item name="current_sc" protocol="current" param="sc" event="1"/>
70        <item name="voltage_buck" protocol="voltage" param="buck" event="1"/>
71        <item name="process_ctrl" event=""/>
72        <item name="shut_down" event="0"/>
73        <item name="thermallevel" event="0"/>
74        <item name="popup"/>
75        <item name="(action_name)" protocol="node" param="/sys/class/thermal/xxx"/>
76    </action>
77    ```
78
794. 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:
80
81    ```shell
82    import("//build/ohos.gni")                      # Reference build/ohos.gni.
83
84    ohos_prebuilt_etc("thermal_service_config") {
85        source = "thermal_service_config.xml"
86        relative_install_dir = "thermal_config"
87        install_images = [ chipset_base_dir ]       # Required configuration for installing the thermal_service_config.xml file in the vendor directory.
88        part_name = "product_rk3568"                # Set part_name to product_rk3568 for subsequent build. You can change it as required.
89    }
90    ```
91
925. Add the build target to `module_list` in [ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build). For example:
93
94    ```json
95    {
96        "parts": {
97            "product_rk3568": {
98                "module_list": [
99                    "//vendor/hihope/rk3568/default_app_config:default_app_config",
100                    "//vendor/hihope/rk3568/image_conf:custom_image_conf",
101                    "//vendor/hihope/rk3568/preinstall-config:preinstall-config",
102                    "//vendor/hihope/rk3568/resourceschedule:resourceschedule",
103                    "//vendor/hihope/rk3568/etc:product_etc_conf",
104                    "//vendor/hihope/rk3568/thermal/profile:thermal_service_config", // Add the configuration for building of thermal_service_config.
105                ]
106            }
107        },
108        "subsystem": "product_hihope"
109    }
110    ```
111    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.
112
1136. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md).
114
115    ```shell
116    ./build.sh --product-name rk3568 --ccache
117    ```
118
1197. Burn the customized version to the DAYU200 development board.
120
121### Debugging and Verification
122
1231. After startup, run the following command to launch the shell command line:
124    ```shell
125    hdc shell
126    ```
127
1282. Obtain the current thermal control information.
129    ```shell
130    hidumper -s 3303 -a -a
131    ```
132
133    The following is the reference thermal control result after customization:
134    ```shell
135    -------------------------------[ability]-------------------------------
136
137
138    ----------------------------------ThermalService---------------------------------
139    name: cpu_big	strict: 0	enableEvent: 0
140    name: cpu_med	strict: 0	enableEvent: 0
141    name: cpu_lit	strict: 0	enableEvent: 0
142    name: gpu	strict: 0	enableEvent: 0
143    name: boost	strict: 0	enableEvent: 0
144    name: lcd	strict: 0	enableEvent: 0
145    name: volume	uid: 2001,2002	strict: 0	enableEvent: 0
146    name: current	protocol: sc,buck	strict: 0	enableEvent: 1
147    name: voltage	protocol: sc,buck	strict: 0	enableEvent: 1
148    name: process_ctrl	strict: 0	enableEvent: 0
149    name: shut_down	strict: 0	enableEvent: 0
150    name: thermallevel	strict: 0	enableEvent: 0
151    name: popup	strict: 0	enableEvent: 0
152    ```
153
154## Reference
155During 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).
156
157Packing path: `/vendor/etc/thermal_config/hdf`
158