Preparing Nexus Player (FUGU) for SoCWatch

Original author: Alice H.
  • Transfer
The benefits of optimizing the power consumption of Android applications that are designed for mobile devices are visible to the naked eye. Less power consumption - longer time between recharges. But energy use has other aspects. Stationary hardware like the Nexus Player also needs cost-effective applications. On a global scale, and the Android platform is a phenomenon of such a magnitude, a careful attitude to energy means caring for the environment. Intel SoC Watch is a command line tool that allows you to analyze the power consumption of systems based on Intel platforms. Nexus Player is one such system. In order to find out with the help of SoCWatch what is happening “under the hood” of the Nexus Player, the device must be specially prepared.

image



SoCWatch Overview


Intel SoC Watch can collect information about the power consumption states of microprocessors and the reasons for switching between these states, track changes in clock frequency, bus usage, and many other indicators. All this helps to analyze in detail the parameters of energy consumption by various systems.

After collecting information, SoCWatch, by default, generates files containing raw data and a report with general information on the target system. Raw data (they are stored in a .SW1 format file) can be imported into Intel Energy Profiler. This tool has the same interface as VTune Amplifier. Here you can compare and visualize data about the behavior of the system, deployed in time. The report file (in .CSV format) can be opened, for example, in Microsoft Excel and, based on the data contained in it, build graphs that will facilitate analysis.

Obtaining root rights to the Nexus player


Nexus Player has already appeared on sale. Details on working with it, highlighted at the Intel Developer Forum 2015, can be found in IDF2015 Lab Notes: Getting your Nexus Player from shrink-wrap to Performance and Energy Analysis .

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

Building a kernel with a new configuration for Nexus Player


Google has disabled the module loading feature in the device’s kernel configuration. Therefore, in order to prepare the Nexus Player for working with SoCWatch, we need to download the kernel source code from the official Google website and, having modified its configuration, rebuild it. In order to do this, you need to follow these steps.

1. Download the kernel source from the official Google site.

2. Change the kernel configuration 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-built kernel. In the case of devices built on the Intel platform, sometimes, if you upgrade only the kernel partition, 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 build a bootable image, we use the tool for working with images of Android Image Kitchen . It, in particular, allows you to unpack and pack images. To get started, download the factory image from the Google Developers portal. After that, we will 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 a failed flashing, you can revive it as follows. Disconnect the power cable, wait a bit, connect the cable, and then press and hold the hardware button, which 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 reflash the device and return it to working capacity.

5. Sew a new boot.img to the device using the following commands:

adb reboot bootloader
fastboot flash boot boot.img
fastboot reboot

Now you can check the kernel version to see if the flashing succeeded. If successful, then you can build the SoCWatch driver.

SoCWatch driver assembly


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

1. Let's build socperf1_2.ko using the script to build the driver in <INSTALLATION_DIR_PATH> \ soc_perf_driver \ src \

sh ./build-driver

2. Let's build SOCWATCH1_5.ko using the script to build the driver in <INSTALLATION_DIR_PATH> \ socwatch_driver \ lxkernel \

sh ./build-driver –k  -s 

Setting up the SoCWatch environment


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 required. 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 the SD card, and then copy them to the / data / socwatch directory. It 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 use the SoCWatch User Guide to begin collecting data. After collecting the data, it remains only to download the received files from the device to the host computer and begin to analyze the performance and power consumption information of the Nexus Player.


Data collection with SoCWatch

Summary


If you are developing applications that focus on the Nexus Player, now you know how to make the world a better place. It is enough to analyze the energy consumption of your developments with the help of Intel SoC Watch and fix the fact that there is unreasonably a lot of electricity.

Also popular now: