Flash fastboot ROM without a computer (ARM built android to another android ) - Android Software/Hacking General [Developers Only]

Hello guys...
This is first tutorial post here for me....
Please give a feedback about how am I been able to help you....any suggestions are always welcome.
Today I am presenting an approach how to flash a fastboot from without a PC.
In this section I am providing an fastboot binary file which has prepared by KMyers in XDA.
What You need
1. One rooted android phone (say dev 1) with ARM processor only, instead of a PC.
additional features required in this phone is ES file explorer (or any other), .tgz extractor, terminal emulator (attached here).
2. fastboot rom fully downloaded.
3. another device (say devi 2)matching with downloaded fastboot rom (this device will be flashed).
3. Some files I attached in this thread.
4. USB data cable + USB OTG cable.
Steps
1. make the file system ready at dev 1 (rooted android which will be used instead of a PC)a. install es file, terminal emulator and allow root access. install 7zip extractor.
b. take the downloaded fastboot rom and extract it thru zip extractor, rename the extracted file as fastbootrom for easiness and put it at internal storage.
c. download the attached fastboot.zip, extract it. copy the fastboot binary file and paste it to /system/xbin or /system/bin. set permission to the file as -rwxrwxrwx. This file will be responsible for flashing the dev 2 device.
d. there are script files like flash_all.sh, flash_all_except_data-storage.sh etc which are self explanatory.
we will run this script file with su permission at terminal during flashing.
3. hardware connection
connect the OTG cable to dev1 , connect the usb data cable to dev 2. Now connect the usb data cable to OTG cable female part.
thats it. connection is ready.
4. edit the script file
If you want, you can edit the script file flash-all.sh in any text editor as per your choice, but be very carefull in this section. better leave it as it is. Personally what I do is, I replace the recovery.img in fastboot rom/images/ with twrp.img of the same device, and rename twrp.img as recovery.img.
Then at last line instead of fastboot reboot, I put fastboot $* boot `dirname $0`/images/recovery.img. This will reboot he device after flashing into twrp first time. Simply flash supersu etc from twrp then reboot the device in one shot directly rooted.
5. flash
a. open the terminal
type su and enter. allow root permission if required.
b. change the working directory to fastboot rom by
cd storage/emulated/0/fastbootrom/ this command is for my xiaomi redmi3sprime & MI4. change the path according to your device.
now choose the edited script file for flashing. say it is flash_all.sh ( I prefer flash_all_except_data_storage_.sh) remember dont take flash_all.bat file. That is for windows system. Now we will be flashing from android device and it is similer to linux platform.
c. start the dev 2 in fastboot mode, connect it to data cable. connect OTG cable to dev 1. connect OTG female part+data cable male part.
d. execute in terminal fastboot devices you will see the list of devices like 0e34cdf5 fastboot.
f. if the device is showing in fastboot mode then voila....you are mostly done. Before flashing ensure at least 50% battery in both device.
g. Now execute the script file by
sh flash_all_except_data_storage_.sh you will find the flashing details will be displayed in your android dev 1 terminal.
If flash is successful......reboot / root / do whatever you like.
remember first boot after flash takes long time may be 30 minutes or more...so be patient..better leave it in charging and rebooting for 1 hr.
Leave a comment if you do all things successfully....and rate me.
The resources used here are collected from different free sources like apkmirror.com. xda-developer.com.
I personally thanks to KMyers for making the fastboot binary for arm processor, full credit goes to him for that.
Thanks to chainfire for su binary.
BN P
Long live open source.
Love open source and Hate those, who hide their content.

attached files are here...
due to site rules I cant upload esfile.apk and 7zipper.apk...
those are available in playstore for free...
BN P
Long live open source.
Love open source and Hate those, who hide their content.

Impressive, ill check it out, let u know my experience
Sent from my XT830C using XDA Labs

BTW This post has nothing to do with open source, I don't even see the source. FWIW I just have no faith in people in this forum using source at all. Here I'll post the Android.mk i used to build fastboot statically for arm a year or so ago, it will have to be adapted to the new fastboot source since its no longer in C and instead is C++. Id be very impressed if anyone even uses it. You'll quickly see why it's useless to post items on xda in the name of open source.
Code:
# Copyright (C) 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../mkbootimg \
$(LOCAL_PATH)/../../extras/ext4_utils
LOCAL_SRC_FILES := \
protocol.c \
engine.c \
bootimg.c \
fastboot.c
LOCAL_MODULE := fastboot
LOCAL_MODULE_TAGS := debug
ifeq ($(HOST_OS),linux)
LOCAL_SRC_FILES += usb_linux.c util_linux.c
endif
ifeq ($(HOST_OS),darwin)
LOCAL_SRC_FILES += usb_osx.c util_osx.c
LOCAL_LDLIBS += -framework CoreFoundation -framework IOKit \
-framework Carbon
endif
ifeq ($(HOST_OS),windows)
LOCAL_SRC_FILES += usb_windows.c util_windows.c
EXTRA_STATIC_LIBS := AdbWinApi
ifneq ($(strip $(USE_CYGWIN)),)
# Pure cygwin case
LOCAL_LDLIBS +=
LOCAL_C_INCLUDES += /usr/include/w32api/ddk
endif
ifneq ($(strip $(USE_MINGW)),)
# MinGW under Linux case
LOCAL_LDLIBS += -lws2_32
USE_SYSDEPS_WIN32 := 1
LOCAL_C_INCLUDES += /usr/i586-mingw32msvc/include/ddk
endif
LOCAL_C_INCLUDES += development/host/windows/usb/api
endif
LOCAL_STATIC_LIBRARIES := \
$(EXTRA_STATIC_LIBS) \
libselinux \
liblog \
libutils \
libcutils \
libzipfile \
libunz \
libext4_utils_host \
libsparse \
libziparchive \
libbase \
libz
ifneq ($(HOST_OS),windows)
LOCAL_STATIC_LIBRARIES += libselinux
endif # HOST_OS != windows
LOCAL_CPPFLAGS := -std=gnu89 -Wno-missing-field-initializers
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/include \
system/core/base/include \
system/core/libutils \
system/core/liblog \
system/core/libcutils \
system/extras/ext4_utils \
external/expat \
bionic/libc \
external/zlib/src \
external/libcxx/include \
external/libcxxabi/include \
system/core/libziparchive \
frameworks/base/libs/androidfw \
frameworks/base/include/androidfw
LOCAL_LDLIBS := -lc -lgcc -ldl -lm -lz -static-libgcc -lstdc++
LOCAL_CFLAGS += -O2 -D_GNU_SOURCE -g -Wall
LOCAL_MODULE_CLASS := UTILITY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT_SBIN)
LOCAL_UNSTRIPPED_PATH := $(PRODUCT_OUT)/symbols/utilities
LOCAL_LDFLAGS += -static
LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_PACK_MODULE_RELOCATIONS := false
include $(BUILD_EXECUTABLE)
if anything I'll just get questions about posting the binary, which in the name of open source, I refuse. Doesn't mean I won't tell others how I did it.
Sent from my Nexus 6P using XDA-Developers Legacy app

Surge1223 said:
BTW This post has nothing to do with open source, I don't even see the source. FWIW I just have no faith in people in this forum using source at all. Here I'll post the Android.mk i used to build fastboot statically for arm a year or so ago, it will have to be adapted to the new fastboot source since its no longer in C and instead is C++. Id be very impressed if anyone even uses it. You'll quickly see why it's useless to post items on xda in the name of open source.
if anything I'll just get questions about posting the binary, which in the name of open source, I refuse. Doesn't mean I won't tell others how I did it.
Click to expand...
Click to collapse
The binary compiled by kmyers...as i mentioned. I hv only tested it...nd found workinng fine.
The source code is available in github....go to kmyers thread.

Related

Simple HOWTO building some linux apps and libraries from scratch on android

This howto is only draft! Sometimes i went upgrade this, or make page on my site and post link on it. Also we have a project for automated building, like buildroot and opkg repository for android.
All needed configs in attached file. If you have error on unpack - just rename my.zip in my.tar.bz2 and try to unpack. Please correct me, if needed.
----------------------------------------------------------------------------------------------------------------------------------
All work will be in home directory (/home/xvilka)
create dir build
mkdir build
1. Download the kernel (for android on your version for device) and unpack
make headers_install ARCH=arm INSTALL_HDR_PATH=~/build/kern_h/
For some optimisations you need know, which proccessor (SoC) in your android-system(gcc.gnu.org/onlinedocs/gcc-4.4.3/gcc/ARM-Options.html#ARM-Options)
Im have Motorola Milestone - SoC = TI OMAP3430 - ARM Cortex a8 (arch - armv7a)
(en.wikipedia.org/wiki/ARM_architecture)
So, if you have OMAP3430-processor - use the config files with -omap3430 suffix
If you have Quallcomm MSM7200A (HTC Hero) - use the config files with -msm7200a suffix
First, we need to define _XXFLAGS, which contain some optimisation options for your compiler:
export _XXCFLAGS=" -mcpu=cortex-a8 -march=armv7-a -mtune=cortex-a8 -mfpu=vfpv3 -O3 -Os" (if you have Motorola Milestone/Droid or other device with TI OMAP3430)
export _XXCFLAGS=" -march=armv6j -mtune=arm1136jf-s -O3 -Os" (if you have HTC Hero or other device with Quallcomm MSM 7200A)
............................................................................................
If you don't know which chip you have in phone use _XXCFLAGS=" -O3 -Os"
2. Download crosstool-ng (ymorin.is-a-geek.org/dokuwiki/projects/crosstool),
unpack, build (you must have make,install,bash,cut,sed,grep,gcc,awk,bison,flex,automake,libtool,stat,
wget,cvs,patch,tar,gzip,bzip2,lzma,readlink,ncurses)
.configure
make
make install
3. Create directory toolchain-android, and copy config to this
XVilka-crosstool-<suffix>.config in .config
XVilka-uClibc-<suffix>.config in uClibc-0.9.30.2.config (or later version, if available)
and then run:
ct-ng menuconfig
you may change some options, if needed!
(Also use options from XXCFLAGS:
Target options -> Target optimizations ->
Architecture-level equal -march, use armv7-a
Emit assembly for CPU equal -mcpu, use cortex-a8
Tune for cpu equal -mtune, use cortex-a8
Use specific FPU equal -mfpu, use vfpv3
Floating point use hardware, because it built-in TI OMAP3430
Target CFLAGS - use -O3 -Os
) - for the Motorola Milestone/Droid
(Also use options from _XXCFLAGS:
Target options -> Target optimizations ->
Architecture-level equal -march, use armv6j
Emit assembly for CPU equal -mcpu, use nothing
Tune for cpu equal -mtune, use arm1136jf-s
Floating point use software
Target CFLAGS - use -O3 -Os
) - for the HTC Hero
Save in .config
In file uClibs-0.9.30.2.config
edit this strings:
{
UCLIBC_HAS_FLOATS=y
UCLIBC_HAS_FPU=y
# UCLIBC_HAS_SOFT_FLOAT=y
UCLIBC_EXTRA_CFLAGS=" -march=armv7-a -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=vfpv3 -O3 -Os"
} - for the Motorola Milestone/Droid
{
UCLIBC_HAS_FLOATS=y
#UCLIBC_HAS_FPU=y
UCLIBC_HAS_SOFT_FLOAT=y
UCLIBC_EXTRA_CFLAGS=" -march=armv6j -mtune=arm1136jf-s -O3 -Os"
} - for the HTC Hero
and then run
ct-ng build
4. Ok, done. We have installed cross - toolchain in directory build/x-tools.
And all programs in it with names arm-android-linux-uclibsgnueabi-*
For easy using add this directory in PATH:
PATH=~/build/x-tools/arm-android-linux-uclibcgnueabi/bin:$PATH
so we can run cross-gcc by the command:
arm-android-linux-uclibcgnueabi-gcc
Root directory of target system is:
~/build/x-tools/arm-android-linux-uclibcgnueabi/arm-android-linux-uclibcgnueabi/sys-root
But for the safe - make new root dir and copy files too.
Copy files in ~/build/cross/sys-root
chmod +w sys-root
chmod +w sys-root/usr
5. Building busybox (only static build, but if we have static busybox in any problems with system problems with libs
we can easy use busybox as repair-mode tool)
copy file XVilka-busybox-<suffix>.config in .config
make menuconfig
make ARCH=arm CC="arm-android-linux-uclibcgnueabi-gcc" CROSS_COMPILE="arm-android-linux-uclibcgnueabi-" \
CFLAGS=" -static $_XXFLAGS"
make install CONFIG_PREFIX=~/build/cross/sys-root
Copy ~/build/cross/sys-root/bin/busybox in /system/bin on device
chown root /system/bin/busybox
chmod 755 /system/bin/busybox
ln -s /system/bin/busybox /system/bin/ash
Or in other directory and you can install all programs included in busybox by the command:
busybox --install
7. Building simple but powerful text editor jupp (mirbsd.org/jupp.htm)
chmod +x configure
./configure --prefix=/system/local --disable-curses --disable-termcap --disable-termidx --host=arm-android-linux-uclibcgnueabi ARCH=arm \
CC="arm-android-linux-uclibcgnueabi-gcc" CROSS_COMPILE="arm-android-linux-uclibcgnueabi-" sysconfdir=/system/usr/local/etc sysconfjoesubdir=/joe \
CFLAGS=" -static $_XXFLAGS"
make
arm-android-linux-uclibcgnueabi-strip joe
On device:
copy joe in /system/bin
copy joerc in /system/usr/local/etc/joe
copy jupprc in /system/usr/local/etc/joe
copy jmacsrc in /system/usr/local/etc/joe
copy sintax files in /system/usr/local/etc/joe/syntax
chmod 755 /system/bin/joe
ln -s /system/bin/joe /system/bin/jupp
ln -s /system/bin/joe /system/bin/jmacs
chmod 644 /system/usr/local/etc/joe/joerc
chmod 644 /system/usr/local/etc/joe/jupprc
chmod 644 /system/usr/local/etc/joe/jmacsrc
before running joe we must define TERM
export TERM=ansi
8. How to use dinamic linking and shared libraries
(if we installed programs in local directory in sys-root,
so copy lib from local)
cd ~/build/cross/sys-root
tar -jcf lib.tar.bz2 lib/
And on device:
cd /system/usr/local
busybox tar -xcf /sdcard/lib.tar.bz2
For our programs, wich uses this non-standart library path we may create this script and run your programs by it:
#!/bin/sh
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
exec /usr/bin/local/some_program $*
9. Building libFLAC in shared library, which we can use easy and copy to /system/lib,
which have nothing in NEEDED - just kernel and you, also no any libc (bionic, or uClibc) not used.
Download latest version of libFLAC from the official site, unpack and cd to dir:
./autogen.sh --host=arm --target=arm-android-linux-uclibcgnueabi CC="arm-android-linux-uclibcgnueabi-gcc" \
CXX="arm-android-linux-uclibcgnueabi-g++" STRIP="arm-android-linux-uclibcgnueabi-strip" \
AR="arm-android-linux-uclibcgnueabi-ar" AS="arm-android-linux-uclibcgnueabi-as" LD="arm-android-linux-uclibcgnueabi-ld" \
RANLIB="arm-android-linux-uclibcgnueabi-ranlib" OBJDUMP="arm-android-linux-uclibcgnueabi-objdump" \
NM="arm-android-linux-uclibcgnueabi-nm" CROSS_COMPILE="arm-android-linux-uclibcgnueabi-" \
CFLAGS=" -nodefaultlibs -nostdlib -fPIC $_XXFLAGS" \
CXXFLAGS=" -nodefaultlibs -nostdlib -fPIC $_XXFLAGS" \
LDFLAGS=" -fPIC -static -s -L$HOME/build/cross/sys-root/usr/lib -lm -lc" --prefix="$HOME/build/cross/sys-root/usr" \
--disable-ogg --disable-oggtest --disable-rpath --disable-xmms-plugin --disable-cpplibs --disable-altivec \
--disable-3dnow --disable-thorough-tests --disable-doxygen-docs
cd src/libFLAC
make
cd .libs
arm-android-linux-uclibcgnueabi-ld -shared -s -o libFLAC.so -whole-archive libFLAC.a
And now we have shared library libFLAC.so, lybrary without any dependency, and which we can just copy in /system/lib
on device and use it from any program.
For programming on libFLAC you must see header files of libFLAC
10. Building xvid in shared library, without any dependecy, same as libFLAC.
cd src/build/generic
./configure --host=arm --target=arm-android-linux-uclibcgnueabi CC="arm-android-linux-uclibcgnueabi-gcc" \
CXX="arm-android-linux-uclibcgnueabi-g++" STRIP="arm-android-linux-uclibcgnueabi-strip" \
AR="arm-android-linux-uclibcgnueabi-ar" AS="arm-android-linux-uclibcgnueabi-as" \
LD="arm-android-linux-uclibcgnueabi-ld" RANLIB="arm-android-linux-uclibcgnueabi-ranlib" \
OBJDUMP="arm-android-linux-uclibcgnueabi-objdump" NM="arm-android-linux-uclibcgnueabi-nm" \
CROSS_COMPILE="arm-android-linux-uclibcgnueabi-" \
CFLAGS=" -nodefaultlibs -nostdlib -fPIC $_XXFLAGS" \
CXXFLAGS=" -nodefaultlibs -nostdlib -fPIC $_XXFLAGS" \
LDFLAGS=" -fPIC -static -s -L$HOME/build/cross/sys-root/usr/lib -lm -lc" --prefix="$HOME/build/cross/sys-root/usr"
cd =build
rm-android-linux-uclibcgnueabi-ld -shared -s -o libxvidcore.so -whole-archive libxvidcore.a
So we have libxvidcore.so, which using very-very simple and copy-only-use too.
11. Building nmap
svn co --username guest --password "" svn://svn.insecure.org/nmap/
cd nmap
./configure --host=arm-android-linux-uclibcgnueabi CC="arm-android-linux-uclibcgnueabi-gcc" \
CROSS_COMPILE="arm-android-linux-uclibcgnueabi-" CFLAGS=" -static $_XXFLAGS" \
CXXFLAGS=" -static $_XXFLAGS" \
--prefix="$HOME/build/cross/sys-root/system/usr/local" --with-lua=included --with-pcap=included --with-pcre=included --with-dnet=included
make
make install
12. Building dropbear
./configure --host=arm-android-linux-uclibcgnueabi CC="arm-android-linux-uclibcgnueabi-gcc" \
CROSS_COMPILE="arm-android-linux-uclibcgnueabi-" \
CFLAGS=" -static $_XXFLAGS" \
--prefix="$HOME/build/cross/sys-root/system/usr/local" --disable-zlib
make
make install
copy dbclient, dropbearconvert and dropbearkey in /system/bin
copy dropbear in /system/sbin
chown root on all copied files
chmod 755 on all copied files
Hi, I've been folowing your howto in order to build busybox but when I download the my.zip file I think it's corrupted or something because it's empty and I can't extract the config files. Could you check it please? Thanks in advance
the my.zip file is compressed strangely. I was able to open it using 7-zip then opened the "my" file in there and it showed a bunch of file within it. Can the op look into his archive and see about recompressing it in a more compliant format. It isn't a zip file.
EDIT: Actually forget it. When you download it replace the .zip with .tar.bz2 or you can just append it to the filename probably if the .zip part isn't showing for you. It's a bzip2 compressed tar archive.
shinji257 said:
the my.zip file is compressed strangely. I was able to open it using 7-zip then opened the "my" file in there and it showed a bunch of file within it. Can the op look into his archive and see about recompressing it in a more compliant format. It isn't a zip file.
EDIT: Actually forget it. When you download it replace the .zip with .tar.bz2 or you can just append it to the filename probably if the .zip part isn't showing for you. It's a bzip2 compressed tar archive.
Click to expand...
Click to collapse
worked like a charm. Thanks!!
I would like to thank you for this guide. With it (and a small alteration to my own busybox .config) I was able to build 1.18.5 and 1.19.0.git with network support working finally. The files are a bit bigger for my taste but I'll go back and see if I can get a dynamic build next.
The flash* items (flashcp, flash_lock, flash_unlock, flash_eraseall) will not build unless you get the mtd-utils package from the android repo.
EDIT: It will dynamic build but I came across a roadblock. The uClibc included on my phone already is 0.9.31 and the toolchain built 0.9.30.2 so I'm changing it up a bit... Should be fine though.
Dynamic link reduces from 1.7MB to ~1.0MB
Here is russian version of manual http://wiki.androidfan.ru/Сборка_c_нуля
Also there some updates too: https://www.droid-developers.org/wiki/Toolchain
Easy way to build jupp… if you’ve got Debian, that is.
XVilka said:
7. Building simple but powerful text editor jupp (mirbsd.org/jupp.htm)
Click to expand...
Click to collapse
Thank you very much for liking jupp and publishing him here!
If you’re running Debian on an ARM system, there’s an even easier way to get jupp.
• set up the system for building packages (or login to a Debian porterbox like harris.debian.org and switch into the “sid” chroot): install the build-essential package
• install debhelper and autotools-dev
• install dietlibc-dev (or libklibc-dev, but I tested with dietlibc-dev right now as I cannot install libklibc-dev on the porterbox by myself)
• go to packages.debian.org/source/sid/jupp and figure out the download link to the .dsc file
• download that with “dget”:
Code:
dget -d http://ftp.de.debian.org/debian/pool/main/j/jupp/jupp_3.1.23-1.dsc
(of course, adjust the link; this is the version up to date at the time of this writing)
• extract the package (adjust the name as usual):
Code:
dpkg-source -x jupp_3.1.23-1.dsc
• switch into the source directory:
Code:
cd jupp-3.1.23/
• run a compilation:
Code:
env DEB_BUILD_OPTIONS=diet fakeroot debian/rules binary
(or DEB_BUILD_OPTIONS=klibc)
Now you have in the directories ./debian/jupp/ and ./debian/joe-jupp/ the full build result. Test it by running
Code:
./debian/jupp/usr/bin/jupp
(you can press ^Kq, that is Ctrl-K followed by q, to exit it immediately; remember ^J (Ctrl-J) opens the help).
Now install the following files into their final locations:
• debian/jupp/etc/jupp/* to /etc/jupp/ (including subdirectories)
• debian/jupp/usr/bin/jupp to /usr/bin/jupp
• optionally, debian/joe-jupp/etc/jupp/ to /etc/jupp/ and the symlinks from debian/joe-jupp/usr/bin/ to /usr/bin/
Strictly speaking, for running “jupp”, no other file than the executable is needed, and that can be in any path. It includes a copy of jupprc in the executable, although without syntax highlighting.
If you have to change the paths, look at the file debian/rules (--prefix, --sysconfdir, --mandir although you don’t need the mandir) and debian/jupp.install and debian/joe-jupp.install (install paths) before compiling.
JOE finds the *rc files by looking into a path that is set at compile time (if --sysconfdir=/etc it looks into /etc/joe/ but debian/rules also sets sysconfjoesubdir=/jupp at make time, so it uses /etc/jupp/ instead), a file that’s the basename of the editor command plus “rc”, so /usr/bin/jfoo will let it load jfoorc. The klingon charmap and the syntax files are expected in subdirectories of where the configs (rc files) are.
Hope that helps!
If you want, I’m in the IRC channel #MirBSD and #!/bin/mksh on Freenode IRC network, and can help (but will assume you’re either running Debian/ARM or have your cross compiler set up correctly).

[GUIDE] How to port Bluez to Kitkat, Lollipop & Marshmallow

Introduction
When the bluetooth stack changed to Bluedroid in Android 4.2, it was a nightmare to some of the old devices like my GT-P6800. I didn't have any experience in Bluetooth before so I did what I know. I spent weeks to revert the 4.2 platform to Bluez. Even though I succeeded, it probably not doable for 4.3 and later.
Last Nov. I found that bluez.org announced support for Andriod in Sep. It gave me hope again! Thanks to the bluez team!:good: The principle is straight forward - Implement the functions defined in "hardware/libhardware/include/hardware/bluetooth.h". That's what I thought but I didn't have enough knowledge nor confidence to try...
After studying for a while, I started porting bluez to Android 4.4 last Christmas. It was frustrated and helpless. Although the lastest Android 4.4 example for Mako and Flo are out, they don't help much. A bunch of prebuilt kernel objects surely doesn't help! Porting for those devices already having bluedroid support is meaningless to most of us too...
Building the bluez hal and daemon are straight forward but how to make it really work is another story. After a few painful and frustrated weekends, I finally managed to pull everything together. I can start/stop and pairing bluetooth devices in the platform now. And here I'm, sharing my experiences. I think there might be better way and I welcome any corrections.
My p6800 has CSR bluetooth chip which has no bluedroid support. I think the same approach would work for other chips too. Cheers! :highfive:
** All paths assume your rom source dircetory to be the current directory **
1. Downlaod and Build
Bluez.org already has its own tutorial. I just summerize and list my suggestions.
1.1 local manifest
I learned my lesson and would avoid touching the "manifest.xml".
Add the following lines to your ".repo/local_manifests/local_menifest.xml"
For cm11, omni, etc.
Code:
<remote name="gcode" fetch="https://code.google.com/p/"/>
<remote name="korg" fetch="git://git.kernel.org/pub/scm/bluetooth/"/>
<remove-project name="android_external_bluetooth_bluedroid"/>
<project remote="korg" path="external/bluetooth/bluez" name="bluez" group="pdk" revision="master"/>
<project remote="korg" path="external/bluetooth/sbc" name="sbc" group="pdk" revision="master"/>
<project remote="gcode" path="external/bluetooth/glib" name="aosp-bluez.glib" group="pdk" revision="master"/>
For AOSP, replace the remove-project with:
Code:
<remove-project name="platform/external/bluetooth/bluedroid"/>
After repo sync, bluez will replace bluedroid.
1.2 patching bionic
The patches for bionic are simple. Mainly by adding two flags and the function epoll_create1().
Bionic may vary from ROMs. It is wiser to patch the bionic of your ROM manually. You may follow the changes of the two commits below:
https://code.google.com/p/aosp-blue...96020013615b00d70579123f&repo=platform-bionic
https://code.google.com/p/aosp-blue...3347746d0d9727d8439ef4c4&repo=platform-bionic
1.3 neccessary tools
There are tools in "external/bluetooth/bluez/tools". You may need some of those tools for setup or testing.
This is the "Android.mk" I added to "external/bluetooth/bluez/tools". You may cheery pick the required tools for your device.
Code:
#
# Bluetooth tools for setup and debug
# daniel_hk
LOCAL_PATH := external/bluetooth
# Retrieve BlueZ version from configure.ac file
BLUEZ_VERSION := $(shell grep ^AC_INIT $(LOCAL_PATH)/bluez/configure.ac | cpp -P -D'AC_INIT(_,v)=v')
# Specify pathmap for glib
#pathmap_INCL += glib:external/bluetooth/glib
# Specify common compiler flags
BLUEZ_COMMON_CFLAGS := -DVERSION=\"$(BLUEZ_VERSION)\" \
-DSTORAGEDIR=$(ANDROID_STORAGEDIR) \
# Disable warnings enabled by Android but not enabled in autotools build
BLUEZ_COMMON_CFLAGS += -Wno-pointer-arith -Wno-missing-field-initializers
# @ daniel, extra tools for CSR
ifeq ($(BOARD_HAVE_BLUETOOTH_CSR),true)
#
# bccmd
#
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
bluez/lib/hci.c \
bluez/lib/bluetooth.c \
bluez/tools/bccmd.c \
bluez/tools/csr.c \
bluez/tools/csr_3wire.c \
bluez/tools/csr_bcsp.c \
bluez/tools/csr_hci.c \
bluez/tools/csr_h4.c \
bluez/tools/csr_usb.c \
bluez/tools/ubcsp.c
LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
LOCAL_C_INCLUDES:=\
$(LOCAL_PATH)/bluez \
$(LOCAL_PATH)/bluez/lib \
$(LOCAL_PATH)/bluez/tools \
$(LOCAL_PATH)/bluez/src \
$(LOCAL_PATH)/bluez/src/shared \
LOCAL_MODULE:=bccmd
include $(BUILD_EXECUTABLE)
#
# sdptool
#
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
bluez/lib/hci.c \
bluez/lib/bluetooth.c \
bluez/lib/sdp.c \
bluez/tools/sdptool.c \
bluez/src/sdp-xml.c
LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
LOCAL_C_INCLUDES:=\
$(LOCAL_PATH)/bluez \
$(LOCAL_PATH)/bluez/lib \
$(LOCAL_PATH)/bluez/tools \
$(LOCAL_PATH)/bluez/src \
$(LOCAL_PATH)/bluez/src/shared \
LOCAL_C_INCLUDES += \
$(call include-path-for, glib) \
$(call include-path-for, glib)/glib \
LOCAL_SHARED_LIBRARIES := \
libglib \
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE:=sdptool
include $(BUILD_EXECUTABLE)
endif
1.4 patches for CyanogenMod 11
In CyanogenMod 11, the function "pin_request_cb" has one more argument. The following file need some patches:
in the file "external/bluetooth/bluez/android/hal-bluetooth.c"
Code:
[I]** in function: handle_pin_request[/I]
bt_hal_cbacks->pin_request_cb(addr, name, ev->class_of_dev, 0); // @ daniel, added 0 for cm11
in the file "external/bluetooth/bluez/android/client/if-bt.c"
Code:
[I]** in function: pin_request_cb[/I]
static void pin_request_cb(bt_bdaddr_t *remote_bd_addr, bt_bdname_t *bd_name,
uint32_t cod, uint8_t secure) // @ daniel, added secure from cm11
{
/* Store for command completion */
bt_bdaddr_t2str(remote_bd_addr, last_remote_addr);
pin_request_addr = *remote_bd_addr;
haltest_info("%s: remote_bd_addr=%s bd_name=%s cod=%06x secure=%02x\n", __func__,
last_remote_addr, bd_name->name, cod, secure); // @ daniel, added
terminal_prompt_for("Enter pin: ", pin_request_answer);
}
2. kerenl patch
In the "README" inside "external/bluetooth/bluez/android", there is the line:
Minimal required version of management interface is 1.3. This corresponds to Linux 3.9 but latest available version is recommended.
Click to expand...
Click to collapse
If you have tried porting bluez and fail, check the logcat. You might probably found the error "Failed to access management interface". This is the key making bluez to work! Sadly, most of the existing Android kernels are before ver. 3.9! The latest kernel we have might be ver. 3.4.x and the kernel for my p6800 is ver. 3.0.x! As the above line stated, Bluez5 requires the kernel to have management interface 1.3 or above. That means we have to backport the bluetooth subsystem from at least ver. 3.9. I backport my kernel with the latest (3.13-1) found in linux-foundation.org: http://drvbp1.linux-foundation.org/~mcgrof/rel-html/backports/
It was a tough and painful job! There are lots of changes. I finally got a bootable backport kernel in 2 days!
I packed my patches in View attachment kernel-3.0.x-backport-3.13-1.zip. This patch is for my 3.0.x kernel which might be different from other 3.0.x kernels. Don't have time to tidy up but it works for me. Although I've done the hard part, it still requires extra patience to get yours done. Prepare yourself...
2.1 Backport 3.13-1 to your kernel
Direct replacements.
Replace the following folders in the zip with the one in your kernel source:
drivers/bluetooth
net/bluetooth
include/net/bluetooth
include/backport​
Direct replacement might not work!
Check include/linux in the zip
For each file,
add the required part (which I delimited with comments @ daniel and //@ ) to the corresponding file in your kernel source.
If file not exist,
copy the files to your kernel source​
Check your defconfig. As README suggested, defconfig should have:
CONFIG_BT
CONFIG_BT_RFCOMM
CONFIG_BT_RFCOMM_TTY
CONFIG_BT_BNEP
CONFIG_BT_BNEP_MC_FILTER
CONFIG_BT_BNEP_PROTO_FILTER
CONFIG_BRIDGE
CONFIG_UHID
# and for CSR chips
CONFIG_BT_HCIUART=y
CONFIG_BT_HCIUART_H4=y
CONFIG_BT_HCIUART_BCSP=y​
You probably need to compile the kernel many times to get it work. I worte a build script View attachment build-k.zip to compile the kernel only.
Copy build-k to your ROM source directory and type:
Code:
./build-k <your device>
2.2 Backport-hid-generic to your kernel
There is another patch in the Mako-kern example:
https://code.google.com/p/aosp-blue...eneric-driver.patch?repo=device-lge-mako-kern
Don't know if it is required for your kernel but adding this patch seems doesn't hurt.
If you do it right, you may find "Bluetooth management interface 1.4" in your logcat. Congratulation! Bluetoothd can connect to your kernel now!
3. initialization and setup
Take a look at your devices tree's TARGET_CUSTOM_BLUEDROID definition. If you have a file assigned, it supposed to replace the file "bluetooth.c" in the "system/bluetooth" project. In Android 4.4, this project is no longer exist/needed. Before Android 4.2, this project provide the functions "bt_enable()" and "bt_disable()" which are called in the frameworks. These functions will tell you how to "power on", "power off" and init your device's Bluetooth chip.
For CSR:
set /sys/class/rfkill/rfkill0/state to 1 ("power on")
start the service "bccmd" which will setup the chip and upload a PSConfig to the chip
start the service "hciattach" which init the port hci0 with parameters
start the service "bluetoothd" which is the bluez stack
The services are defined in init.rc or init.${ro.hardware}.rc.
3.1 Test your device and the tools
Disable the "import init.bluetooth.rc" line if you have added it before.
Example for CSR chips. Follow the steps in bt_enable. In a terminal or via adb:
Code:
$ su -- [I][COLOR="SeaGreen"]root user is required[/COLOR][/I]
# echo "1" > /sys/class/rfkill/rfkill0/state
# bccmd -t bcsp -d /dev/ttySAC0 -b 115200 psload -r /system/etc/PSConfig_8811.psr
Loading 0x212c ... done
Loading 0x212d ... done
...
Loading PSKEY_CLOCK_REQUEST_ENABLE ... done
Loading PSKEY_UART_HOST_WAKE ... done
# hciattach -p /dev/ttySAC0 bcsp 3000000 flow
Device setup complete
# hciconfig hci0 up
# hcitool scan -- [I][COLOR="SeaGreen"]turn on a device's bluetooth for testing[/COLOR][/I]
Nexus 4 -- [I][COLOR="SeaGreen"]found the device means bluetooth is working now[/COLOR][/I]
3.2 Init sequence
In Bluez5, the HAL (bluetooth.default.so) driver will be loaded at boot and the daemon (bluetoothd) will be started inside too. Take a look at the function "bool hal_ipc_init(void)" in "external/bluetooth/bluez/android/hal-ipc.c". You may find how the HAL is init which is different from pre-4.2 Androids.
In order to get the daemon (bluetoothd) to work, we have to init the chip before that.
I worte a shell script init.bt.sh to init the chip/port:
Code:
#!/system/bin/sh
# modified by daniel_hk
LOG_TAG="CSR8811-HCI"
BTUART_PORT=/dev/ttySAC0
BTSTATE=/sys/class/rfkill/rfkill0/state
PSCONFIG=/system/etc/PSConfig_8811.psr
logi ()
{
/system/bin/log -t $LOG_TAG -p i ": [email protected]"
}
loge ()
{
/system/bin/log -t $LOG_TAG -p e ": [email protected]"
}
failed ()
{
loge "$1: exit code $2"
exit $2
}
#Enable power of csr chip
echo "1" > $BTSTATE
# PS Config with bccmd
logwrapper /system/bin/bccmd -t bcsp -d $BTUART_PORT -b 115200 psload -r $PSCONFIG
case $? in
0) logi "bccmd init port....done";;
*) failed "port: $BTUART_PORT - bccmd failed" $?;
exit $?;;
esac
# attach HCI
logwrapper /system/bin/hciattach -p $BTUART_PORT bcsp 3000000 flow
case $? in
0) logi "hci attached to : $BTUART_PORT";;
*) failed "port: $BTUART_PORT - hciattach failed" $?;
exit $?;;
esac
exit 0
It takes time for bccmd and hciattach to complete. Putting them in seperate services requires delay in between. I think it is better to run them as application one after one.
A new rc file init.${ro.hardware}.bt.rc is created and need to be imported in your init.${ro.hardware}.rc
Code:
on boot
start bt_init
on property:init.svc.bluetoothd=running
start hci0_up
on property:init.svc.bluetoothd=stopped
start hci0_down
service bt_init /system/bin/logwrapper /system/bin/sh /system/etc/init.bt.sh
class main
user root
group bluetooth net_bt_admin system
disabled
oneshot
service hci0_up /system/bin/logwrapper /system/xbin/hciconfig hci0 up
class main
group bluetooth
disabled
oneshot
service hci0_down /system/bin/logwrapper /system/xbin/hciconfig hci0 down
class main
group bluetooth
disabled
oneshot
import init.bluetooth.rc
Since HAL (bluetooth.default.so) is started quite early, I start the service bt_init at boot. I have tried a few places, daemon might timed out before bt_init finish. It also seems no need to repeat the init process everytime.
When bluetoothd is running (system/core/init will set the property init.svc.bluetoothd=running), set hci0 up with hciconfig. And when the service bluetoothd is stopped, set hci0 down with hciconfig. There might be a better way. Please indulge me if something better coming up.
You may turn ON/OFF bluetooth in settings now. Pairing and file transfer is working too.
4. Further porting
Take a look at the function get_profile_interface() in the file external/bluetooth/bluez/android/hal-bluetooth.c. Some interfaces which frameworks requested are missing.
eg. Bluetooth Handsfree interface
Bluetooth Map Client Interface
Bluetooth Health Interface
Bluetooth GATT Interface​Update: Fully support for Kitkat now. Check the README inside the android folder for detail.
As I mentioned before, I'm new to bluetooth. Further reading is required for me to fix other services. I also don't have enough time now. I have to process the stuck works after the Chinese New Year holiday. :cyclops: Hoping I can continue by the end of Feb. In the mean time, I hope someone have better knowledge may help fix other services.
For those devices don't have bluedroid support, we have a chance to carry on now!
[GUIDE] Porting Bluez to Marshmallow
Check the modified Bluez in my github.
It has been tested with Omni6 (Android-6.0.1_r3)
You have to remove system_bt in local_manifest.xml (similar to bluedroid, check post #1 for detail)
CM needs extra modifications. Will be available after testing.
Nice , Xperia Novathor devs also working on stable bluez 
 @95A31
Nice guide In CM11 you need also revert this https://github.com/CyanogenMod/andr...mmit/763c68d048d268bd931dffa72000f52830ffe2d8
95A31 said:
Nice guide In CM11 you need also revert this https://github.com/CyanogenMod/andr...mmit/763c68d048d268bd931dffa72000f52830ffe2d8
Click to expand...
Click to collapse
Thanks! Patch in section 1.4 is another alternative for cm11.
daniel_hk said:
Thanks! Patch in section 1.4 is another alternative for cm11.
Click to expand...
Click to collapse
Wops my fault :silly:, you have right
although i dont have my previous device which has csr chip..but those still have csr will get greatly benefited ..your work is incredible......god bless u!!!
keep the good work!!!
static void pin_request_cb is defined in external/bluetooth/bluez/android/client/if-bt.c
95A31 said:
static void pin_request_cb is defined in external/bluetooth/bluez/android/client/if-bt.c
Click to expand...
Click to collapse
yeah, it is also defined in if-bt.c but if you check android/Android.mk, only haltest use it. If you want to build haltest, you need to change if-bt.c too.
Take a look the file android/Android.mk which is the make file for android. bluetooth.default.so which cm11 refered to, use the definition in hal-bluetoth.c.
Sent from my Nexus 7 using Tapatalk
daniel_hk said:
yeah, it is also defined in if-bt.c but if you check android/Android.mk, only haltest use it. If you want to build haltest, you need to change if-bt.c too.
Take a look the file android/Android.mk which is the make file for android. bluetooth.default.so which cm11 refered to, use the definition in hal-bluetoth.c.
Sent from my Nexus 7 using Tapatalk
Click to expand...
Click to collapse
Forgot my unknowledge/newbie but I can not find it in hal-bluetoth.c (In BLueZ git)
95A31 said:
Forgot my unknowledge/newbie but I can not find it in hal-bluetoth.c (In BLueZ git)
Click to expand...
Click to collapse
It's in the android folder. In the same place as Android.mk.
If you can't find inside the file, you might have the old version. Try include the project in manifest and sync again.
I have a suggested local_manifest in post #1.
Good luck!
Sent from my Nexus 7 using Tapatalk
daniel_hk said:
It's in the android folder. In the same place as Android.mk.
Sent from my Nexus 7 using Tapatalk
Click to expand...
Click to collapse
I mean in hal-bluetooth.c, can you tell me the line in this version ot the file? (I know that it is a retarded question but I really can find other occurences of pin_request_cb outside handle_pin_request function) I am working on BlueZ git so I am working on lastest version
95A31 said:
I mean in hal-bluetooth.c, can you tell me the line in this version ot the file? (I know that it is a retarded question but I really can find other occurences of pin_request_cb outside handle_pin_request function) I am working on BlueZ git so I am working on lastest version
Click to expand...
Click to collapse
All the changes are listed in post#1.
In line 239 of you link, there is the line:
bt_hal_cbacks->pin_request_cb(addr, name, ev->class_of_dev);
It is a callback. The definition is in cm11 which had changed. That's why we have to add one more argument. (or revert the cm11 commit as you said)
The definition if-bt.c which is a client, is for testing. It has to define the callback which is required in int. Got it?
daniel_hk said:
All the changes are listed in post#1.
In line 239 of you link, there is the line:
bt_hal_cbacks->pin_request_cb(addr, name, ev->class_of_dev);
It is a callback. The definition is in cm11 which had changed. That's why we have to add one more argument. (or revert the cm11 commit as you said)
The definition if-bt.c which is a client, is for testing. It has to define the callback which is required in int. Got it?
Click to expand...
Click to collapse
Get it :good:
Ok, I have a nice bootloop: http://pastebin.com/QcZbEkfx Guys some ideas ?
95A31 said:
Ok, I have a nice bootloop: http://pastebin.com/QcZbEkfx Guys some ideas ?
Click to expand...
Click to collapse
I have checked your logcat. There is no management interface log. The kernel backport on blietooth subsystem is probably failed.
Sent from my Nexus 7 using Tapatalk
daniel_hk said:
I have checked your logcat. There is no management interface log. The kernel backport on blietooth subsystem is probably failed.
Sent from my Nexus 7 using Tapatalk
Click to expand...
Click to collapse
I foud this dependence in my case: WLAN init need that BT chip is initialized because WLAN ask clock to BT. The intoduction of import init.bluetooth.rc broke this dependence. Fu*king details :cyclops: I hope to save debug time to someone
Thanks, very helpful guide. Following this I was able to get BlueZ working on MSM7x27a. However, instead of dropping the backport sources in the kernel tree I followed this documentation to build the backports as external modules, which looks like a cleaner way to me. This requires building the kernel without BT (and, in cases like this, patching the source to remove some dependencies on built-in BT). This leaves the kernel sources (mostly) untouched, and makes adapting the backport sources easier because you can separately build the modules without doing a full kernel build.
The modules can then be built like this:
Code:
# clean output files
make -C kernel/backports ARCH=arm CROSS_COMPILE="arm-eabi-" KLIB=$OUT/obj/KERNEL_OBJ KLIB_BUILD=$OUT/obj/KERNEL_OBJ mrproper
# configure
make -C kernel/backports ARCH=arm CROSS_COMPILE="arm-eabi-" KLIB=$OUT/obj/KERNEL_OBJ KLIB_BUILD=$OUT/obj/KERNEL_OBJ menuconfig
# build
make -C kernel/backports ARCH=arm CROSS_COMPILE="arm-eabi-" KLIB=$OUT/obj/KERNEL_OBJ KLIB_BUILD=$OUT/obj/KERNEL_OBJ
jjm34 said:
Thanks, very helpful guide. Following this I was able to get BlueZ working on MSM7x27a. However, instead of dropping the backport sources in the kernel tree I followed this documentation to build the backports as external modules, which looks like a cleaner way to me. This requires building the kernel without BT (and, in cases like this, patching the source to remove some dependencies on built-in BT). This leaves the kernel sources (mostly) untouched, and makes adapting the backport sources easier because you can separately build the modules without doing a full kernel build.
The modules can then be built like this:
Code:
# clean output files
make -C kernel/backports ARCH=arm CROSS_COMPILE="arm-eabi-" KLIB=$OUT/obj/KERNEL_OBJ KLIB_BUILD=$OUT/obj/KERNEL_OBJ mrproper
# configure
make -C kernel/backports ARCH=arm CROSS_COMPILE="arm-eabi-" KLIB=$OUT/obj/KERNEL_OBJ KLIB_BUILD=$OUT/obj/KERNEL_OBJ menuconfig
# build
make -C kernel/backports ARCH=arm CROSS_COMPILE="arm-eabi-" KLIB=$OUT/obj/KERNEL_OBJ KLIB_BUILD=$OUT/obj/KERNEL_OBJ
Click to expand...
Click to collapse
Yeah! Yours seems better. I was messing with the kernel for a while before backport. Traditional backport kill my WiFi so I did what I knew. I will try yours later.
Any other success would be cheerful.
Sent from my Nexus 7 using Tapatalk
Sucessfully ported on CyanogenMod 11.0 git (using Bluetooth from AOSP).
HOWTO:
Remove CyanogenMod Bluetooth and grab AOSP version by local_manifest:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="kernel"
fetch="git://git.kernel.org/pub/scm/" />
<remote name="googlecode"
fetch="https://code.google.com/" />
<remove-project name="CyanogenMod/android_external_bluetooth_bluedroid" />
<project remote="kernel" path="external/bluetooth/bluez" name="bluetooth/bluez" groups="pdk" revision="master" />
<project remote="kernel" path="external/bluetooth/sbc" name="bluetooth/sbc" groups="pdk" revision="master" />
<project remote="googlecode" path="external/bluetooth/glib" name="p/aosp-bluez.glib" groups="pdk" revision="master" />
<remove-project name="CyanogenMod/android_packages_apps_Bluetooth" />
<remove-project name="CyanogenMod/android_packages_apps_BluetoothExt" />
<project path="packages/apps/Bluetooth" name="platform/packages/apps/Bluetooth" remote="aosp" revision="refs/tags/android-4.4.2_r1" />
<project path="aosp/packages/apps/Settings" name="platform/packages/apps/Settings" remote="aosp" revision="refs/tags/android-4.4.2_r1" />
<project path="aosp/frameworks/base" name="platform/frameworks/base/" remote="aosp" revision="refs/tags/android-4.4.2_r1" />
<project path="aosp/hardware/libhardware" name="platform/hardware/libhardware/" remote="aosp" revision="refs/tags/android-4.4.2_r1" />
</manifest>
Replace CyanogenMod Bluetooth system with AOSP one:
Code:
rm cm-11.0/hardware/libhardware/include/hardware/bluetooth.h
cp aosp/hardware/libhardware/include/hardware/bluetooth.h cm-11.0/hardware/libhardware/include/hardware/bluetooth.h
rm -rf cm-11.0/frameworks/base/core/java/android/bluetooth
cp -r aosp/frameworks/base/core/java/android/bluetooth cm-11.0/frameworks/base/core/java/android
rm cm-11.0/frameworks/base/services/java/com/android/server/BluetoothManagerService.java
cp aosp/frameworks/base/services/java/com/android/server/BluetoothManagerService.java cm-11.0/frameworks/base/services/java/com/android/server/BluetoothManagerService.java
rm -rf cm-11.0/packages/apps/Settings/src/com/android/settings/bluetooth
cp -r aosp/packages/apps/Settings/src/com/android/settings/bluetooth cm-11.0/packages/apps/Settings/src/com/android/settings
Adapt CyanogenMod with this changes:
Code:
diff --git a/frameworks/base/Android.mk b/frameworks/base/Android.mk
index 91338ef..43a87ef 100644
--- a/frameworks/base/Android.mk
+++ b/frameworks/base/Android.mk
@@ -88,10 +88,8 @@ LOCAL_SRC_FILES += \
core/java/android/wipower/IWipower.aidl \
core/java/android/wipower/IWipowerManagerCallback.aidl \
core/java/android/bluetooth/IBluetooth.aidl \
- core/java/android/bluetooth/IQBluetooth.aidl \
core/java/android/bluetooth/IBluetoothA2dp.aidl \
core/java/android/bluetooth/IBluetoothCallback.aidl \
- core/java/android/bluetooth/IQBluetoothAdapterCallback.aidl \
core/java/android/bluetooth/IBluetoothHeadset.aidl \
core/java/android/bluetooth/IBluetoothHeadsetPhone.aidl \
core/java/android/bluetooth/IBluetoothHealth.aidl \
@@ -100,18 +98,12 @@ LOCAL_SRC_FILES += \
core/java/android/bluetooth/IBluetoothPan.aidl \
core/java/android/bluetooth/IBluetoothManager.aidl \
core/java/android/bluetooth/IBluetoothManagerCallback.aidl \
- core/java/android/bluetooth/IQBluetoothManagerCallback.aidl \
core/java/android/bluetooth/IBluetoothPbap.aidl \
core/java/android/bluetooth/IBluetoothMap.aidl \
core/java/android/bluetooth/IBluetoothStateChangeCallback.aidl \
- core/java/android/bluetooth/IBluetoothHandsfreeClient.aidl \
- core/java/android/bluetooth/IBluetoothHidDevice.aidl \
- core/java/android/bluetooth/IBluetoothHidDeviceCallback.aidl \
core/java/android/bluetooth/IBluetoothGatt.aidl \
core/java/android/bluetooth/IBluetoothGattCallback.aidl \
core/java/android/bluetooth/IBluetoothGattServerCallback.aidl \
- core/java/android/bluetooth/IBluetoothSap.aidl \
- core/java/android/bluetooth/IBluetoothDun.aidl \
core/java/android/content/IClipboard.aidl \
core/java/android/content/IContentService.aidl \
core/java/android/content/IIntentReceiver.aidl \
@@ -407,7 +399,6 @@ aidl_files := \
frameworks/base/core/java/com/android/internal/view/IInputMethodClient.aidl \
frameworks/base/core/java/com/android/internal/view/IInputMethodManager.aidl \
frameworks/base/core/java/com/android/internal/view/IInputMethodSession.aidl \
- frameworks/base/core/java/android/bluetooth/BluetoothLEServiceUuid.aidl \
frameworks/base/graphics/java/android/graphics/Bitmap.aidl \
frameworks/base/graphics/java/android/graphics/Rect.aidl \
frameworks/base/graphics/java/android/graphics/Region.aidl \

Building AOSP Emulator

Though it's not necessary to build AOSP to build AOSP emulator, but I will discuss it here anyway.
Note: From here on we are considering, $HOME/AOSP is our AOSP repo download folder.
Android Build:
-----------------
Everything are already explained in source.andorid clearly except some step. I am going to explain those.
1. Follow this url, "https://source.android.com/setup/build/requirements".
2. Replace branch name of,
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
by going "https://android.googlesource.com/platform/manifest" and select chosen branch. Download may take up to 20 hours or more.
3. If not sure what argument to choose from lunch command, just type lunch and a bunch of options will be shown. Then select the correct one.
4. Replace "make –jN" to the number of threads you have in your PC. For example for a 4 thread processor "make –j4" will be the command.
5. If jack server has any memory issue run following command,
export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g"
./prebuilts/sdk/tools/jack-admin kill-server
./prebuilts/sdk/tools/jack-admin start-server
Remember to replace –Xmx4g accordingly, here 4g means 4GB. Total build may take up to 9hrs.
6. After that, for every incremental build, type source and lunch command then make command for fresh started terminal otherwise only make will do.
Adding Default Application to android Source:
--------------------------------------------------------
1. Create an application in Android Studio.
2. We don’t need any gradle related folders for AOSP build. Take only java, assets and res folder and copy that in a new folder. Then take that folder to "AOSP/packages/apps" folder.
3. Add "Android.mk" file to that folder and add following lines (replace AppName accordingly and if app has assets un-comment line starting with "LOCAL_ASSETS_DIR"),
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := AppName
LOCAL_SDK_VERSION := current
LOCAL_SRC_FILES := $(call all-java-files-under, java)
# Include libraries
#LOCAL_JAVA_LIBRARIES := <Java lib dependencies>
LOCAL_STATIC_JAVA_LIBRARIES := android-common
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-appcompat
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
#LOCAL_ASSETS_DIR := $(LOCAL_PATH)/assets
LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_AAPT_FLAGS += --extra-packages android.support.v7.appcompat
include $(BUILD_PACKAGE)
4. Don't use newly introduced layouts, which may create run-time exception (use linear, relative or other old layouts). Also use properly scoped style. For example,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="50dp"
android:layout_height="30dp"
android:layout_weight="1"
android:text="Hello World!"
android:textAppearance="@android:style/TextAppearance.Large" />
</LinearLayout>
In andorid studio "android:layout_width" may be written as "layout_width" and "@android:style/TextAppearance.Large" may be written as "TextAppearance.Large". We've to add full scope to every item, as AOSP build doesn't use gradle build system.
5. Add app name to "PRODUCT_PACKAGES" variable of "AOSP/build/target/product/core.mk" and "AOSP/device/generic/armv7-a-neon/mini_common.mk" files.
6. Build app using make appName then use make –jN or make snod.
NOTE: In emulator, settings page might crash. To fix this, go to "AOSP/packages/apps/Settings/src/com/android/settings/wfd/WifiDisplaySettgins.java", replace existing code by code below,
public static boolean isAvailable(Context context) {
return false;
//return context.getSystemService(Context.DISPLAY_SERVICE) != null
// && context.getSystemService(Context.WIFI_P2P_SERVICE) != null;
}
Emulator Build:
------------------
1. Android emulator is build upon QEMU. Branch for QEMU on "https://android.googlesource.com" is named qemu and generic kernel is in goldfish branch. Note that though we can build goldfish kernel using simple make commands, we've used prebuilt kernel for our approach.
2. Emulator source:
git clone https://android.googlesource.com/platform/external/qemu
(note there is another branch named qemu-android, this branch is not used any more so avoid cloning that branch)
Goldfish source:
git clone https://android.googlesource.com/device/generic/goldfish
(not needed to build emulator)
3. Remember we've to use the appropriate branch after repo name for example for emulator we are using latest 2.8 version which is in branch, "emu-2.8-release". So our command will be,
git clone https://android.googlesource.com/platform/external/qemu-android -b emu-2.8-release
or we can switch to that branch after cloning for master.
4. After cloning, copy the whole directory to "$HOME/AOSP/external" folder, rename older to qemu (if we've cloned qemu into our chosen named folder). We need this because qemu build uses "AOSP/external" and "AOSP/prebuilt" folder for its dependencies. By doing this we can avoid copying multiple repos for emulator, as we've already pulled it during AOSP cloning.
5. Run,
./android/configure.sh
./configure
6. We need to clone some other branches to build the emulator. Below branches should be copied to external folder,
git clone https://android.googlesource.com/platform/external/gtest -b emu-2.8-release
git clone https://android.googlesource.com/platform/external/tinyobjloader -b emu-2.8-release
put below branches in prebuilts/android-emulator-build folder,
git clone https://android.googlesource.com/platform/prebuilts/android-emulator-build/archive -b emu-2.8-release
git clone https://android.googlesource.com/platform/prebuilts/android-emulator-build/common -b emu-2.8-release
git clone https://android.googlesource.com/platform/prebuilts/android-emulator-build/curl -b emu-2.8-release
git clone https://android.googlesource.com/platform/prebuilts/android-emulator-build/mesa -b emu-2.8-release
git clone https://android.googlesource.com/platform/prebuilts/android-emulator-build/mesa-deps -b emu-2.8-release
git clone https://android.googlesource.com/platform/prebuilts/android-emulator-build/protobuf -b emu-2.8-release
git clone https://android.googlesource.com/platform/prebuilts/android-emulator-build/qemu-android-deps -b emu-2.8-release
git clone https://android.googlesource.com/platform/prebuilts/android-emulator-build/qt -b emu-2.8-release
also we may need below branch, (we've to put it in "prebuilts/clang/host/linux-x86" folder)
git clone https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86 -b emu-2.8-release
Note: if we look through git path of each branch they are same as AOSP folder structure. So we can get the hint, where to put them
If any ssl problem occures to download repo, run below command,
export GIT_SSL_NO_VERIFY=1
7. Run "make -jN". if any other things are missing we will be shown the message and please clone those items from googlesource and put it in the correct location.
8. If emulator build failed for warning the run this "./configure --disable-werror", then make again.
9. After successful build we will get obs folder. Replace contents of "$home/AOSP/prebuilts/android-emulator/linux-x86_64" by the contents of our built folder.
10. Go back to AOSP root folder, now if we run "emulator" command, our custom built emulator will be used from now on.
11. We can run "emulator -verbose" to see generated commands.
Note: to buid AOSP again, we need to remove qemu, gtest, tinyobjloader from AOSP source, as they interfere with AOSP prebuilt packages. So after buiding emulator remove those folders from AOSP source folder.
Some Commands:
----------------------
This commands may or may not be needed, depending on the status of Ubuntu or source code.
1. Adding qt library in path
export PATH=/home/saikat/AOSP/prebuilts/android-emulator/linux-x86_64/lib64:/home/saikat/AOSP/prebuilts/android-emulator/linux-x86_64/lib64/gles_swiftshader:/home/saikat/AOSP/prebuilts/android-emulator/linux-x86_64/lib64/gles_angle:/home/saikat/AOSP/prebuilts/android-emulator/linux-x86_64/lib64/gles_angle9:/home/saikat/AOSP/prebuilts/android-emulator/linux-x86_64/lib64/gles_angle11:/home/saikat/AOSP/prebuilts/android-emulator/linux-x86_64/lib64/libstdc++:/home/saikat/AOSP/prebuilts/android-emulator/linux-x86_64/lib64/qt/lib:$PATH
export QT_QPA_PLATFORM_PLUGIN_PATH=/home/saikat/AOSP/prebuilts/android-emulator/linux-x86_64/lib64/qt/plugins
2. Library installation commands
apt-get install build-essential zlib1g-dev pkg-config libglib2.0-dev binutils-dev libboost-all-dev autoconf libtool libssl-dev libpixman-1-dev libpython-dev python-pip python-capstone virtualenv
sudo apt-get install libsdl1.2-dev libsdl1.2debian libsdl-gfx1.2-5 libsdl-gfx1.2-dev libsdl-gfx1.2-doc libsdl-image1.2 libsdl-image1.2-dbg libsdl-image1.2-dev libsdl-mixer1.2 libsdl-mixer1.2-dbg libsdl-mixer1.2-dev libsdl-net1.2 libsdl-net1.2-dbg libsdl-net1.2-dev libsdl-sound1.2 libsdl-sound1.2-dev libsdl-ttf2.0-0 libsdl-ttf2.0-dev
sudo apt-get install libgtk-3-dev libspice-server-dev libusb-1.0-0-dev libusbredirparser-dev
3. QEMU default command, (not working just given for reference)
qemu-system-x86_64 \
-enable-kvm -smp 2 \
-append "console=ttyS0 vt.global_cursor_default=0 androidboot.selinux=permissive debug drm.debug=0 -device VGA" \
-m 1024 \
-serial mon:stdio \
-kernel $HOME/AOSP/out/target/product/generic_x86_64/kernel-ranchu \
-initrd $HOME/AOSP/out/target/product/generic_x86_64/ramdisk.img \
-drive index=0,if=none,id=system,file=$HOME/AOSP/out/target/product/generic_x86_64/system.img \
-device virtio-blk-pci,drive=system \
-drive index=1,if=none,id=cache,file=$HOME/AOSP/out/target/product/generic_x86_64/cache.img \
-device virtio-blk-pci,drive=cache \
-drive index=2,if=none,id=userdata,file=$HOME/AOSP/out/target/product/generic_x86_64/userdata.img \
-device virtio-blk-pci,drive=userdata \
-netdev user,id=mynet,hostfwd=tcp::5400-:5555 -device virtio-net-pci,netdev=mynet \
-device virtio-mouse-pci -device virtio-keyboard-pci \
-d guest_errors \
-nodefaults \
-display gtk,gl=on
I will add an sample app later
Sample emulator app
shoaibsaikat said:
I will add an sample app later
Click to expand...
Click to collapse
Here is the emulator client app
https://github.com/shoaibsaikat/ScreenTransferFromAndroidEmulatorToPhone
Why the emulator repo isn't updates since 6 years ago? Where is the emulator app right now?

Preinstall APK to custom Android 10 ROM

Hey guys, I've tried to preinstall an prebuilt and signed APK to an Android 10 AOSP build, but when I launch the emulator locally the APK is not there... I've tried searching similar threads here and couldn't find any.
First I tried to build the "device/generic/armv7-a-neon" one, but no luck, then I've copied the config to my custom device and modified it there, still no luck. Here are my steps:
Bash:
repo init -u https://android.googlesource.com/platform/manifest -b android-security-10.0.0_r51
repo sync
echo "PRODUCT_PROPERTY_OVERRIDES += ro.config.low_ram=true" >> device/generic/armv7-a-neon/AndroidProducts.mk
#Add MyApp
mkdir packages/apps/MyApp
echo 'LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := MyApp
LOCAL_MODULE_TAGS := optional
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_SRC_FILES := MyApp.apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
include $(BUILD_PREBUILT)' >> packages/apps/MyApp/Android.mk
echo "PRODUCT_PACKAGES += MyApp" >> ~/WORKING_DIRECTORY/build/target/product/handheld_product.mk
source build/envsetup.sh
lunch aosp_arm-eng
#for my own custom device config I am using:
#lunch custom_armv7_neon-eng
make -j8
#after that I am copying the out/target/product/generic/system.img and out/target/product/generic/userdata.img to my local machine
#and running on my local AVD emulator, which I've created from scratch and specifying the system.img and userdata.img
emulator -avd Pixel_4_API_25_ARM -system ~/aosp/system.img -initdata ~/aosp/userdata.img
The emulator launches with the system and the apk is not preinstalled.
Any feedback would be very appreciated

How to Build Basic TWRP for a Android Device Android 9+

How to Build Basic TWRP for a Android Device Android 9+​​Note​
This is a basic method to build twrp. If twrp has bugs you have to fix it with your self according to your device
In samsung devices decryption/encryption cannot be fix easily and it need to modify kernel to fix mtp. most of time common bugs are mtp and decryption you need can find more info by referring more device trees
Click to expand...
Click to collapse
Prepare Environmet​
Create a github account​
Create a new empty repo​
Then log into gitpod using github account​
Open new workspace in gitpod,​
Select your new repo and selcect class as large​
​Make a device tree using twrpdtgen​
git clone https://github.com/twrpdtgen/twrpdtgen​
cd twrpdtgen​
sudo apt install cpio​
pip3 install twrpdtgen​
drag and drop the stock recovery.img to twrpdtgen folder​
python3 -m twrpdtgen <path to image>​
you will get twrp device tree at the out/manufature/code_name (eg: samsung/m01q)​
then copy manufature folder into root directory (workspace/name_of_your_github_repo)​
​
Install repo and packages​
sudo apt update​
sudo apt install rsync​
​​
repo init --depth=1 --no-repo-verify -u https://github.com/minimal-manifest-twrp/platform_manifest_twrp_aosp.git -b twrp-12.1 -g default,-mips,-darwin,-notdefault​
repo sync -c --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync -j8​
Place device tree​
​move manufature folder (created device tree) to device (EG: workspace/name_of_your_github_repo/device/samsung)​
Modify Device Tree​
open device.mk and add these​​Add support to fastbootd (skip the if your device dosnt have super.img)​Change the value according to shipped android os​
if android 10 = 29​if android 11 = 30​if android 12 = 31​if android 12.1 = 32​if android 13 = 33​
PRODUCT_PACKAGES += \
[email protected] \
fastbootd
PRODUCT_USE_DYNAMIC_PARTITIONS := true
PRODUCT_SHIPPING_API_LEVEL := 29
​Add device code name​​TARGET_OTA_ASSERT_DEVICE := m01q
TARGET_COPY_OUT_VENDOR := vendor
​TWRP FLAGS​​TARGET_RECOVERY_PIXEL_FORMAT := "RGBX_8888"
# TWRP specific build flags
TW_THEME := portrait_hdpi
RECOVERY_SDCARD_ON_DATA := true
TW_EXCLUDE_DEFAULT_USB_INIT := true
TW_EXTRA_LANGUAGES := true
TW_INCLUDE_NTFS_3G := true
TW_USE_TOOLBOX := true
TW_INCLUDE_RESETPROP := true
TW_INPUT_BLACKLIST := "hbtp_vm"
TW_BRIGHTNESS_PATH := "/sys/class/backlight/panel0-backlight/brightness"
TW_DEFAULT_BRIGHTNESS := 1200
TARGET_USES_MKE2FS := true
TW_NO_LEGACY_PROPS := true
TW_USE_NEW_MINADBD := true
TW_NO_BIND_SYSTEM := true
TW_NO_SCREEN_BLANK := true
TW_EXCLUDE_APEX := true
TW_FRAMERATE := 60
​TWRP Name​​TW_DEVICE_VERSION := smiley​​Enable notch​
TW_Y_OFFSET := 70
TW_H_OFFSET := -70
Reboot to odin for samsung​​TW_HAS_DOWNLOAD_MODE := true​​Enable Logcat​​TWRP_INCLUDE_LOGCAT := true[/HEADING]
[HEADING=2]TARGET_USES_LOGD := true​​Add fingerprint​​#Properties
TW_OVERRIDE_SYSTEM_PROPS := \
"ro.build.fingerprint=ro.system.build.fingerprint;ro.build.version.incremental"
Modify fstab​
Open recovery.fstab​
add this to end of line to enable partition backup and flash​
;backup=1;flashimg
add those to enable sdcard and otg​
# Removable storage
/external_sd vfat /dev/block/mmcblk1p1 /dev/block/mmcblk1 flags=storage;wipeingui;removable
/usb-otg auto /dev/block/sda1 /dev/block/sda flags=display="USB-OTG";storage;wipeingui;removable
Open BoradConfig,mk and modify values according to your device (skip if you dont have super.img)​
# Dynamic Partition
BOARD_SUPER_PARTITION_SIZE := 3945791488
BOARD_SUPER_PARTITION_GROUPS := android_dynamic_partitions
BOARD_ANDROID_DYNAMIC_PARTITIONS_SIZE := 3945791488
BOARD_ANDROID_DYNAMIC_PARTITIONS_PARTITION_LIST := system vendor product odm
Open Omni_device_code.mk​
$(call inherit-product, vendor/omni/config/common.mk)
rename omni to twrp​
$(call inherit-product, vendor/twrp/config/common.mk)
Build TWRP​
. build/envstup.sh
lunch (select your device-eng)
make recoveryimage
smiley9000 said:
How to Build Basic TWRP for a Android Device Android 9+​​Note​
Prepare Environmet​
Create a github account​
Create a new empty repo​
Then log into gitpod using github account​
Open new workspace in gitpod,​
Select your new repo and selcect class as large​
​Make a device tree using twrpdtgen​
git clone https://github.com/twrpdtgen/twrpdtgen​
cd twrpdtgen​
sudo apt install cpio​
pip3 install twrpdtgen​
drag and drop the stock recovery.img to twrpdtgen folder​
python3 -m twrpdtgen <path to image>​
you will get twrp device tree at the out/manufature/code_name (eg: samsung/m01q)​
then copy manufature folder into root directory (workspace/name_of_your_github_repo)​
​
Install repo and packages​
sudo apt update​
sudo apt install rsync​
​​
repo init --depth=1 --no-repo-verify -u https://github.com/minimal-manifest-twrp/platform_manifest_twrp_aosp.git -b twrp-12.1 -g default,-mips,-darwin,-notdefault​
repo sync -c --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync -j8​
Place device tree​
​move manufature folder (created device tree) to device (EG: workspace/name_of_your_github_repo/device/samsung)​
Modify Device Tree​
open device.mk and add these​​Add support to fastbootd (skip the if your device dosnt have super.img)​Change the value according to shipped android os​
if android 10 = 29​if android 11 = 30​if android 12 = 31​if android 12.1 = 32​if android 13 = 33​
PRODUCT_PACKAGES += \
[email protected] \
fastbootd
PRODUCT_USE_DYNAMIC_PARTITIONS := true
PRODUCT_SHIPPING_API_LEVEL := 29
​Add device code name​​TARGET_OTA_ASSERT_DEVICE := m01q
TARGET_COPY_OUT_VENDOR := vendor
​TWRP FLAGS​​TARGET_RECOVERY_PIXEL_FORMAT := "RGBX_8888"
# TWRP specific build flags
TW_THEME := portrait_hdpi
RECOVERY_SDCARD_ON_DATA := true
TW_EXCLUDE_DEFAULT_USB_INIT := true
TW_EXTRA_LANGUAGES := true
TW_INCLUDE_NTFS_3G := true
TW_USE_TOOLBOX := true
TW_INCLUDE_RESETPROP := true
TW_INPUT_BLACKLIST := "hbtp_vm"
TW_BRIGHTNESS_PATH := "/sys/class/backlight/panel0-backlight/brightness"
TW_DEFAULT_BRIGHTNESS := 1200
TARGET_USES_MKE2FS := true
TW_NO_LEGACY_PROPS := true
TW_USE_NEW_MINADBD := true
TW_NO_BIND_SYSTEM := true
TW_NO_SCREEN_BLANK := true
TW_EXCLUDE_APEX := true
TW_FRAMERATE := 60
​TWRP Name​​TW_DEVICE_VERSION := smiley​​Enable notch​
TW_Y_OFFSET := 70
TW_H_OFFSET := -70
Reboot to odin for samsung​​TW_HAS_DOWNLOAD_MODE := true​​Enable Logcat​​TWRP_INCLUDE_LOGCAT := true[/HEADING][/HEADING]
[HEADING=2][HEADING=2]TARGET_USES_LOGD := true​​Add fingerprint​​#Properties
TW_OVERRIDE_SYSTEM_PROPS := \
"ro.build.fingerprint=ro.system.build.fingerprint;ro.build.version.incremental"
Modify fstab​
Open recovery.fstab​
add this to end of line to enable partition backup and flash​
;backup=1;flashimg
add those to enable sdcard and otg​
# Removable storage
/external_sd vfat /dev/block/mmcblk1p1 /dev/block/mmcblk1 flags=storage;wipeingui;removable
/usb-otg auto /dev/block/sda1 /dev/block/sda flags=display="USB-OTG";storage;wipeingui;removable
Open BoradConfig,mk and modify values according to your device (skip if you dont have super.img)​
# Dynamic Partition
BOARD_SUPER_PARTITION_SIZE := 3945791488
BOARD_SUPER_PARTITION_GROUPS := android_dynamic_partitions
BOARD_ANDROID_DYNAMIC_PARTITIONS_SIZE := 3945791488
BOARD_ANDROID_DYNAMIC_PARTITIONS_PARTITION_LIST := system vendor product odm
Open Omni_device_code.mk​
$(call inherit-product, vendor/omni/config/common.mk)
rename omni to twrp​
$(call inherit-product, vendor/twrp/config/common.mk)
Build TWRP​
. build/envstup.sh
lunch (select your device-eng)
make recoveryimage
Click to expand...
Click to collapse
After creating a device tree, how does one find the required files that should go into the recovery/root folder to build TWRP
whale0z said:
After creating a device tree, how does one find the required files that should go into the recovery/root folder to build TWRP
Click to expand...
Click to collapse
try to find twrp device tree of similler soc and compare to make most succesfull device tree. but decryption is heavily depend on oem
smiley9000 said:
try to find twrp device tree of similler soc and compare to make most succesfull device tree. but decryption is heavily depend on oem
Click to expand...
Click to collapse
I was able to build for a mediatek device but fastboot boot doesn't seem to work. I was wondering if using fastboot flash would not mess with the normal boot sequence.
whale0z said:
I was able to build for a mediatek device but fastboot boot doesn't seem to work. I was wondering if using fastboot flash would not mess with the normal boot sequence.
Click to expand...
Click to collapse
Some device dosent support fastboot boot for security reasons
smiley9000 said:
How to Build Basic TWRP for a Android Device Android 9+​​Note​
Prepare Environmet​
Create a github account​
Create a new empty repo​
Then log into gitpod using github account​
Open new workspace in gitpod,​
Select your new repo and selcect class as large​
​Make a device tree using twrpdtgen​
git clone https://github.com/twrpdtgen/twrpdtgen​
cd twrpdtgen​
sudo apt install cpio​
pip3 install twrpdtgen​
drag and drop the stock recovery.img to twrpdtgen folder​
python3 -m twrpdtgen <path to image>​
you will get twrp device tree at the out/manufature/code_name (eg: samsung/m01q)​
then copy manufature folder into root directory (workspace/name_of_your_github_repo)​
​
Install repo and packages​
sudo apt update​
sudo apt install rsync​
​​
repo init --depth=1 --no-repo-verify -u https://github.com/minimal-manifest-twrp/platform_manifest_twrp_aosp.git -b twrp-12.1 -g default,-mips,-darwin,-notdefault​
repo sync -c --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync -j8​
Place device tree​
​move manufature folder (created device tree) to device (EG: workspace/name_of_your_github_repo/device/samsung)​
Modify Device Tree​
open device.mk and add these​​Add support to fastbootd (skip the if your device dosnt have super.img)​Change the value according to shipped android os​
if android 10 = 29​if android 11 = 30​if android 12 = 31​if android 12.1 = 32​if android 13 = 33​
PRODUCT_PACKAGES += \
[email protected] \
fastbootd
PRODUCT_USE_DYNAMIC_PARTITIONS := true
PRODUCT_SHIPPING_API_LEVEL := 29
​Add device code name​​TARGET_OTA_ASSERT_DEVICE := m01q
TARGET_COPY_OUT_VENDOR := vendor
​TWRP FLAGS​​TARGET_RECOVERY_PIXEL_FORMAT := "RGBX_8888"
# TWRP specific build flags
TW_THEME := portrait_hdpi
RECOVERY_SDCARD_ON_DATA := true
TW_EXCLUDE_DEFAULT_USB_INIT := true
TW_EXTRA_LANGUAGES := true
TW_INCLUDE_NTFS_3G := true
TW_USE_TOOLBOX := true
TW_INCLUDE_RESETPROP := true
TW_INPUT_BLACKLIST := "hbtp_vm"
TW_BRIGHTNESS_PATH := "/sys/class/backlight/panel0-backlight/brightness"
TW_DEFAULT_BRIGHTNESS := 1200
TARGET_USES_MKE2FS := true
TW_NO_LEGACY_PROPS := true
TW_USE_NEW_MINADBD := true
TW_NO_BIND_SYSTEM := true
TW_NO_SCREEN_BLANK := true
TW_EXCLUDE_APEX := true
TW_FRAMERATE := 60
​TWRP Name​​TW_DEVICE_VERSION := smiley​​Enable notch​
TW_Y_OFFSET := 70
TW_H_OFFSET := -70
Reboot to odin for samsung​​TW_HAS_DOWNLOAD_MODE := true​​Enable Logcat​​TWRP_INCLUDE_LOGCAT := true[/HEADING][/HEADING][/HEADING][/HEADING][/HEADING]
[HEADING=2][HEADING=2][HEADING=2][HEADING=2][HEADING=2]TARGET_USES_LOGD := true​​Add fingerprint​​#Properties
TW_OVERRIDE_SYSTEM_PROPS := \
"ro.build.fingerprint=ro.system.build.fingerprint;ro.build.version.incremental"
Modify fstab​
Open recovery.fstab​
add this to end of line to enable partition backup and flash​
;backup=1;flashimg
add those to enable sdcard and otg​
# Removable storage
/external_sd vfat /dev/block/mmcblk1p1 /dev/block/mmcblk1 flags=storage;wipeingui;removable
/usb-otg auto /dev/block/sda1 /dev/block/sda flags=display="USB-OTG";storage;wipeingui;removable
Open BoradConfig,mk and modify values according to your device (skip if you dont have super.img)​
# Dynamic Partition
BOARD_SUPER_PARTITION_SIZE := 3945791488
BOARD_SUPER_PARTITION_GROUPS := android_dynamic_partitions
BOARD_ANDROID_DYNAMIC_PARTITIONS_SIZE := 3945791488
BOARD_ANDROID_DYNAMIC_PARTITIONS_PARTITION_LIST := system vendor product odm
Open Omni_device_code.mk​
$(call inherit-product, vendor/omni/config/common.mk)
rename omni to twrp​
$(call inherit-product, vendor/twrp/config/common.mk)
Build TWRP​
. build/envstup.sh
lunch (select your device-eng)
make recoveryimage
Click to expand...
Click to collapse
hiya
after enter this command :
" repo sync -c --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync -j8 "​i got this error:
Usage: repo sync [<project>...]
main.py: error: option -j: invalid integer value: '8\u200b'
i think its about java , but java works fine.
================================================================================
gitpod /workspace/Nokia-5.3-twrp-device-tree (main) $ lunch
You're building on Linux
Lunch menu... pick a combo:
1. aosp_arm-eng
2. aosp_arm64-eng
3. aosp_x86-eng
4. aosp_x86_64-eng
5. omni_CAP_sprout-eng
6. omni_CAP_sprout-user
7. omni_CAP_sprout-userdebug
Which would you like? [aosp_arm-eng] 5
In file included from build/make/core/config.mk:313:
In file included from build/make/core/envsetup.mk:312:
In file included from build/make/target/product/telephony_vendor.mk:24:
device/hmd/CAP_sprout/device.mk:24: error: PRODUCT_STATIC_BOOT_CONTROL_HAL is obsolete. Use shared library module instead. See https://android.googlesource.com/platform/build/+/master/Changes.md#PRODUCT_STATIC_BOOT_CONTROL_HAL.
16:01:34 dumpvars failed with: exit status 1
Device CAP_sprout not found. Attempting to retrieve device repository from TeamWin Github (http://github.com/TeamWin).
Repository for CAP_sprout not found in the TeamWin Github repository list.
If this is in error, you may need to manually add it to your .repo/local_manifests/roomservice.xml
In file included from build/make/core/config.mk:313:
In file included from build/make/core/envsetup.mk:312:
In file included from build/make/target/product/telephony_vendor.mk:24:
device/hmd/CAP_sprout/device.mk:24: error: PRODUCT_STATIC_BOOT_CONTROL_HAL is obsolete. Use shared library module instead. See https://android.googlesource.com/platform/build/+/master/Changes.md#PRODUCT_STATIC_BOOT_CONTROL_HAL.
16:01:35 dumpvars failed with: exit status 1
In file included from build/make/core/config.mk:313:
In file included from build/make/core/envsetup.mk:312:
In file included from build/make/target/product/telephony_vendor.mk:24:
device/hmd/CAP_sprout/device.mk:24: error: PRODUCT_STATIC_BOOT_CONTROL_HAL is obsolete. Use shared library module instead. See https://android.googlesource.com/platform/build/+/master/Changes.md#PRODUCT_STATIC_BOOT_CONTROL_HAL.
16:01:35 dumpvars failed with: exit status 1
** Don't have a product spec for: 'omni_CAP_sprout'
** Do you have the right repo manifest?
========================================================================
new error:
device/hmd/CAP_sprout/Android.mk:13: error: cannot assign to readonly variable: PRODUCT_PACKAGES
16:15:14 ckati failed with: exit status 1
how can i fix it??
PRODUCT_PACKAGES += \
[email protected] \
fastbootd
MEYSAMKIA said:
hiya
after enter this command :
" repo sync -c --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync -j8 "​i got this error:
Usage: repo sync [<project>...]
main.py: error: option -j: invalid integer value: '8\u200b'
i think its about java , but java works fine.
================================================================================
gitpod /workspace/Nokia-5.3-twrp-device-tree (main) $ lunch
You're building on Linux
Lunch menu... pick a combo:
1. aosp_arm-eng
2. aosp_arm64-eng
3. aosp_x86-eng
4. aosp_x86_64-eng
5. omni_CAP_sprout-eng
6. omni_CAP_sprout-user
7. omni_CAP_sprout-userdebug
Which would you like? [aosp_arm-eng] 5
In file included from build/make/core/config.mk:313:
In file included from build/make/core/envsetup.mk:312:
In file included from build/make/target/product/telephony_vendor.mk:24:
device/hmd/CAP_sprout/device.mk:24: error: PRODUCT_STATIC_BOOT_CONTROL_HAL is obsolete. Use shared library module instead. See https://android.googlesource.com/platform/build/+/master/Changes.md#PRODUCT_STATIC_BOOT_CONTROL_HAL.
16:01:34 dumpvars failed with: exit status 1
Device CAP_sprout not found. Attempting to retrieve device repository from TeamWin Github (http://github.com/TeamWin).
Repository for CAP_sprout not found in the TeamWin Github repository list.
If this is in error, you may need to manually add it to your .repo/local_manifests/roomservice.xml
In file included from build/make/core/config.mk:313:
In file included from build/make/core/envsetup.mk:312:
In file included from build/make/target/product/telephony_vendor.mk:24:
device/hmd/CAP_sprout/device.mk:24: error: PRODUCT_STATIC_BOOT_CONTROL_HAL is obsolete. Use shared library module instead. See https://android.googlesource.com/platform/build/+/master/Changes.md#PRODUCT_STATIC_BOOT_CONTROL_HAL.
16:01:35 dumpvars failed with: exit status 1
In file included from build/make/core/config.mk:313:
In file included from build/make/core/envsetup.mk:312:
In file included from build/make/target/product/telephony_vendor.mk:24:
device/hmd/CAP_sprout/device.mk:24: error: PRODUCT_STATIC_BOOT_CONTROL_HAL is obsolete. Use shared library module instead. See https://android.googlesource.com/platform/build/+/master/Changes.md#PRODUCT_STATIC_BOOT_CONTROL_HAL.
16:01:35 dumpvars failed with: exit status 1
** Don't have a product spec for: 'omni_CAP_sprout'
** Do you have the right repo manifest?
========================================================================
new error:
device/hmd/CAP_sprout/Android.mk:13: error: cannot assign to readonly variable: PRODUCT_PACKAGES
16:15:14 ckati failed with: exit status 1
how can i fix it??
PRODUCT_PACKAGES += \
[email protected] \
fastbootd
Click to expand...
Click to collapse
Contact in telegram
@samsung_galaxy_m01_a01_m11_a11

Categories

Resources