📜 ⬆️ ⬇️

Preparing Nexus Player (FUGU) for working with SoCWatch

The benefits of optimizing the power consumption of Android applications that are designed for mobile devices are visible to the naked eye. Less energy consumption - longer time between recharges. But there are other aspects of energy consumption. Stationary hardware, like the Nexus Player, also needs cost-effective applications. On a global scale, and the Android platform is a phenomenon of just that magnitude, respect for energy means caring for the environment.

image

Intel SoC Watch is a command line tool that allows you to analyze the power consumption of systems based on platforms from Intel. Nexus Player is one such system. In order to learn with the help of SoCWatch what is going on “under the hood” of the Nexus Player, the device must be specially prepared.

General information about SoCWatch


Intel SoC Watch is able to collect information about the states of power consumption of microprocessors and the reasons for switching between these states, track changes in the clock frequency, the use of tires, and many other indicators. All this helps to analyze in detail the parameters of energy consumption by different systems.
')
After collecting information, SoCWatch, by default, generates files containing raw data and a report with general information on the target system. Raw data (stored in a .SW1 file) can be imported into the Intel Energy Profiler. This tool has the same interface as VTune Amplifier. Here you can compare and visualize data on the behavior of the system, deployed in time. The report file (in the .CSV format) can be opened, for example, in Microsoft Excel and, based on the data it contains, to construct graphs that will make analysis easier.

Getting root rights on the Nexus player


Nexus Player is already on sale. Details about working with him, covered at the Intel Developer Forum 2015, you can find in the material IDF2015 Lab Notes: Getting your Nexus Player from shrink-wrap to Performance and Energy Analysis .

In order for the Nexus Player to be analyzed using SoCWatch, additional efforts will be required. For example, an analytical system needs root-rights to collect performance data using a kernel-level driver. In order to obtain such rights, you can use the video guide Nexus Player - How to Root Android TV . After root-rights are obtained, the device will be able to perceive the su command in the ADB shell.

Build a kernel with a new configuration for Nexus Player


Google has disabled the module loading feature in the device's OS kernel configuration. Therefore, in order to prepare Nexus Player for working with SoCWatch, we need to download the kernel source code from the official Google site and, after modifying its configuration, rebuild. In order to do this, you need to perform the following steps.

1. Download the kernel source code from the official Google website.

2. Let's change the configuration of the kernel so that it contains the following settings, which include the features we need:

export ARCH=x86 make fugu_defconfig make menuconfig 

 CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y CONFIG_TRACEPOINTS=y CONFIG_FRAME_POINTER=y CONFIG_COMPAT=y CONFIG_TIMER_STATS=y CONFIG_X86_ACPI_CPUFREQ=m (or CONFIG_X86_ACPI_CPUFREQ=y) CONFIG_INTEL_IDLE=y 

3. Make sure that the rebuilt kernel can be found at <INSTALLATION_DIR_PATH> \ x86_64 \ arch \ x86 \ boot \ bzImage

 make –j4 

4. Create a boot image with a pre-assembled kernel. In the case of devices built on the Intel platform, sometimes, if you only reflash the kernel section, you can fail. Therefore, we will create a boot image with the newly built kernel configured as we need. For this purpose, we can put the kernel inside the Android source tree and build only the boot image.

In order to collect the boot image, we use the tool to work with images of Android Image Kitchen . It, in particular, allows you to unpack and pack images. First, download the factory image from the Google Developers portal. After that, use the unpackimg.bat file to unpack the image and replace the <INSTALLATION_DIR_PATH> \ split_img \ boot.img-zImage file with the bzImage file that we created in the previous step. At the end of this step, we will use the batch file repacking.bat to create a new boot.img

Please note that if the device cannot reboot after unsuccessful flashing, you can revive it as follows. Unplug the power cord, wait a while, plug in the cord, and then press and hold the hardware button that is located on the bottom of the device. Nexus Player will enter fastboot mode. After that, use the flash-all.bat script, which can be found among the files downloaded along with the factory image from the Google Developers website. He will rewrite the device and return it to work.

5. Run the new boot.img to the device with the following commands:

 adb reboot bootloader fastboot flash boot boot.img fastboot reboot 

Now you can check the kernel version in order to understand whether the flashing was successful. If successful, you can build the SoCWatch driver.

SoCWatch driver build


The source code for the driver is included in the SocWatch package, which can be downloaded along with Intel System Studio . SoCWatch is one of the components of Intel System Studio. To build the driver, use the following sequence of actions:

1. Build socperf1_2.ko using a script to build the driver in <INSTALLATION_DIR_PATH> \ soc_perf_driver \ src \

 sh ./build-driver 

2. We will build SOCWATCH1_5.ko using the script to build the driver in <INSTALLATION_DIR_PATH> \ socwatch_driver \ lxkernel \

 sh ./build-driver –k <KERNEl_BUILD_DIR> -s <KERNEl_BUILD_DIR> 

Setting up the environment SoCWatch


You can run the installation file (socwatch_android_install.bat) using the adb root command after root-rights are obtained on the device. However, in order for this command to work successfully, some additional settings may be needed. Therefore, we will consider here a universal procedure for preparing the SoCWatch environment based on the use of the su command.

First you need to go to the SoCWatch folder and copy the necessary files to the device In our case, we can send these files to an SD card, and then copy them to the / data / socwatch directory. This is done like this:

 tools\os2unix.exe setup_socwatch_env.sh tools\dos2unix.exe SOCWatchConfig.txt adb push socwatch /sdcard/socwatch/ adb push setup_socwatch_env.sh /sdcard/socwatch/ adb push libs /sdcard/socwatch/libs/ adb push valleyview_soc /sdcard/socwatch/valleyview_soc/ adb push tangier_soc /sdcard/socwatch/tangier_soc/ adb push anniedale_soc /sdcard/socwatch/anniedale_soc/ adb push socperf1_2.ko /sdcard/socwatch/ adb push SOCWATCH1_5.ko /sdcard/socwatch/ adb shell su cp –r /sdcard/socwatch /data/ cd /data/socwatch chmod 766 socwatch 

Now you can, using the SoCWatch User Guide , start collecting data. After collecting the data, it remains only to download the received files from the device to the main computer and proceed to the analysis of information about the performance and power consumption of the Nexus Player.


Data collection with SoCWatch

Results


If you are developing applications targeted at Nexus Player, now you know how to make the world a better place. It is enough to analyze the power consumption of its developments with the help of the Intel SoC Watch and correct what "eats" an unreasonably lot of electricity.

Source: https://habr.com/ru/post/266843/


All Articles