subsys-thermal_log.md 8.9 KB
Newer Older
S
shawn_he 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
# Thermal Log Customization

## Overview

### Introduction

By 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.

### Constraints

The 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.

## How to Develop

### Setting Up the Environment

**Hardware requirements:**

Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite.

**Environment requirements:**

For details about the requirements on the Linux environment, see [Quick Start](../quick-start/quickstart-overview.md).

### Getting Started with Development

The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate thermal log customization.

S
shawn_he 已提交
29
1. Create the thermal folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568).
S
shawn_he 已提交
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

2. 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:
     
    ```text
    profile
    ├── BUILD.gn
    ├── thermal_hdi_config.xml
    ```

3. 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:
    ```text
    etc
    ├── BUILD.gn
    ├── thermal.para
    ├── thermal.para.dac
    ```

4. 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.

    **Table 1** Description of the tracing configuration

    | Configuration Item| Description| Data Type| Value Range|
    | -------- | -------- | -------- | -------- |
    | outpath | Path for storing temperature tracing logs.| string | N/A|

    **Table 2** Description of the node configuration

    | Node| Configuration Item| Description|
    | -------- | -------- | -------- |
    | title | path | Path for obtaining the thermal zone name.|
    | title | name | Thermal zone name.|
    | value | path | Path for obtaining the thermal zone temperature.|

    ```shell
S
shawn_he 已提交
64
    <tracing outpath="/data/log/thermal-log">
S
shawn_he 已提交
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
        <node>
            <title path="sys/class/thermal/thermal_zone0/type"/>
            <value path="sys/class/thermal/thermal_zone0/temp"/>
        </node>
        <node>
            <title name="gpu-thermal"/>   
            <value path="sys/class/thermal/thermal_zone1/temp"/>
        </node>
    </tracing>
    ```

5. 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:

    thermal.para:
    ```text
    persist.thermal.log.enable=true     # Enable the thermal log function.
    persist.thermal.log.interval=5000   # Set the interval for recording temperature tracing logs, in ms.
    persist.thermal.log.width=20        # Set the width of the temperature tracing log, in characters.
    ```

    thermal.para.dac:
    ```text
S
shawn_he 已提交
87
    persist.thermal.log.="power_host:power_host:500" # Configure access permissions.
S
shawn_he 已提交
88 89
    ```

S
shawn_he 已提交
90
6. 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:
S
shawn_he 已提交
91 92 93 94 95 96 97

    ```shell
    import("//build/ohos.gni")

    ohos_prebuilt_etc("thermal_hdf_config") {
        source = "thermal_hdi_config.xml"
        relative_install_dir = "thermal_config/hdf"
S
shawn_he 已提交
98
        install_images = [ chipset_base_dir ]       # Required configuration for installing the thermal_service_config.xml file in the vendor directory.
S
shawn_he 已提交
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
        part_name = "product_rk3568"                # Set part_name to product_rk3568 for subsequent build. You can change it as required.
    }
    ```

7. 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:

    ```shell
    import("//build/ohos.gni")

    ## Install thermal.para to /vendor/etc/param/thermal.para

    ohos_prebuilt_etc("thermal.para") {
        source = "thermal.para"
        relative_install_dir = "param"
        install_images = [ chipset_base_dir ]
        part_name = "product_rk3568"
    }

    ohos_prebuilt_etc("thermal.para.dac") {
        source = "thermal.para.dac"
        relative_install_dir = "param"
        install_images = [ chipset_base_dir ]
        part_name = "product_rk3568"
    }

    group("param_files") {
        deps = [
            ":thermal.para",
            ":thermal.para.dac",
        ]
    }
    ```

8. 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:

    ```json
    {
        "parts": {
            "product_rk3568": {
                "module_list": [
                    "//vendor/hihope/rk3568/default_app_config:default_app_config",
                    "//vendor/hihope/rk3568/image_conf:custom_image_conf",
                    "//vendor/hihope/rk3568/preinstall-config:preinstall-config",
                    "//vendor/hihope/rk3568/resourceschedule:resourceschedule",
                    "//vendor/hihope/rk3568/etc:product_etc_conf",
                    "//vendor/hihope/rk3568/thermal/profile:thermal_hdf_config",  // Add the configuration for building of thermal_hdf_config.
                    "//vendor/hihope/rk3568/thermal/etc:param_files"              // Add the configuration for building of thermal.para and thermal.para.dac.
                ]
            }
        },
        "subsystem": "product_hihope"
    }
    ```
S
shawn_he 已提交
152
    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.
S
shawn_he 已提交
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198

9. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md).

    ```shell
    ./build.sh --product-name rk3568 --ccache
    ```

10. Burn the customized version to the DAYU200 development board.

### Debugging and Verification

1. After startup, run the following command to launch the shell command line:
    ```shell
    hdc shell
    ```
 
2. Go to the customized directory.
    ```shell
    cd /data/log/thermal/
    ```

    View thermal logs.
    ```shell
    cat thermal.000.20170805-175756
    ```

    The following is the reference thermal log after customization:
    ```shell
    timestamp                    soc-thermal         gpu-thermal
    2017-08-05 17:57:56          37777               37222
    2017-08-05 17:58:01          38333               37777
    2017-08-05 17:58:06          36666               37222
    2017-08-05 17:58:11          36666               37222
    2017-08-05 17:58:16          36666               37222
    2017-08-05 17:58:21          36111               37222
    2017-08-05 17:58:26          36111               37222
    2017-08-05 17:58:31          36666               37222
    2017-08-05 17:58:36          36111               37222
    2017-08-05 17:58:41          36111               37222
    2017-08-05 17:58:46          36666               36666
    ```

## Reference
During 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).

Packing path: `/vendor/etc/thermal_config/hdf`