HomeCommunityMobile, Graphics, and Gaming blog
May 13, 2015

Using DS-5 Streamline with Mali on Samsung Galaxy Note 4

ABSTRACTThis guide will show how to get ARM® DS-5™ Streamline™ support working on a production Samsung Galaxy Note 4 device, with minimal modifications.The resulting files generated will be a gatord, gator.ko and a boot.img.tar.md5 f...

By Michael McGeagh

Share
Reading time 5 minutes

ABSTRACT

This guide will show how to get ARM® DS-5™ Streamline™ support working on a production Samsung Galaxy Note 4 device, with minimal modifications.

The resulting files generated will be a gatord, gator.ko and a boot.img.tar.md5 file.

This guide is written with Android™ version 5.0.1 (Lollipop) in mind.

Note: If using version 4.4.4, please upgrade to 5.0.1. There is a known issue with 4.4.4 which results in hardware counters reporting zeros.

PREREQUISITE

Device Requirements

It is required that the Note 4 (SM-N910S) device have root access.

This is required in order to install gator and to insert the kernel module.

You will also be flashing a custom kernel.

Software Requirements

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.21 on Windows and Linux.

In addition, you will need the Android SDK (for adb) and Android NDK (for building gator daemon).

You will also need to use ODIN, which works under Windows, in order to flash the boot image.

Finally, you will need the linux tool abootimg to modify the boot image.

KERNEL

Toolchain

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






In order to set up your build environment to use this toolchain and to target cross compilation, do the following:

export PATH=$PATH:$(pwd)/arm-eabi-4.7/bin
export CROSS_COMPILE=arm-eabi-
export ARCH=arm
export SUBARCH=arm







Source Code

The kernel source code can be obtained from the following website:

http://opensource.samsung.com/

For the Note 4, search for SM-N910S. At time of writing, this was tested with SM-N910S_LL_Opensource.zip.

Building

To build the kernel, do the following:

make trelteskt_defconfig
make






In order to build the gator driver however, you will need to make modifications to the kernel.

make menuconfig

Enable the following:


[*] Enable loadable module support -->

[*] Forced module loading


General setup -->

[*] Profiling support

    Kernel Performance Events And Counters -->
          [*] Kernel performance events and counters


Device Drivers -->

Graphics Support -->

ARM GPU Configuration -->

Mali-T7XX support -->

[*] Streamline Debug support

Disable the following:

System Type -->

[ ] Enable TIMA(Trustzone based Integrity Measurement Archtecture feature

The above disabled feature is neccessary in order to successfully insmod the gator kernel module. If you do not do this, then when you run the gator daemon, you will get an error and a message on dmesg about "GAF structure checksum is invalid!"

You can now build the kernel with make.



BOOT IMAGE

In order to get this modified kernel onto the device, you need to generate a boot.img.tar.md5 file for use with the ODIN Windows application.

boot.img

You can obtain the original stock boot.img file directly off the device with the following command:

adb shell su -c dd if=/dev/block/platform/15540000.dwmmc0/by-name/BOOT of=/sdcard/boot.img
adb pull /sdcard/boot.img







boot.img.tar.md5

Now we have the components, we can create the final image to use with ODIN.

First, generate a new boot.img with your newly built kernel by doing the following:

abootimg -u boot.img -k kernel/arch/arm/boot/zImage






Finally, tar and then generate and append an md5sum to the end of the file:

tar cf boot.img.tar boot.img
md5sum boot.img.tar >> boot.img.tar
mv boot.img.tar boot.img.tar.md5

ODIN

In order to use ODIN, you first need to boot the device into download/odin mode. This is easily done via adb:

adb reboot download

Alternatively, you can press and hold VOL_DOWN + HOME + PWR buttons. Press VOL_UP to continue when prompted.

Please download and run the Windows application ODIN, and then connect the device via USB.

Click the PDA or AP button, and browse to the boot.img.tar.md5 file created previously.

Then click Start.

Your device should now boot using the custom kernel.

This can be tested by looking at Settings -> About device -> Kernel version

GATOR

You can obtain the driver and daemon source files from your DS-5 installation directory:

<DS-5 Installation Directory>/arm/gator/

Driver

Because the kernel sources have multiple copies of the Mali Driver, you need to let gator know which one is being used by the kernel. To do this, you need to run the following command:

sed –i 's|midgard|t7xx/r5p0|g' mali_midgard.mk

Now, you can build the driver by doing the following, from within the gator-driver directory:

GATOR_WITH_MALI_SUPPORT=MALI_MIDGARD make -C <path_to>/kernel M=`pwd` modules

You should now have gator.ko.

Daemon

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.

Device Setup

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.

Using Gator

The normal procedure for using gator is as follows – and is required to be done each time the device restarts:

adb shell su -c mount -o remount /system

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.


4Log in to like this post
Share

Article text

Re-use is only permitted for informational and non-commercial or personal use only.

placeholder