Android build device list

mvaisakh / Bringup.md

A small Device Tree Bringup Guide

So, you guys might be wondering, how do these «Developers» get your favourite Custom roms, such as LineageOS, Paranoid Android etc., to their own devices. Well I’m here to Guide you on how to do it, specifically on how to bringup or make your own device tree from scratch or adapting.

Gist of this Guide: This is for people with genuine interest in Android OS porting/development. After going through this guide, you should be able to do a total device tree bringup on your own.

Prerequisite: Certain requirements are to be met before you start with this amazing journey.

A brain (The most important part)

A computer/server powerful enough to build android roms (Out of the scope of this guide, though you should check out minimum specifications required to build android from AOSP)

Basic text editing.

A way around Android Build system

Familiarity with Linux/MacOS Command Line Interface

Note: I assume that you already know about Linux directories and Android Build System (How Android.mk works, etc.), which to be explained is out of the scope of this guide.

Note 2: This guide applies to devices that were launched with Project Treble enabled (Android Oreo 8.0+), devices launched without it, are not supported on this thread.

Note 3: I’d be specifically talking about a Qualcomm Device (Snapdragon SDM660 based device, launched with Android Oreo 8.1.0) as a reference on this guide. I’m really not experienced with MediaTek or other SoCs device trees , if anyone knows about them, feel free to add a reply to this thread.

Note 4: This guide uses Paranoid Android as the Android Rom Build System. Each and every rom has a different/unique base. This rom here is based on CodeAuroraForum (CAF) Collaborative Project.

For refreshing, android device trees are certain bits of makefile code (also has certain other parts), that allows the Android Build system to recognise the target device specifications to build for, and what all to be built with it.

According to the Google’s conventions, a device is usually placed in a specific location:

There’s a script located in device/common to populate the basic makefiles according to the format I specified above. But, it’s better to do it manually to have a better understanding and learning on how to do it. Understanding Basic Structure of the device tree

When we look at certain device trees, there are certain files and folders we come across, as you can see here

Let’s break these down:

  • Android.mk: This is the most basic makefile definition for any path to be included in the android build system. This makefiles calls for all other makefiles present in the directory and subdirectories of the device tree. The basic use of this specific makefile is to guard the device tree makefile when not building for our target device.
  • BoardConfig.mk: This contains the Board (SoC/Chipset) specific definition, such as the architecture (arm, arm64, x86, etc.), required build flags and kernel build flags. The flags in these aid during building.
  • device.mk: This makefile contains all the build targets and copy specifications (Such as audio configs, feature configs, etc.). If you want a certain package to be built inline with android rom builds, this where you’d want to define it. The vendor tree makefiles are also called from here.
  • README.md: Contains the basic info about the device. It’s always good to have documentation.
  • config.fs: Read more about it on AOSP.
  • extract-files.sh, setup-makefiles.sh & proprietary-files.txt: These files are linked to each other. These are used to extract proprietary blobs from a device and/or from a stock rom dump. Proprietary-files.txt is a list of proprietary (Non-opensource or blobs with proprietary OEM modifications) binaries, which is to be extracted and pushed to vendor tree. Read more about it from LineageOS Wiki.
  • props.mk or any .prop: These contain the specifications needed for build.prop or commonly known as runtime properties.
  • framework-manifest.xml: These are HIDL manifest required by the system framework features and HAL features to work. Read more about them at AOSP.
  • rootdir directory: This contains the major init scripts that are executed during boot time. These are usually found in etc/ dir of /system and /vendor partition.
  • sepolicy directory: This folder contains the specific SELinux policies that are required for the Mandatory Access Control (MAC). Read more about it on AOSP.
  • overlay: This is an important directory. This contains all the framework additions and removals (Since the android framework is largely based on Java, Kotlin and XML, framework configs are controlled from xmls in overlays rather than flags in BoardConfig.mk).
  • aosp_device-name.mk: This is a common makefile found in most AOSP trees. This specific makefile defines device name and manufacturer and build product details. This makefile for my device can be found in Paranoid Android vendor repo (As I mentioned earlier, every rom has their base, which can also mean they have their own way of including device trees)
  • AndroidProducts.mk: This makefile includes the device specific makefiles, i.e., the above mentioned aosp_device codename.mk on lunching (term used to initialise device trees for build). This makefile also defines the lunch target (Android 10+).
Читайте также:  New facebook on android

Now that we know what the Android Device tree are made up of, let’s move on ahead with actually getting our device tree up!

You’ll need to figure out the codename of the device by looking at the build number or reading the build.prop or checking out the stock rom dump.

Since I have a qualcomm device, I started digging into CAF OSS board trees, they have certain codenames for their boards (sdm660 is called falcon), you should be able to find them by a google search. If you can’t find your Board OSS tree, there’s a high chance that it uses a major board type for your specific board (eg., msm8937 uses thorium trees, and since then, sdm450 etc., have used thorium as their base tree). You should take a look at the Board trees present here.

Now my tree here is falcon_64 (64 suffix is here because it’s an arm64 device, your board may or may not have it). Open the OSS Board Tree git repository, and use the tag/branch that matches your android version that you want to bring up. note: CAF tags starting with LA.UM.7.x are Android 9.0 pie, LA.UM.8.x are Android 10, and so on.

Now what we need to do is, create the above mentioned files in the device tree. (It’s better to initialise a repository beforehand)

Starting with Android.mk, we’d need to add the guard conditions (using ifeq ) that should be like:

This means that only if the TARGET_DEVICE variable is set to your device, it will start including this device tree, else this tree would be ignored.

My device’s codename here is X01BD

You should also add an inclusion command so that all other makefiles in the sub directory are included, such as:

Basic Android.mk structure is done!

Moving on to BoardConfig.mk, we need to add architecture specifications, this is where the OSS Board Tree comes in handy, as you can just take all the flags from there. So, almost all the BoardConfig flags are written in a specific format, i.e.,

Note: The ‘#’ here is a comment.

Copy most of the flags from the Board OSS tree, for reference use my BoardConfig to check what to copy and what not to copy. Most of the flags should be similar. Note: Kernel flags may or may not be same across different boards. Make sure you get the proper ones. And additional flag that you might want to add is

This is to allow the selinux to be permissive and help us boot avoiding selinux shenanigans. You should also look into other .mk files for specific flags in the Board OSS tree.

Источник

Android ABIs

Different Android devices use different CPUs, which in turn support different instruction sets. Each combination of CPU and instruction set has its own Application Binary Interface (ABI). An ABI includes the following information:

  • The CPU instruction set (and extensions) that can be used.
  • The endianness of memory stores and loads at runtime. Android is always little-endian.
  • Conventions for passing data between applications and the system, including alignment constraints, and how the system uses the stack and registers when it calls functions.
  • The format of executable binaries, such as programs and shared libraries, and the types of content they support. Android always uses ELF. For more information, see ELF System V Application Binary Interface.
  • How C++ names are mangled. For more information, see Generic/Itanium C++ ABI.

This page enumerates the ABIs that the NDK supports, and provides information about how each ABI works.

ABI can also refer to the native API supported by the platform. For a list of those kinds of ABI issues affecting 32-bit systems, see 32-bit ABI bugs.

Читайте также:  Gps адаптер для android

Supported ABIs

Table 1. ABIs and supported instruction sets.

ABI Supported Instruction Sets Notes
armeabi-v7a
  • armeabi
  • Thumb-2
  • VFPv3-D16
  • Incompatible with ARMv5/v6 devices.
    arm64-v8a
  • AArch64
  • x86
  • x86 (IA-32)
  • MMX
  • SSE/2/3
  • SSSE3
  • No support for MOVBE or SSE4.
    x86_64
  • x86-64
  • MMX
  • SSE/2/3
  • SSSE3
  • SSE4.1, 4.2
  • POPCNT
  • Note: Historically the NDK supported ARMv5 (armeabi), and 32-bit and 64-bit MIPS, but support for these ABIs was removed in NDK r17.

    armeabi-v7a

    This ABI is for 32-bit ARM-based CPUs. The Android variant includes Thumb-2 and the VFP hardware floating point instructions, specifically VFPv3-D16, which includes 16 dedicated 64-bit floating point registers.

    For information about the parts of the ABI that aren’t Android-specific, see Application Binary Interface (ABI) for the ARM Architecture

    The NDK’s build systems generate Thumb-2 code by default unless you use LOCAL_ARM_MODE in your Android.mk for ndk-build or ANDROID_ARM_MODE when configuring CMake.

    Other extensions including Advanced SIMD (Neon) and VFPv3-D32 are optional. For more information, see Neon Support.

    The armeabi-v7a ABI uses -mfloat-abi=softfp to enforce the rule that, although system can execute floating-point code, the compiler must pass all float values in integer registers and all double values in integer register pairs when making function calls.

    arm64-v8a

    This ABI is for ARMv8-A based CPUs, which support the 64-bit AArch64 architecture. It includes the Advanced SIMD (Neon) architecture extensions.

    You can use Neon intrinsics in C and C++ code to take advantage of the Advanced SIMD extension. The Neon Programmer’s Guide for Armv8-A provides more information about Neon intrinsics and Neon programming in general.

    See Arm’s Learn the Architecture for complete details of the parts of the ABI that aren’t Android-specific. Arm also offers some porting advice in 64-bit Android Development.

    On Android, the platform-specific x18 register is reserved for ShadowCallStack and should not be touched by your code. Current versions of Clang default to using the -ffixed-x18 option on Android, so unless you have hand-written assembler (or a very old compiler) you shouldn’t need to worry about this.

    This ABI is for CPUs supporting the instruction set commonly known as «x86», «i386», or «IA-32». Characteristics of this ABI include:

      Instructions normally generated by GCC with compiler flags such as the following:

    These flags target the Pentium Pro instruction set, along with the the MMX, SSE, SSE2, SSE3, and SSSE3 instruction set extensions. The generated code is an optimization balanced across the top Intel 32-bit CPUs.

    For more information on compiler flags, particularly related to performance optimization, refer to GCC x86 Performance Hints.

  • Use of the standard Linux x86 32-bit calling convention, as opposed to the one for SVR. For more information, see section 6, «Register Usage», of Calling conventions for different C++ compilers and operating systems.
  • The ABI does not include any other optional IA-32 instruction set extensions, such as:

    You can still use these extensions, as long as you use runtime feature-probing to enable them, and provide fallbacks for devices that do not support them.

    The NDK toolchain assumes 16-byte stack alignment before a function call. The default tools and options enforce this rule. If you are writing assembly code, you must make sure to maintain stack alignment, and ensure that other compilers also obey this rule.

    Refer to the following documents for more details:

    x86_64

    This ABI is for CPUs supporting the instruction set commonly referred to as «x86-64.» It supports instructions that GCC typically generates with the following compiler flags:

    These flags target the x86-64 instruction set, according to the GCC documentation. along with the MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, and POPCNT instruction-set extensions. The generated code is an optimization balanced across the top Intel 64-bit CPUs.

    For more information on compiler flags, particularly related to performance optimization, refer to GCC x86 Performance Hints.

    This ABI does not include any other optional x86-64 instruction set extensions, such as:

    You can still use these extensions, as long as you use runtime feature probing to enable them, and provide fallbacks for devices that do not support them.

    Refer to the following documents for more details:

    Generate code for a specific ABI

    Gradle

    Gradle (whether used via Android Studio or from the command line) builds for all non-deprecated ABIs by default. To restrict the set of ABIs that your application supports, use abiFilters . For example, to build for only 64-bit ABIs, set the following configuration in your build.gradle :

    ndk-build

    ndk-build builds for all non-deprecated ABIs by default. You can target a specific ABIs by setting APP_ABI in your Application.mk file. The following snippet shows a few examples of using APP_ABI :

    For more information on the values you can specify for APP_ABI , see Application.mk.

    CMake

    With CMake, you build for a single ABI at a time and must specify your ABI explicitly. You do this with the ANDROID_ABI variable, which must be specified on the command line (cannot be set in your CMakeLists.txt). For example:

    For the other flags that must be passed to CMake to build with the NDK, see the CMake guide.

    The default behavior of the build system is to include the binaries for each ABI in a single APK, also known as a fat APK. A fat APK is significantly larger than one containing only the binaries for a single ABI; the tradeoff is gaining wider compatibility, but at the expense of a larger APK. It is strongly recommended that you take advantage of either App Bundles or APK Splits to reduce the size of your APKs while still maintaining maximum device compatibility.

    At installation time, the package manager unpacks only the most appropriate machine code for the target device. For details, see Automatic extraction of native code at install time.

    ABI management on the Android platform

    This section provides details about how the Android platform manages native code in APKs.

    Native code in app packages

    Both the Play Store and Package Manager expect to find NDK-generated libraries on filepaths inside the APK matching the following pattern:

    Here, is one of the ABI names listed under Supported ABIs, and is the name of the library as you defined it for the LOCAL_MODULE variable in the Android.mk file. Since APK files are just zip files, it is trivial to open them and confirm that the shared native libraries are where they belong.

    If the system does not find the native shared libraries where it expects them, it cannot use them. In such a case, the app itself has to copy the libraries over, and then perform dlopen() .

    In a fat APK, each library resides under a directory whose name matches a corresponding ABI. For example, a fat APK may contain:

    Note: ARMv7-based Android devices running 4.0.3 or earlier install native libraries from the armeabi directory instead of the armeabi-v7a directory if both directories exist. This is because /lib/armeabi/ comes after /lib/armeabi-v7a/ in the APK. This issue is fixed from 4.0.4.

    Android platform ABI support

    The Android system knows at runtime which ABI(s) it supports, because build-specific system properties indicate:

    • The primary ABI for the device, corresponding to the machine code used in the system image itself.
    • Optionally, secondary ABIs, corresponding to other ABI that the system image also supports.

    This mechanism ensures that the system extracts the best machine code from the package at installation time.

    For best performance, you should compile directly for the primary ABI. For example, a typical ARMv5TE-based device would only define the primary ABI: armeabi . By contrast, a typical, ARMv7-based device would define the primary ABI as armeabi-v7a and the secondary one as armeabi , since it can run application native binaries generated for each of them.

    64-bit devices also support their 32-bit variants. Using arm64-v8a devices as an example, the device can also run armeabi and armeabi-v7a code. Note, however, that your application will perform much better on 64-bit devices if it targets arm64-v8a rather than relying on the device running the armeabi-v7a version of your application.

    Many x86-based devices can also run armeabi-v7a and armeabi NDK binaries. For such devices, the primary ABI would be x86 , and the second one, armeabi-v7a .

    You can force install an apk for a specific ABI. This is useful for testing. Use the following command:

    Automatic extraction of native code at install time

    When installing an application, the package manager service scans the APK, and looks for any shared libraries of the form:

    If none is found, and you have defined a secondary ABI, the service scans for shared libraries of the form:

    When it finds the libraries that it’s looking for, the package manager copies them to /lib/lib .so , under the application’s native library directory ( / ). The following snippets retrieve the nativeLibraryDir :

    Kotlin

    If there is no shared-object file at all, the application builds and installs, but crashes at runtime.

    Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.

    Источник

    Читайте также:  Заводское меню для андроид
    Оцените статью