Android one device tree

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+).
Читайте также:  Mazda tweak android auto

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 one device tree

Unified Device Tree for Android One Second Generation (seed)

Basic Specification List
CPU Quad-core 1.2 GHz ARM® Cortex™ A53
CHIPSET Qualcomm MSM8916 Snapdragon 410
GPU Adreno 306
Memory 2 GB
Shipped Android Version 5.1.1
Storage 16 GB
MicroSD Up to 128 GB
Battery 2500 mAh (removable)
Display 720 x 1280 pixels, 5″ (294ppi)
Rear Camera 13.0 MP Dual-Flash
Front Camera 5.0 MP

About

Android One Second Generation (seed) device tree, based on Wileyfox Swift (crackling)

Resources

Releases

Packages 0

Languages

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

Источник

How to create Device tree for Android Rom building

jai44

Member

How to create Device tree for Android Rom building

I assume you already downloaded source code

before we start please do following

1. Install unpackbootimg

Go to https://github.com/jsharma44/bootimg-tools and download as a zip or use git clone command.

extract files
cd directory
make

now you will find unpackbootimg and mkbootimg in this directory

2. copy unpackbootimg and mkbootimg to /usr/bin

sudo cp unpackbootimg /usr/bin
sudo cp mkbootimg /usr/bin

Note this is necessary if you are getting error

” “unpackbootimg not found. Is your android build environment set up and have the host tools been built?

3. Extracting boot.img from your device

1. A rooted phone
2. Enable Usb Debugging in Developer Mode
3. ADB command knowldge

connect your phone via usb cable ensure that usb debugging is enabled
open terminal and type adb devices

if it is showing your device’s serial no than we are ready to go

ls -l /dev/block/platform/mtk-msdc.0/11230000.msdc0/by-name

please note this command may vary by device to device. What we are doing here we want to know partition scheme of your device.

note down block name of /boot partition

example it will be like boot -> /dev/block/mmcblk0p7

dd if=/dev/block/mmcblk0p7 of=/sdcard/boot.img

now boot.img succesfully transfered to your SD card Copy it to your Desktop

now path should be /home/user/Desktop/boot.img or similar but remeber path name alternatively you can type pwd in terminal to know this

cd to your working directory

Syntex: ./build/tools/device/mkvendor.sh Vendor-Name Device-CodeName

/Path to your/boot.img

Example:
./build/tools/device/mkvendor.sh GIONEE GIONEE_WBL7511

Now it will create following file in /device/Vender-Name/Device_CodeName

AndroidBoard.mk
cm.mk
recovery.fstab
AndroidProducts.mk
device_GIONEE_WBL7511.mk
system.prop
BoardConfig.mk
kernel

Note1: Please creater vendorsetup.mk file in this directory manualy. To use source build/envsetup.sh

Note2: Please double check BoardConfig.mk file and ensure every partition size is correct in this file. Also check recovery.fstab showing correct mount point

Note3: Here kernel is prebuilt kernel. If you want to compile kernel as well as download your kernel source in /kernel/Vender-Name/Device_CodeName dirtectory. You will find kernel related config in BoardConfig.mk

Please note it will not create vendorsetup.sh file and following Directory
1./vendor/Vender-Name/Device_CodeName
2. /kernel/Vender-Name/Device_CodeName

Wait for next post for more info

FeyoMx

Senior Member

Thank you very much for the tutorial I will try to do it

Enviado desde mi A7010a48 mediante Tapatalk

opticyclic

Senior Member

Are you ready with the post about creating the vendor tree?

Darkness1

Member

daser4ever96

Member

Thank you for this great tut, but I have a noob error that I couldn’t found «mkbootimg» and «unpackbootimg» in «/bootimg-tools-master» folder
But in «/bootimg-tools-master/mkbootimg» I found «bootimg.h, mkbootimg, mkbootimg.c, mkbootimg.o, unmkbootimg, unmkbootimg.c, unmkbootimg.o»

Also, I have read your note:
Note this is necessary if you are getting error
” “unpackbootimg not found. Is your android build environment set up and have the host tools been built?

but I couldn’t figure out what to do to check that
Additional info. : I am doing that to build a LineageOS Rom

theGeekyLad

Senior Member

Tree and API dependance

Amazing tutorial yet a small query — are the device (and vendor) trees android version dependant?

Could I use the boot.img of say Android 6.0 for building a 7.0 Nougat based ROM?

adityaparmar07

Member

i am getting errors !

How to create Device tree for Android Rom building

I assume you already downloaded source code

before we start please do following

1. Install unpackbootimg

Go to https://github.com/jsharma44/bootimg-tools and download as a zip or use git clone command.

extract files
cd directory
make

now you will find unpackbootimg and mkbootimg in this directory

2. copy unpackbootimg and mkbootimg to /usr/bin

sudo cp unpackbootimg /usr/bin
sudo cp mkbootimg /usr/bin

Note this is necessary if you are getting error

” “unpackbootimg not found. Is your android build environment set up and have the host tools been built?

3. Extracting boot.img from your device

1. A rooted phone
2. Enable Usb Debugging in Developer Mode
3. ADB command knowldge

connect your phone via usb cable ensure that usb debugging is enabled
open terminal and type adb devices

if it is showing your device’s serial no than we are ready to go

ls -l /dev/block/platform/mtk-msdc.0/11230000.msdc0/by-name

please note this command may vary by device to device. What we are doing here we want to know partition scheme of your device.

note down block name of /boot partition

example it will be like boot -> /dev/block/mmcblk0p7

dd if=/dev/block/mmcblk0p7 of=/sdcard/boot.img

now boot.img succesfully transfered to your SD card Copy it to your Desktop

now path should be /home/user/Desktop/boot.img or similar but remeber path name alternatively you can type pwd in terminal to know this

cd to your working directory

Syntex: ./build/tools/device/mkvendor.sh Vendor-Name Device-CodeName

/Path to your/boot.img

Example:
./build/tools/device/mkvendor.sh GIONEE GIONEE_WBL7511

Now it will create following file in /device/Vender-Name/Device_CodeName

Источник

Читайте также:  Инструкция для quik android
Оцените статью