1e41f4b71Sopenharmony_ci# Thermal Log Customization
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci## Overview
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci### Introduction
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ciBy default, the OpenHarmony provides the thermal log feature. Thermal logs record the temperature of device components during usage. However, the content and path of thermal logs vary according to product specifications. To address this issue, OpenHarmony provides the thermal log 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 log 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 log configuration folder](https://gitee.com/openharmony/drivers_peripheral/tree/master/thermal/interfaces/hdi_service/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_hdi_config.xml
37e41f4b71Sopenharmony_ci    ```
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci3. Create a target folder by referring to the [default thermal log parameter configuration folder](https://gitee.com/openharmony/drivers_peripheral/tree/master/thermal/etc) and install it in `//vendor/hihope/rk3568/thermal`. The file format is as follows:
40e41f4b71Sopenharmony_ci    ```text
41e41f4b71Sopenharmony_ci    etc
42e41f4b71Sopenharmony_ci    ├── BUILD.gn
43e41f4b71Sopenharmony_ci    ├── thermal.para
44e41f4b71Sopenharmony_ci    ├── thermal.para.dac
45e41f4b71Sopenharmony_ci    ```
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci4. Write the custom `thermal_hdi_config.xml` file by referring to the [thermal_hdi_config.xml](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/interfaces/hdi_service/profile/thermal_hdi_config.xml) file in the default thermal log configuration folder. The following tables describe the related configuration items.
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci    **Table 1** Description of the tracing configuration
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci    | Configuration Item| Description| Data Type| Value Range|
52e41f4b71Sopenharmony_ci    | -------- | -------- | -------- | -------- |
53e41f4b71Sopenharmony_ci    | interval | Interval for recording temperature tracing logs, in ms.| int | >0 |
54e41f4b71Sopenharmony_ci    | width | Width of the temperature tracing log, in characters.| int | >0 |
55e41f4b71Sopenharmony_ci    | outpath | Path for storing temperature tracing logs.| string | N/A|
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci    **Table 2** Description of the node configuration
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci    | Node| Configuration Item| Description|
60e41f4b71Sopenharmony_ci    | -------- | -------- | -------- |
61e41f4b71Sopenharmony_ci    | title | path | Path for obtaining the thermal zone name.|
62e41f4b71Sopenharmony_ci    | title | name | Thermal zone name.|
63e41f4b71Sopenharmony_ci    | value | path | Path for obtaining the thermal zone temperature.|
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci    ```shell
66e41f4b71Sopenharmony_ci    <tracing interval="5000" width="20" outpath="/data/log/thermal-log">
67e41f4b71Sopenharmony_ci        <node>
68e41f4b71Sopenharmony_ci            <title path="sys/class/thermal/thermal_zone0/type"/>
69e41f4b71Sopenharmony_ci            <value path="sys/class/thermal/thermal_zone0/temp"/>
70e41f4b71Sopenharmony_ci        </node>
71e41f4b71Sopenharmony_ci        <node>
72e41f4b71Sopenharmony_ci            <title name="gpu-thermal"/>   
73e41f4b71Sopenharmony_ci            <value path="sys/class/thermal/thermal_zone1/temp"/>
74e41f4b71Sopenharmony_ci        </node>
75e41f4b71Sopenharmony_ci    </tracing>
76e41f4b71Sopenharmony_ci    ```
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ci5. Write the custom `thermal.para` and `thermal.para.dac` files by referring to the [thermal.para](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/etc/thermal.para) and [thermal.para.dac](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/etc/thermal.para.dac) files in the default hot log parameter configuration folder. The custom configuration is as follows:
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci    thermal.para:
81e41f4b71Sopenharmony_ci    ```text
82e41f4b71Sopenharmony_ci    persist.thermal.log.enable=true     # Enable the thermal log function.
83e41f4b71Sopenharmony_ci    persist.thermal.log.interval=5000   # Set the interval for recording temperature tracing logs, in ms.
84e41f4b71Sopenharmony_ci    persist.thermal.log.width=20        # Set the width of the temperature tracing log, in characters.
85e41f4b71Sopenharmony_ci    ```
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_ci    thermal.para.dac:
88e41f4b71Sopenharmony_ci    ```text
89e41f4b71Sopenharmony_ci    persist.thermal.log.="power_host:power_host:600" # Configure access permissions.
90e41f4b71Sopenharmony_ci    ```
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci6. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/interfaces/hdi_service/profile/BUILD.gn) file in the default thermal log configuration folder to pack the `thermal_hdi_config.xml` file to the `//vendor/etc/thermal_config/hdf` directory. The configuration is as follows:
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci    ```shell
95e41f4b71Sopenharmony_ci    import("//build/ohos.gni")
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ci    ohos_prebuilt_etc("thermal_hdf_config") {
98e41f4b71Sopenharmony_ci        source = "thermal_hdi_config.xml"
99e41f4b71Sopenharmony_ci        relative_install_dir = "thermal_config/hdf"
100e41f4b71Sopenharmony_ci        install_images = [ chipset_base_dir ]       # Required configuration for installing the thermal_hdi_config.xml file in the vendor directory.
101e41f4b71Sopenharmony_ci        part_name = "product_rk3568"                # Set part_name to product_rk3568 for subsequent build. You can change it as required.
102e41f4b71Sopenharmony_ci    }
103e41f4b71Sopenharmony_ci    ```
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ci7. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/etc/BUILD.gn) file in the default thermal log parameter configuration folder to pack the `thermal.para` and `thermal.para.dac` files to the `//vendor/etc/param/thermal.para` directory. The configuration is as follows:
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci    ```shell
108e41f4b71Sopenharmony_ci    import("//build/ohos.gni")
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci    ## Install thermal.para to /vendor/etc/param/thermal.para
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci    ohos_prebuilt_etc("thermal.para") {
113e41f4b71Sopenharmony_ci        source = "thermal.para"
114e41f4b71Sopenharmony_ci        relative_install_dir = "param"
115e41f4b71Sopenharmony_ci        install_images = [ chipset_base_dir ]
116e41f4b71Sopenharmony_ci        part_name = "product_rk3568"
117e41f4b71Sopenharmony_ci    }
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ci    ohos_prebuilt_etc("thermal.para.dac") {
120e41f4b71Sopenharmony_ci        source = "thermal.para.dac"
121e41f4b71Sopenharmony_ci        relative_install_dir = "param"
122e41f4b71Sopenharmony_ci        install_images = [ chipset_base_dir ]
123e41f4b71Sopenharmony_ci        part_name = "product_rk3568"
124e41f4b71Sopenharmony_ci    }
125e41f4b71Sopenharmony_ci
126e41f4b71Sopenharmony_ci    group("param_files") {
127e41f4b71Sopenharmony_ci        deps = [
128e41f4b71Sopenharmony_ci            ":thermal.para",
129e41f4b71Sopenharmony_ci            ":thermal.para.dac",
130e41f4b71Sopenharmony_ci        ]
131e41f4b71Sopenharmony_ci    }
132e41f4b71Sopenharmony_ci    ```
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci8. 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_hdf_config",  // Add the configuration for building of thermal_hdf_config.
147e41f4b71Sopenharmony_ci                    "//vendor/hihope/rk3568/thermal/etc:param_files"              // Add the configuration for building of thermal.para and thermal.para.dac.
148e41f4b71Sopenharmony_ci                ]
149e41f4b71Sopenharmony_ci            }
150e41f4b71Sopenharmony_ci        },
151e41f4b71Sopenharmony_ci        "subsystem": "product_hihope"
152e41f4b71Sopenharmony_ci    }
153e41f4b71Sopenharmony_ci    ```
154e41f4b71Sopenharmony_ci    In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` and `etc` are folder names, and `thermal_hdf_config` and `param_files` are the build targets.
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ci9. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md).
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci    ```shell
159e41f4b71Sopenharmony_ci    ./build.sh --product-name rk3568 --ccache
160e41f4b71Sopenharmony_ci    ```
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_ci10. Burn the customized version to the DAYU200 development board.
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ci### Debugging and Verification
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_ci1. After startup, run the following command to launch the shell command line:
167e41f4b71Sopenharmony_ci    ```shell
168e41f4b71Sopenharmony_ci    hdc shell
169e41f4b71Sopenharmony_ci    ```
170e41f4b71Sopenharmony_ci 
171e41f4b71Sopenharmony_ci2. Go to the customized directory.
172e41f4b71Sopenharmony_ci    ```shell
173e41f4b71Sopenharmony_ci    cd /data/log/thermal/
174e41f4b71Sopenharmony_ci    ```
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ci    View thermal logs.
177e41f4b71Sopenharmony_ci    ```shell
178e41f4b71Sopenharmony_ci    cat thermal.000.20170805-175756
179e41f4b71Sopenharmony_ci    ```
180e41f4b71Sopenharmony_ci
181e41f4b71Sopenharmony_ci    The following is the reference thermal log after customization:
182e41f4b71Sopenharmony_ci    ```shell
183e41f4b71Sopenharmony_ci    timestamp                    soc-thermal         gpu-thermal
184e41f4b71Sopenharmony_ci    2017-08-05 17:57:56          37777               37222
185e41f4b71Sopenharmony_ci    2017-08-05 17:58:01          38333               37777
186e41f4b71Sopenharmony_ci    2017-08-05 17:58:06          36666               37222
187e41f4b71Sopenharmony_ci    2017-08-05 17:58:11          36666               37222
188e41f4b71Sopenharmony_ci    2017-08-05 17:58:16          36666               37222
189e41f4b71Sopenharmony_ci    2017-08-05 17:58:21          36111               37222
190e41f4b71Sopenharmony_ci    2017-08-05 17:58:26          36111               37222
191e41f4b71Sopenharmony_ci    2017-08-05 17:58:31          36666               37222
192e41f4b71Sopenharmony_ci    2017-08-05 17:58:36          36111               37222
193e41f4b71Sopenharmony_ci    2017-08-05 17:58:41          36111               37222
194e41f4b71Sopenharmony_ci    2017-08-05 17:58:46          36666               36666
195e41f4b71Sopenharmony_ci    ```
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_ci## Reference
198e41f4b71Sopenharmony_ciDuring development, you can refer to the [default thermal log configuration](https://gitee.com/openharmony/drivers_peripheral/tree/master/thermal/interfaces/hdi_service/profile/) and [default thermal log parameter configuration](https://gitee.com/openharmony/drivers_peripheral/tree/master/thermal/etc).
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_ciPacking path: `/vendor/etc/thermal_config/hdf`
201