1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 4<title>9.�README.android</title> 5<link rel="stylesheet" type="text/css" href="vg_basic.css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="index.html" title="Valgrind Documentation"> 8<link rel="up" href="dist.html" title="Valgrind Distribution Documents"> 9<link rel="prev" href="dist.readme-s390.html" title="8.�README.S390"> 10<link rel="next" href="dist.readme-android_emulator.html" title="10.�README.android_emulator"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<div><table class="nav" width="100%" cellspacing="3" cellpadding="3" border="0" summary="Navigation header"><tr> 14<td width="22px" align="center" valign="middle"><a accesskey="p" href="dist.readme-s390.html"><img src="images/prev.png" width="18" height="21" border="0" alt="Prev"></a></td> 15<td width="25px" align="center" valign="middle"><a accesskey="u" href="dist.html"><img src="images/up.png" width="21" height="18" border="0" alt="Up"></a></td> 16<td width="31px" align="center" valign="middle"><a accesskey="h" href="index.html"><img src="images/home.png" width="27" height="20" border="0" alt="Up"></a></td> 17<th align="center" valign="middle">Valgrind Distribution Documents</th> 18<td width="22px" align="center" valign="middle"><a accesskey="n" href="dist.readme-android_emulator.html"><img src="images/next.png" width="18" height="21" border="0" alt="Next"></a></td> 19</tr></table></div> 20<div class="chapter"> 21<div class="titlepage"><div><div><h1 class="title"> 22<a name="dist.readme-android"></a>9.�README.android</h1></div></div></div> 23<div class="literallayout"><p><br> 24������<br> 25How�to�cross-compile�and�run�on�Android.��Please�read�to�the�end,<br> 26since�there�are�important�details�further�down�regarding�crash<br> 27avoidance�and�GPU�support.<br> 28<br> 29These�notes�were�last�updated�on�4�Nov�2014,�for�Valgrind�SVN<br> 30revision�14689/2987.<br> 31<br> 32These�instructions�are�known�to�work,�or�have�worked�at�some�time�in<br> 33the�past,�for:<br> 34<br> 35arm:<br> 36��Android�4.0.3�running�on�a�(rooted,�AOSP�build)�Nexus�S.<br> 37��Android�4.0.3�running�on�Motorola�Xoom.<br> 38��Android�4.0.3�running�on�android�arm�emulator.<br> 39��Android�4.1���running�on�android�emulator.<br> 40��Android�2.3.4�on�Nexus�S�worked�at�some�time�in�the�past.<br> 41<br> 42x86:<br> 43��Android�4.0.3�running�on�android�x86�emulator.<br> 44<br> 45mips32:<br> 46��Android�4.1.2�running�on�android�mips�emulator.<br> 47��Android�4.2.2�running�on�android�mips�emulator.<br> 48��Android�4.3���running�on�android�mips�emulator.<br> 49��Android�4.0.4�running�on�BROADCOM�bcm7425<br> 50<br> 51arm64:<br> 52��Android�4.5�(?)�running�on�ARM�Juno<br> 53<br> 54On�android-arm,�GDBserver�might�insert�breaks�at�wrong�addresses.<br> 55Feedback�on�this�welcome.<br> 56<br> 57Other�configurations�and�toolchains�might�work,�but�haven't�been�tested.<br> 58Feedback�is�welcome.<br> 59<br> 60Toolchain:<br> 61<br> 62��For�arm32,�x86�and�mips32�you�need�the�android-ndk-r6�native<br> 63����development�kit.��r6b�and�r7�give�a�non-completely-working�build;<br> 64����see�http://code.google.com/p/android/issues/detail?id=23203<br> 65����For�the�android�emulator,�the�versions�needed�and�how�to�install<br> 66����them�are�described�in�README.android_emulator.<br> 67<br> 68����You�can�get�android-ndk-r6�from<br> 69����http://dl.google.com/android/ndk/android-ndk-r6-linux-x86.tar.bz2<br> 70<br> 71��For�arm64�(aarch64)�you�need�the�android-ndk-r10c�NDK,�from<br> 72����http://dl.google.com/android/ndk/android-ndk-r10c-linux-x86_64.bin<br> 73<br> 74Install�the�NDK�somewhere.��Doesn't�matter�where.��Then:<br> 75<br> 76<br> 77#�Modify�this�(obviously).��Note,�this�"export"�command�is�only�done<br> 78#�so�as�to�reduce�the�amount�of�typing�required.��None�of�the�commands<br> 79#�below�read�it�as�part�of�their�operation.<br> 80#<br> 81export�NDKROOT=/path/to/android-ndk-r<version><br> 82<br> 83<br> 84#�Then�cd�to�the�root�of�your�Valgrind�source�tree.<br> 85#<br> 86cd�/path/to/valgrind/source/tree<br> 87<br> 88<br> 89#�After�this�point,�you�don't�need�to�modify�anything.��Just�copy�and<br> 90#�paste�the�commands�below.<br> 91<br> 92<br> 93#�Set�up�toolchain�paths.<br> 94#<br> 95#�For�ARM<br> 96export�AR=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ar<br> 97export�LD=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ld<br> 98export�CC=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc<br> 99<br> 100#�For�x86<br> 101export�AR=$NDKROOT/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-android-linux-ar<br> 102export�LD=$NDKROOT/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-android-linux-ld<br> 103export�CC=$NDKROOT/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-android-linux-gcc<br> 104<br> 105#�For�MIPS32<br> 106export�AR=$NDKROOT/toolchains/mipsel-linux-android-4.8/prebuilt/linux-x86_64/bin/mipsel-linux-android-ar<br> 107export�LD=$NDKROOT/toolchains/mipsel-linux-android-4.8/prebuilt/linux-x86_64/bin/mipsel-linux-android-ld<br> 108export�CC=$NDKROOT/toolchains/mipsel-linux-android-4.8/prebuilt/linux-x86_64/bin/mipsel-linux-android-gcc<br> 109<br> 110#�For�ARM64�(AArch64)<br> 111export�AR=$NDKROOT/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-ar�<br> 112export�LD=$NDKROOT/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-ld<br> 113export�CC=$NDKROOT/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-gcc<br> 114<br> 115<br> 116#�Do�configuration�stuff.��Don't�mess�with�the�--prefix�in�the<br> 117#�configure�command�below,�even�if�you�think�it's�wrong.<br> 118#�You�may�need�to�set�the�--with-tmpdir�path�to�something<br> 119#�different�if�/sdcard�doesn't�work�on�the�device�--�this�is<br> 120#�a�known�cause�of�difficulties.<br> 121<br> 122#�The�below�re-generates�configure,�Makefiles,�...<br> 123#�This�is�not�needed�if�you�start�from�a�release�tarball.<br> 124./autogen.sh<br> 125<br> 126#�for�ARM<br> 127CPPFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm"�\<br> 128���CFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm"�\<br> 129���./configure�--prefix=/data/local/Inst�\<br> 130���--host=armv7-unknown-linux�--target=armv7-unknown-linux�\<br> 131���--with-tmpdir=/sdcard<br> 132#�note:�on�android�emulator,�android-14�platform�was�also�tested�and�works.<br> 133#�It�is�not�clear�what�this�platform�nr�really�is.<br> 134<br> 135#�for�x86<br> 136CPPFLAGS="--sysroot=$NDKROOT/platforms/android-9/arch-x86"�\<br> 137���CFLAGS="--sysroot=$NDKROOT/platforms/android-9/arch-x86�-fno-pic"�\<br> 138���./configure�--prefix=/data/local/Inst�\<br> 139���--host=i686-android-linux�--target=i686-android-linux�\<br> 140���--with-tmpdir=/sdcard<br> 141<br> 142#�for�MIPS32<br> 143CPPFLAGS="--sysroot=$NDKROOT/platforms/android-18/arch-mips"�\<br> 144���CFLAGS="--sysroot=$NDKROOT/platforms/android-18/arch-mips"�\<br> 145���./configure�--prefix=/data/local/Inst�\<br> 146���--host=mipsel-linux-android�--target=mipsel-linux-android�\<br> 147���--with-tmpdir=/sdcard<br> 148<br> 149#�for�ARM64�(AArch64)<br> 150CPPFLAGS="--sysroot=$NDKROOT/platforms/android-21/arch-arm64"�\<br> 151���CFLAGS="--sysroot=$NDKROOT/platforms/android-21/arch-arm64"�\<br> 152���./configure�--prefix=/data/local/Inst�\<br> 153���--host=aarch64-unknown-linux�--target=aarch64-unknown-linux�\<br> 154���--with-tmpdir=/sdcard<br> 155<br> 156<br> 157#�At�the�end�of�the�configure�run,�a�few�lines�of�details<br> 158#�are�printed.��Make�sure�that�you�see�these�two�lines:<br> 159#<br> 160#�For�ARM:<br> 161#����������Platform�variant:�android<br> 162#�����Primary�-DVGPV�string:�-DVGPV_arm_linux_android=1<br> 163#<br> 164#�For�x86:<br> 165#����������Platform�variant:�android<br> 166#�����Primary�-DVGPV�string:�-DVGPV_x86_linux_android=1<br> 167#<br> 168#�For�mips32:<br> 169#����������Platform�variant:�android<br> 170#�����Primary�-DVGPV�string:�-DVGPV_mips32_linux_android=1<br> 171#<br> 172#�For�ARM64�(AArch64):<br> 173#����������Platform�variant:�android<br> 174#�����Primary�-DVGPV�string:�-DVGPV_arm64_linux_android=1<br> 175#<br> 176#�If�you�see�anything�else�at�this�point,�something�is�wrong,�and<br> 177#�either�the�build�will�fail,�or�will�succeed�but�you'll�get�something<br> 178#�which�won't�work.<br> 179<br> 180<br> 181#�Build,�and�park�the�install�tree�in�`pwd`/Inst<br> 182#<br> 183make�-j4<br> 184make�-j4�install�DESTDIR=`pwd`/Inst<br> 185<br> 186<br> 187#�To�get�the�install�tree�onto�the�device:<br> 188#�(I�don't�know�why�it's�not�"adb�push�Inst�/data/local",�but�this<br> 189#�formulation�does�appear�to�put�the�result�in�/data/local/Inst.)<br> 190#<br> 191adb�push�Inst�/<br> 192<br> 193<br> 194#�To�run�(on�the�device).��There�are�two�things�you�need�to�consider:<br> 195#<br> 196#�(1)�if�you�are�running�on�the�Android�emulator,�Valgrind�may�crash<br> 197#�����at�startup.��This�is�because�the�emulator�(for�ARM)�may�not�be<br> 198#�����simulating�a�hardware�TLS�register.��To�get�around�this,�run<br> 199#�����Valgrind�with:<br> 200#�������--kernel-variant=android-no-hw-tls<br> 201#�<br> 202#�(2)�if�you�are�running�a�real�device,�you�need�to�tell�Valgrind<br> 203#�����what�GPU�it�has,�so�Valgrind�knows�how�to�handle�custom�GPU<br> 204#�����ioctls.��You�can�choose�one�of�the�following:<br> 205#�������--kernel-variant=android-gpu-sgx5xx�����#�PowerVR�SGX�5XX�series<br> 206#�������--kernel-variant=android-gpu-adreno3xx��#�Qualcomm�Adreno�3XX�series<br> 207#�����If�you�don't�choose�one,�the�program�will�still�run,�but�Memcheck<br> 208#�����may�report�false�errors�after�the�program�performs�GPU-specific�ioctls.<br> 209#<br> 210#�Anyway:�to�run�on�the�device:<br> 211#<br> 212/data/local/Inst/bin/valgrind�[kernel�variant�args]�[the�usual�args�etc]<br> 213<br> 214<br> 215#�Once�you're�up�and�running,�a�handy�modify-V-rebuild-reinstall<br> 216#�command�line�(on�the�host,�of�course)�is<br> 217#<br> 218mq�-j2�&&�mq�-j2�install�DESTDIR=`pwd`/Inst�&&�adb�push�Inst�/<br> 219#<br> 220#�where�'mq'�is�an�alias�for�'make�--quiet'.<br> 221<br> 222<br> 223#�One�common�cause�of�runs�failing�at�startup�is�the�inability�of<br> 224#�Valgrind�to�find�a�suitable�temporary�directory.��On�the�device,<br> 225#�there�doesn't�seem�to�be�any�one�location�which�we�always�have<br> 226#�permission�to�write�to.��The�instructions�above�use�/sdcard.��If<br> 227#�that�doesn't�work�for�you,�and�you're�Valgrinding�one�specific<br> 228#�application�which�is�already�installed,�you�could�try�using�its<br> 229#�temporary�directory,�in�/data/data,�for�example<br> 230#�/data/data/org.mozilla.firefox_beta.<br> 231#<br> 232#�Using�/system/bin/logcat�on�the�device�is�helpful�for�diagnosing<br> 233#�these�kinds�of�problems.<br> 234<br> 235����</p></div> 236</div> 237<div> 238<br><table class="nav" width="100%" cellspacing="3" cellpadding="2" border="0" summary="Navigation footer"> 239<tr> 240<td rowspan="2" width="40%" align="left"> 241<a accesskey="p" href="dist.readme-s390.html"><<�8.�README.S390</a>�</td> 242<td width="20%" align="center"><a accesskey="u" href="dist.html">Up</a></td> 243<td rowspan="2" width="40%" align="right">�<a accesskey="n" href="dist.readme-android_emulator.html">10.�README.android_emulator�>></a> 244</td> 245</tr> 246<tr><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td></tr> 247</table> 248</div> 249</body> 250</html> 251