Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) How to compile perf for Android
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) =========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) I. Set the Android NDK environment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) ------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) (a). Use the Android NDK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) ------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 1. You need to download and install the Android Native Development Kit (NDK).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) Set the NDK variable to point to the path where you installed the NDK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)   export NDK=/path/to/android-ndk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 2. Set cross-compiling environment variables for NDK toolchain and sysroot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) For arm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)   export NDK_TOOLCHAIN=${NDK}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)   export NDK_SYSROOT=${NDK}/platforms/android-24/arch-arm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) For x86:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)   export NDK_TOOLCHAIN=${NDK}/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)   export NDK_SYSROOT=${NDK}/platforms/android-24/arch-x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) This method is only tested for Android NDK versions Revision 11b and later.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) perf uses some bionic enhancements that are not included in prior NDK versions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) You can use method (b) described below instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) (b). Use the Android source tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) -----------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 1. Download the master branch of the Android source tree.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) Set the environment for the target you want using:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)   source build/envsetup.sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)   lunch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 2. Build your own NDK sysroot to contain latest bionic changes and set the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) NDK sysroot environment variable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)   cd ${ANDROID_BUILD_TOP}/ndk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) For arm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)   ./build/tools/build-ndk-sysroot.sh --abi=arm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)   export NDK_SYSROOT=${ANDROID_BUILD_TOP}/ndk/build/platforms/android-3/arch-arm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) For x86:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)   ./build/tools/build-ndk-sysroot.sh --abi=x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)   export NDK_SYSROOT=${ANDROID_BUILD_TOP}/ndk/build/platforms/android-3/arch-x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 3. Set the NDK toolchain environment variable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) For arm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)   export NDK_TOOLCHAIN=${ANDROID_TOOLCHAIN}/arm-linux-androideabi-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) For x86:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)   export NDK_TOOLCHAIN=${ANDROID_TOOLCHAIN}/i686-linux-android-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) II. Compile perf for Android
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) ------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) You need to run make with the NDK toolchain and sysroot defined above:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) For arm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)   make WERROR=0 ARCH=arm CROSS_COMPILE=${NDK_TOOLCHAIN} EXTRA_CFLAGS="-pie --sysroot=${NDK_SYSROOT}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) For x86:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)   make WERROR=0 ARCH=x86 CROSS_COMPILE=${NDK_TOOLCHAIN} EXTRA_CFLAGS="-pie --sysroot=${NDK_SYSROOT}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) III. Install perf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) -----------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) You need to connect to your Android device/emulator using adb.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) Install perf using:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)   adb push perf /data/perf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) If you also want to use perf-archive you need busybox tools for Android.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) For installing perf-archive, you first need to replace #!/bin/bash with #!/system/bin/sh:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)   sed 's/#!\/bin\/bash/#!\/system\/bin\/sh/g' perf-archive >> /tmp/perf-archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)   chmod +x /tmp/perf-archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)   adb push /tmp/perf-archive /data/perf-archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) IV. Environment settings for running perf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) ------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) Some perf features need environment variables to run properly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) You need to set these before running perf on the target:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)   adb shell
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)   # PERF_PAGER=cat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) IV. Run perf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) ------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) Run perf on your device/emulator to which you previously connected using adb:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)   # ./data/perf