This guide will show how to get ARM® DS-5™ Streamline™ support working on a production Google Nexus 10 device, with minimal modifications.
The resulting files generated will be a gatord, gator.ko and a boot.img file.
This guide is written with both Android version 4.3 (JellyBean MR2) and 4.4.2 (KitKat MR1) in mind.
It is required that the Nexus 10 device has root access.
This is required in order to install gator and to insert the kernel module.
You will also be flashing and/or booting a custom kernel.
ARM DS-5 software is required to be installed. This is required in order to do any capturing of data and also contains the source code for gator.
The community edition of DS-5 can be obtained for free from the ds5 website.
This guide has been tested with DS-5 version 5.17 on Linux.
In addition, you will need the Android SDK (for adb and fastboot) and Android NDK (for building gator daemon).
Finally, you will need abootimg or equivalent scripts to modify the boot.img.
The toolchain to be used for building the kernel can be obtained from the following public git repository:
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/
In order to setup your build environment to use this toolchain, and to target cross compilation, do the following:
export PATH=$PATH:$(pwd)/arm-eabi-4.6/bin export CROSS_COMPILE=arm-eabi- export ARCH=arm export SUBARCH=arm
The kernel source code can be obtained from the following public git repository:
git clone https://android.googlesource.com/kernel/exynos kernel cd kernel
Either checkout jb-mr2 (Android 4.3) or kitkat-mr1 (Android 4.4.2) branch depending on what version of Android your device is running:
git checkout android-exynos-manta-3.4-jb-mr2 git checkout android-exynos-manta-3.4-kitkat-mr1
Building
To build the kernel, do the following:
make manta_defconfig make
In order to build the gator driver however, you will need to make modifications to the kernel.
make menuconfig
[*] Enable loadable module support -->
[*] Forced module loading
[*] Module unloading
[*] Forced module unloading
General setup -->
[*] Profiling support
Device Drivers -->
Graphics Support -->
ARM GPU Configuration -->
Mali-T6XX support -->
[*] Streamline Debug support
If you are targeting Android 4.3, you will need to make the following modifications before you can successfully build:
diff --git a/drivers/gpu/arm/t6xx/kbase/src/Kbuild b/drivers/gpu/arm/t6xx/kbase/src/Kbuild index 584d5f2..e6eadd6 100644 --- a/drivers/gpu/arm/t6xx/kbase/src/Kbuild +++ b/drivers/gpu/arm/t6xx/kbase/src/Kbuild @@ -41,7 +41,7 @@ DEFINES = \ -DMALI_ERROR_INJECT_ON=$(MALI_ERROR_INJECT_ON) \ -DMALI_MOCK_TEST=$(MALI_MOCK_TEST) \ -DMALI_COVERAGE=$(MALI_COVERAGE) \ - -DMALI_KBASE_SRC_LINUX_PATH=$(src)/linux \ + -DMALI_KBASE_SRC_LINUX_PATH=../../$(src)/linux \ -DMALI_KBASE_THIRDPARTY_PATH=../../$(src)/platform/$(CONFIG_MALI_PLATFORM_THIRDPARTY_NAME) \ -DMALI_INSTRUMENTATION_LEVEL=$(MALI_INSTRUMENTATION_LEVEL) \ -DMALI_RELEASE_NAME=\"$(MALI_RELEASE_NAME)\" diff --git a/drivers/gpu/arm/t6xx/kbase/src/platform/manta/mali_kbase_platform.c b/drivers/gpu/arm/t6xx/kbase/src/p index 6140252..ad4adfe 100644 --- a/drivers/gpu/arm/t6xx/kbase/src/platform/manta/mali_kbase_platform.c +++ b/drivers/gpu/arm/t6xx/kbase/src/platform/manta/mali_kbase_platform.c @@ -220,7 +220,7 @@ int kbase_platform_cmu_pmu_control(struct kbase_device *kbdev, int control) spin_lock_irqsave(&platform->cmu_pmu_lock, flags); #ifdef CONFIG_MALI_GATOR_SUPPORT - kbase_trace_mali_timeline_event(GATOR_MAKE_EVENT(ACTIVITY_RTPM_CHANGED, ACTIVITY_RTPM) | control); +// kbase_trace_mali_timeline_event(GATOR_MAKE_EVENT(ACTIVITY_RTPM_CHANGED, ACTIVITY_RTPM) | control); #endif /* off */ if (control == 0) {
You can now build the kernel with make.
In order to get this modified kernel onto the device, you need to modify a boot.img file.
A boot image file consists (mainly) of a kernel and a ramdisk.
You can easily download this from google’s website:
https://developers.google.com/android/nexus/images#mantaray
Extract the files for either 4.3 or 4.4.2, and obtain the boot.img file.
In order to generate a new boot.img with your newly built kernel, do the following:
abootimg -u boot.img -k kernel/arch/arm/boot/zImage
Alternative scripts method:
./unpackbootimg -i boot.img ./mkbootimg --kernel kernel/arch/arm/boot/zImage --ramdisk boot.img-ramdisk.gz -o boot.img
At this stage, you can either flash the new boot image over the original stock boot image, or you can boot the image directly without flashing. With the latter option, after a reboot of the device, the original boot image will be used instead. This is useful for testing purposes.
In order to do either, you first need to boot the device into bootloader mode. This is easily done via adb:
adb reboot bootloader
To just boot directly, do:
fastboot boot boot.img
To flash the image, do:
fastboot flash boot boot.img
Your device should now boot using the custom kernel.
This can be tested by looking at Settings -> About tablet -> Kernel version
You can obtain the driver and daemon source files from your DS-5 installation directory:
<DS-5 Installation Directory>/arm/gator/
Build the driver by doing the following, from within the gator-driver directory:
GATOR_WITH_MALI_SUPPORT=MALI_T6xx make -C <path_to>/kernel M=`pwd` modules
You should now have gator.ko.
First, you will need to modify the structure of the gator-daemon directory in order to build for Android.
Create a folder called jni inside gator-daemon and move all files and folder to this location:
mkdir jni mv * jni/
Then, build the daemon by doing the following, from within the gator-daemon directory:
ndk-build
You should now have gatord.
Unfortunately you cannot simply push these two gator files directly into the system directory on the device, due to permission issues with a secure adb device.
The way around this is to do the following. First, remount the system partition as read/write access:
adb shell su -c 'mount -o remount /system'
Next, push the files to the sdcard:
adb push gator.ko /sdcard/ adb push gatord /sdcard/
Then copy these files from the sdcard to the system directory:
adb shell su -c 'cp /sdcard/gator* /system/bin/'
Finally, give full permissions to the daemon:
adb shell su -c 'chmod 777 /system/bin/gatord'
You are now ready to use the device with Streamline support.
The normal procedure for using gator is as follows – and is required to be done each time the device restarts:
Setup forwarding through usb instead of network (optional):
adb forward tcp:8080 tcp:8080
Launch the daemon from within an adb shell:
adb shell su -c 'gatord &'
Launch DS-5, and enter localhost (or the ip address if you didn’t do the forward command) in the connection box.
Select the counters you are interested in capturing, and you are now ready to begin capturing.
I am not able to build the kernel on a Windows 8.1 machine using Cygwin64 terminal. A bunch of errors are coming up while using the makefile. Is it because of the absence of cross compilers? I am working with Nexus 10 device with jb 4.2.2 OS. I pushed the gatord file into the device but am not getting any Mali specific counter values. I have the gator-driver source code. The present kernel version of device is 3.4.5-gaf9c307. Is the issue of not getting GPU counters related to not having a gator.ko in the Nexus device? I am not interested in CPU counters so not concerned with the PMU counters not being configured.
Hi pratik,
That error is a common one we see on the Nexus 10 devices. It is due to the DBGEN bit not being enabled in the bootloader. Unfortunately, the bootloader is from Samsung and not open sourced, so we cannot make modifications to this in order to set it (or at least I have not yet found a way myself - if anyone does, please share it!).
As such, all CPU hardware counters read as zero.
Please note that this only affects CPU hardware counters. It does not affect CPU software counters, or any other block with hardware counters.
This means it does not affect the GPU counters, and as such is not something we mentioned in this article since it should not cause problems for Mali.
Can you confirm that you are indeed seeing Mali GPU counters reading back as zero all the time? And if so, can you list which counters are affected? Is it only a subset, or all of them?
Thank you for bringing this to our attention, if you have any further questions, please don't hesitate to ask them either here or separately as a question in the ARM Mali Graphics section.
Kind Regards,
Michael McGeagh
Hi,
There is an article about the error you are seeing: PMU Counters are reading zeroes in Streamline.
I hope this helps.Marcelo
I followed the steps mentioned above but I get following error in the DS-5 Streamline tool and I am not able to look at the GPU counters:
ARM Processor PMU counters not configured.
ARM Processor PMU event counters have been detected, however the event counters are reading zeroes. Event counters include those counters listed in the counter configuration options dialog under the core name but exclude the cycle counter (Clock:Cycles) as it is controlled by a dedicated counter. It is possible that the PMU configuration bit DBGEN has not been enabled, and counter values subsequently will always read as zero. To remedy, please update your firmware or Linux kernel to enable DBGEN. If a device tree is used it is also possible that the PMU entries are missing in the device tree. If this is the case please contact your vendor for a patch.
How do I enable DBGEN in the kernel?
On Mac OS X 10.9, when running the fastboot commands you may get the error:
ERROR: Unable to create a plug-in (e00002be)
This can be avoided by running fastboot as root:
sudo fastboot flash boot boot.img