🤖 👾 🎃 build Android - Raspberry Pi Q&A, Help & Troubleshooting

Bash:
git config --global your_acc
git config --global [email protected]
#git clone https://github.com/android-rpi/local_manifests
git clone https://github.com/android-rpi/local_manifests .repo/local_manifests -b arpi-12
~/bin/repo init -u https://android.googlesource.com/platform/manifest # Download Android source with local_manifests # Refer to http://source.android.com/source/downloading.html
repo init -u https://android.googlesource.com/platform/manifest -b android-s-beta-2
repo sync
repo sync --force-sync frameworks/av # overwriting
repo sync --force-sync external/mesa3d # dito
lunch # choose some device such as a raspberry Pi
# tapas # tool
m # build Android now
now watch those eerie error messages...
backlink

#### failed to build some targets (39 seconds) ####

Related

[Q] How to make a ROM?

Hello everyone.
Now I know this question has been posted before but I didn't get enough help from that so...
Let me explain what I've done...
I appreciate all of the work that the Devs have done, however, I would
love to help them.
I decided to try and build my own ROM. Unfortunately, I'm getting stuck and
am not sure how to proceed.
That is why I am here. I was hoping the wise devs here on XDA could help me
along this path I'm taking.
Here's my goal.
Build a 2.1 rom from source. No modifications at first.
Run this on an Emulator to see how it runs.
Then run it on my phone.
Here are the steps I've taken:
- Installed Ubuntu
- Installed jdk1.5
#sudo gedit /etc/apt/sources.list
-Add these lines
deb http://archive.ubuntu.com/ubuntu/ jaunty multiverse
deb-src http://archive.ubuntu.com/ubuntu/ jaunty multiverse
deb http://archive.ubuntu.com/ubuntu/ jaunty-updates multiverse
deb-src http://archive.ubuntu.com/ubuntu/ jaunty-updates multiverse
-Save and exit
#sudo apt-get update
#sudo apt-get install sun-java5-jdk
#sudo update-java-alternatives -s java-1.5.0-sun
-Install the dev tools
# sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev valgrind
# cd ~
# mkdir bin
# curl xxxx://android.git.kernel.org/repo >~/bin/repo
# chmod a+x ~/bin/repo
-Get the android source
# cd ~
# mkdir mydroid
# cd mydroid
# repo init -u git://android.git.kernel.org/platform/manifest.git -b android-2.1_r2
# repo sync
-Download the samsung files from opensource.samsung.com
-Search for SGH-I897 and download the tar
# cd ~/Downloads
# mkdir samsung_files
# mv SGH-I897_OpenSource.tar.gz samsung_files/
# cd samsung_files
# tar xzvf SGH-I897_OpenSource.tar.gz
# tar xvf Platform.tar
-Merge the files together
# cd ~/Downloads/samsung_files/Captivate_eclair
# rsync -a --stats --progress dalvik/ ~/mydroid/dalvik/
# rsync -a --stats --progress external/ ~/mydroid/external/
# rsync -a --stats --progress prebuilt/ ~/mydroid/prebuilt/
# rsync -a --stats --progress vendor/ ~/mydroid/vendor/
-Modify the BoardConfig.mk
# sudo gedit ~/mydroid/build/target/board/generic/BoardConfig.mk
-Add these lines
BOARD_HAVE_BLUETOOTH := true
BT_USE_BTL_IF := true
BT_ALT_STACK := true
BRCM_BTL_INCLUDE_A2DP := true
BRCM_BT_USE_BTL_IF := true
-Compile the ROM
# cd ~/mydroid
# make update-api
# make
Now I browsed through the out directory after the Make was complete
and found some .img files:
ramdisk.img
system.img
userdata.img
userdata-qemu.img
I don't have anything for a Kernel and am confused as to how to
take these files and make a .zip that I can flash through CWM
Any direction from here would be greatly appreciated.
i.e.
How to make this run on an emulator.
How to turn this in to a .zip to flash through CWM
Also some tips on modifying the ROM would be nice
i always assumed it was some sort of magic or wizardry.....but all that **** you just said sounds pretty important, too.

[Q] Compiling a simple kernel module for N1

I followed the instructions listed here to compile the kernel from the source and was successful. Next, I saw some instructions here on how to compile our own loadable kernel modules:
Code:
First we must retrieve and copy the kernel config from our device.
$ cd /path/to/android-sdk/tools
$ ./adk pull /proc/config.gz
$ gunzip ./config.gz
$ cp config /path/to/kernel/.config
Next we have to prepare our kernel source for our module.
$ cd /path/to/kernel
$ make ARCH=arm CROSS_COMPILE=/path/to/android-ndk/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/arm-eabi- modules_prepare
PREPARING YOUR MODULE FOR COMPILATION
We need to create a Makefile to cross-compile our kernel module. The contents of your Makefile should be similar to the following:
obj-m := modulename.o
KDIR := /path/to/kernel
PWD := $(shell pwd)
CCPATH := /path/to/android-ndk/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin
default:
$(MAKE) ARCH=arm CROSS_COMPILE=$(CCPATH)/arm-eabi- -C $(KDIR) M=$(PWD) modules
COMPILING AND INSTALLING YOUR MODULE
$ cd /path/to/module/src
$ make
$ cd /path/to/android-sdk/tools/
$ ./adb push /path/to/module/src/modulename.ko /sdcard/modulename.ko
RUNNING YOUR MODULE
$ cd /path/to/android-sdk/
$ ./adb shell
$ su
# insmod /sdcard/modulename.ko
When I try executing:
Code:
make ARCH=arm CROSS_COMPILE=/path/to/android-ndk/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/arm-eabi- modules_prepare
I get an error:
Code:
make: *** No rule to make target `modules_prepare`. Stop.
Can someone please tell me if I am missing something here?
EliteLegend said:
I followed the instructions listed here to compile the kernel from the source and was successful. Next, I saw some instructions here on how to compile our own loadable kernel modules:
Code:
First we must retrieve and copy the kernel config from our device.
$ cd /path/to/android-sdk/tools
$ ./adk pull /proc/config.gz
$ gunzip ./config.gz
$ cp config /path/to/kernel/.config
Next we have to prepare our kernel source for our module.
$ cd /path/to/kernel
$ make ARCH=arm CROSS_COMPILE=/path/to/android-ndk/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/arm-eabi- modules_prepare
PREPARING YOUR MODULE FOR COMPILATION
We need to create a Makefile to cross-compile our kernel module. The contents of your Makefile should be similar to the following:
obj-m := modulename.o
KDIR := /path/to/kernel
PWD := $(shell pwd)
CCPATH := /path/to/android-ndk/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin
default:
$(MAKE) ARCH=arm CROSS_COMPILE=$(CCPATH)/arm-eabi- -C $(KDIR) M=$(PWD) modules
COMPILING AND INSTALLING YOUR MODULE
$ cd /path/to/module/src
$ make
$ cd /path/to/android-sdk/tools/
$ ./adb push /path/to/module/src/modulename.ko /sdcard/modulename.ko
RUNNING YOUR MODULE
$ cd /path/to/android-sdk/
$ ./adb shell
$ su
# insmod /sdcard/modulename.ko
When I try executing:
Code:
make ARCH=arm CROSS_COMPILE=/path/to/android-ndk/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/arm-eabi- modules_prepare
I get an error:
Code:
make: *** No rule to make target `modules_prepare`. Stop.
Can someone please tell me if I am missing something here?
Click to expand...
Click to collapse
The topic is old but the reply may be useful for other people:
this is the tipical issue when is missing the .config file which is a defconfig to be taken from /kernelfolder/arch/arm/configs

[Guide] A beginners guide to building and modifying a nexus 4 kernel from source

A beginners guide to building and modifying a nexus 4 lollipop* kernel from source.
*currently 5.0.1​Disclaimer
I am not a developer, nor am I an expert. All the information in here I have gleaned from other sources, credited where possible, so it may not be correct and almost certainly isn't the 'best' way to do things. But it works for me. I hope it works for you but there's no guarantee. Use at your own risk
Assumptions
You have access to a computer running Ubuntu - other distros will probably work but this is the one I'm using. You'll need a basic understanding of the Linux command line including, but not limited to, ls, cp, cd, mkdir, make, ~, sudo, nano and so on.
You'll need to know how to use adb & fastboot to copy stuff into and out of your Nexus 4
A basic undersanding of Git is REALLY helpful if you want to modify your kernel. You'll be able to get by using the comands listed but you really need to have a basic understanding of what Git does if you're going to proceed.
CONTENTS
Initialise your build environment
Downloading the sources
Toolchain
Building
Creating a boot.img
A bit more about Git
Modifying kernels (how I got DT2W working)
Making a flashable zip
Initialise your build envronment
The information for this stage came from: here
I installed Ubuntu 14.04.1 LTS from a scratch. I used VM ware on a Windows laptop but any Linux environment can probably be made to work. So, to start, do an update just to be sure, then install the packages you'll need.
Code:
# sudo apt-get update
# sudo apt-get install bison g++-multilib git gperf libxml2-utils
# sudo apt-get install libncurses5-dev:i386
# sudo apt-get install lib32ncurses5-dev
# sudo apt-get install build-essential kernel-package
Downloads
Most of the really helpful information I've used came from here
I've updated the information slightly and changed the device from Flo to Mako but Pete's page is well worth reading for more background information than I've included here.
To download the source into a 'kernel' folder
Code:
# mkdir ~/android
# cd ~/android/
# git clone https://android.googlesource.com/kernel/msm.git kernel
# cd kernel/
# git branch -a
will show you all the current branches of Mako kernels, choose the one you want and checkout that one.
Code:
# git checkout android-msm-mako-3.4-lollipop-release
Now you need to find out exactly which kernel to build. The 'official' method is here
but that involves a significant download for just a few bytes so I suggest you use the following trick. Go to the pre-built kernel you want to copy here
and you wll see the first line after the header is:-
"16e203d lowmemorykiller: enhance debug information"
You need to make a note of the first seven characters, in this case 16e203d.
Next you need to use Git to create a new branch for our specific kernel. I've called it 'android-lollipop-release'.
Code:
# git checkout -b android-lollipop-release 16e203d
This will extract the source for the kernel we're going to build.
Toolchain
I'm using the stock toolchain (thanks @zaclimon) but will add an alternative suggested by @aviz1911 as time allows.
I'm going to install the toolchain in /usr/local/share but there are other places you could sensibly put it.
Code:
# cd /usr/local/share
sudo git clone [url]https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7[/url]
Export the path to the toolchain and check it works. Note these exports only work for the current session, if you want to add permanently put it in your .bashrc or .profile
Code:
# export PATH=$PATH:/usr/local/share/arm-eabi-4.7/bin
# cd ~
Test it works with
Code:
# arm-eabi-gcc --version
Now you need to tell the system we want to cross compile.
Code:
# export ARCH=arm
# export SUBARCH=arm
# export CROSS_COMPILE=arm-eabi-
Building
Now you're ready to start.
Code:
#cd ~/android/kernel
# make mako_defconfig
You'll get some warnings like this which you can ignore
warning: (ARCH_MSM_KRAITMP && ARCH_MSM_CORTEX_A5) selects HAVE_HW_BRKPT_RESERVED_RW_ACCESS which has unmet direct dependencies (HAVE_HW_BREAKPOINT)
Code:
# make menuconfig
this is where you can make some changes if you like, we're going to change just the name. Choose General Setup ---> then select
(-perf) Local version - append to kernel release
and change perf to anything you like, I'll use dt2w
Save and exit
Code:
# make -j2
where 2 is twice the number of cores on your machine - there's just one processor on my VM but could be many more on yours. It takes more than half an hour on my machine. Then you should see
Code:
Kernel: arch/arm/boot/zImage is ready
Ta Daaaaa - you have built a kernel - now you need to pack it for testing on your phone.
Creating a boot.img
Again I'm going to use Pete's blog post as my guide but omit some details and just get the job done. I'm not going to explain all the steps, you'll have to investigate yourself if you want to understand more.
Code:
# cd ~/android
# git clone https://github.com/pbatard/bootimg-tools.git bootimg-tools
# cd bootimg-tools/libmincrypt/
# gcc -c *.c -I../include
# # cd ../mkbootimg
# gcc mkbootimg.c -o mkbootimg -I../include ../libmincrypt/libmincrypt.a
# sudo cp mkbootimg /usr/local/bin/
# gcc -o unmkbootimg unmkbootimg.c
# sudo cp unmkbootimg /usr/local/bin/
You need an original boot img to copy so you can insert your new kernel into it. Download the factory image.
Code:
# mkdir ~/android/boot
# cd ~/android/boot
# wget https://dl.google.com/dl/android/aosp/occam-lrx22c-factory-86c04af6.tgz
# tar -xvf occam-lrx22c-factory-86c04af6.tgz
# cd occam-lrx22c/
# unzip occam-lrx22c-factory-86c04af6.zip
# cp boot.img ../
# cd ~/android/boot
Now it's time to unpack the original boot image. unmkbooting will tell you all the parameters you need to repack the boot image with your new kernel inside.
Code:
# unmkbootimg -i boot.img
kernel written to 'kernel' (6009416 bytes)
ramdisk written to 'ramdisk.cpio.gz' (490557 bytes)
To rebuild this boot image, you can use the command:
mkbootimg --base 0 --pagesize 2048 --kernel_offset 0x80208000 --ramdisk_offset 0x81800000 --second_offset 0x81100000 --tags_offset 0x80200100 --cmdline 'console=ttyHSL0,115200,n8 androidboot.hardware=mako lpj=67677 user_debug=31' --kernel kernel --ramdisk ramdisk.cpio.gz -o boot.img
Code:
# cp ~/android/kernel/arch/arm/boot/zImage ~/android/boot/
Repack your new boot image with your new kernel using the information from unmkbootimg
Code:
mkbootimg --base 0 --pagesize 2048 --kernel_offset 0x80208000 --ramdisk_offset 0x81800000 --second_offset 0x81100000 --tags_offset 0x80200100 --cmdline 'console=ttyHSL0,115200,n8 androidboot.hardware=mako lpj=67677 user_debug=31' --kernel zImage --ramdisk ramdisk.cpio.gz -o new_boot.img
Nore that kernel has been changed to zImage and output file has been changed new_boot.img Now it's time to test your new_boot.img by rebooting your phone into bootloader and reboot with the new img.
DO NOT FLASH THE NEW IMAGE.
fastboot boot new_boot.img NOT fastboot flash boot new_boot.img
If all has gone well your phone will now boot with your new kernel. If something has gone wrong just reboot the phone and you'll be back to where you started. If it has all worked then you can flash the new boot image and use that.
A bit more about Git
If like me, you know nothing about Git, then this bit of the guide is for you. If you have basic understanding this will be too simple for you and you'll have to skip this bit and look elsewhere. If you have a basic understanding of any version control software you won't need this either as the necessary commands to complete the next step will be self explanatory.
Jump to the next stage here
Git is a version control system. To understand what it does at a most basic level follow these steps
Code:
# mkdir git_test
# cd git_test
# git init
Tell git who you are. You don't need the inverted commas, just an email address and a name. Keep this information for when/if you open a Github account.
Code:
# git config --global user.email "[email protected]"
# git config --global user.name "Your Name"
create a text file called 'text' with a single line of text that says "This is the first line"
add this file to your git
Code:
# git add text
commit the change with a message
Code:
git commit -m "first line"
create a new branch (checkout -b both creates and makes the new branch current)
Code:
git checkout -b newbranch
edit the 'text' file by adding another line "this is the second line"
add and commit the change to git
Code:
# git add text
# git commit -m "second line"
Then examine the text file, as you might expect it looks like this
Code:
# cat text
this the first line
this is the second line
but if we now go back to the master branch and checkout THE SAME file, we get a different result
Code:
# git checkout master
cat text
this the first line
The second line is not present because it was only added to the 'newbranch' branch. This, it appears to me is the essence of git, it changes files depending on which branch you're viewing them from.
Now we're going to look at how we can use git to extract files from someone else's repository in order to get the files we want for our needs.
There are loads of guides that help you to learn more, I found this video particularly helpful.
https://www.youtube.com/watch?v=1ffBJ4sVUb4
Still to come
Modifying kernels (how I got DT2W working)
Edit:- It's going to be a while before I complete this section as although I managed to build a working kernel I'm pretty sure I didn't do it the 'right' way so I'm reading the Git Pro book.
Will be back later. .. . .
Awesome guide dude. This will surely help a lot of people
Nice
Nice guide, wish you'd have written it a week earlier
Anyways, what i'd really like to know, is how to patch the Linux version properly, because my attempts lead to break the kernel in the process. Didn't get beyond 3.4.11 :/
Hope you can help me out there, buddy.
How to create a zip ?
I have been looking into this and created a kernel a few days ago. But i want to share it.
For that ill have to create a zip. I have searched for it. I think its done using anykernel template.
The issuse is can i use the certificates in the meta-inf folder and the update-binary that is 4 years old ?
Or should i just unzip a kernel , modify the script and place my boot.img. 
 @aviz1911
Unzipping and re zipping is pretty easy, I'd do that.
@Nicknoxx How's the reading up on git going? Any tips on enabling dt2w would be much appreciated. I've been trying but can't seem to get it to work
I'm really new at the Kernel stuff and just wanted to build stock with dt2w as my first project.
Thanks for the first part of the guide
Wow nice guide sir, i'll try it later
Great Guide!
Thanks Mate!!
what all lines or links should i have to modify if i am building kernel for my device oneplus one lollipop ?
 @Nicknoxx
Also @Nicknoxx one can use the -b argument with git while cloning so git just downloads a single branch of the kernel source, this'll save bandwidth and time to some extent
Like
git clone https://android.googlesource.com/kernel/msm.git -bx kernel
Replace x with desired branch name
Click to expand...
Click to collapse
̿ ̿̿’̿’\̵͇̿̿\з==(*͡° ͜ʖ ͡°)==ε/̵͇̿̿/’̿’̿ ̿ ̿̿*
---------- Post added at 08:26 PM ---------- Previous post was at 08:21 PM ----------
Droid.Riz said:
what all lines or links should i have to modify if i am building kernel for my device oneplus one lollipop ?
@Nicknoxx
Click to expand...
Click to collapse
Use the cm kernel source from github.com/CyanogenMod in git clone
Just type
git clone https://github.com/CyanogenMod/android_kernel_oneplus_msm8974 kernel
Click to expand...
Click to collapse
And for compiling
make bacon_defconfig
Click to expand...
Click to collapse
̿ ̿̿’̿’\̵͇̿̿\з==(*͡° ͜ʖ ͡°)==ε/̵͇̿̿/’̿’̿ ̿ ̿̿*
KNIGHT97 said:
Also @Nicknoxx one can use the -b argument with git while cloning so git just downloads a single branch of the kernel source, this'll save bandwidth and time to some extent
Like
̿ ̿̿’̿’\̵͇̿̿\з==(*͡° ͜ʖ ͡°)==ε/̵͇̿̿/’̿’̿ ̿ ̿̿*
---------- Post added at 08:26 PM ---------- Previous post was at 08:21 PM ----------
Use the cm kernel source from github.com/CyanogenMod in git clone
Just type
And for compiling
̿ ̿̿’̿’\̵͇̿̿\з==(*͡° ͜ʖ ͡°)==ε/̵͇̿̿/’̿’̿ ̿ ̿̿*
Click to expand...
Click to collapse
thanks a lot for quick reply i will start it today itself @ night.
after successfully compiling i will reply here
Nice guide. I ad it to my collection. I mis the part about building the modules. For wifi and so on. I think the command is "make modules"
Maby ad some info about updating a kernel. ICS to JB. KK to LP and sow on.
How about the command to clean after building?
[email protected] said:
Nice guide. I ad it to my collection. I mis the part about building the modules. For wifi and so on. I think the command is "make modules"
Maby ad some info about updating a kernel. ICS to JB. KK to LP and sow on.
How about the command to clean after building?
Click to expand...
Click to collapse
Executing the make -j# command automatically builds your modules along with the Zimage, you'll just need to read last few lines in terminal to know the modules and where they reside
̿ ̿̿’̿’\̵͇̿̿\з==(*͡° ͜ʖ ͡°)==ε/̵͇̿̿/’̿’̿ ̿ ̿̿*
Hi guys,
How i can implement this mod/patch in my kernel??
http://forum.xda-developers.com/android/software-hacking/kernel-tap2unlock-tap2wake-feature-t2965344

Ethernet support on XSP?

Hello guys,
I need some help here, I want to add Ethernet driver to my XSP, but I don't know what to do
Currently my XSP ROM is AICP (still on old version, Lollipop), with Helium kernel
I already built the asix.ko module, using this guide, and DooMLoRD' Android Toolchain
When I tried to "insmod asix.ko" on my XSP terminal, it returns error
Code:
init_module failed (Exec format error)
And this is my makefile on ASIX driver
Code:
CURRENT = $(shell uname -r)
TARGET = asix
OBJS = asix.o
MDIR = drivers/net/usb
KDIR = /home/smankusors/Projects/XSP_ASIX_Driver/helium_kernel
SUBLEVEL= $(shell uname -r | cut -d '.' -f 3 | cut -d '.' -f 1 | cut -d '-' -f 1 | cut -d '_' -f 1)
ifneq (,$(filter $(SUBLEVEL),14 15 16 17 18 19 20 21))
MDIR = drivers/usb/net
endif
EXTRA_CFLAGS = -DEXPORT_SYMTAB
PWD = $(shell pwd)
DEST = /lib/modules/$(CURRENT)/kernel/$(MDIR)
obj-m := $(TARGET).o
default:
make ARCH=arm CROSS_COMPILE=/home/smankusors/Projects/XSP_ASIX_Driver/android_prebuilt_toolchains/arm-linux-androideabi-4.7/bin/arm-linux-androideabi- -C $(KDIR) SUBDIRS=$(PWD) modules
$(TARGET).o: $(OBJS)
$(LD) $(LD_RFLAG) -r -o [email protected] $(OBJS)
install:
su -c "cp -v $(TARGET).ko $(DEST) && /sbin/depmod -a"
clean:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean
.PHONY: modules clean
-include $(KDIR)/Rules.make
What I exactly do :
1. Download the android prebuilt toolchains, kernel sourcecode, asix sourcecode
2. Modify the makefile from ASIX sourcecode
3. Make from it
4. Flash to my XSP along with the helium kernel
5. Error.
Is there anything wrong? :crying:

How To Guide How to compile TWRP for the ASUS Zenfone 8

There are a lot of web pages about building your own TWRP image in the internet but at least I did not find a HowTo with all necessary instructions and infos in one place.
Therefor I wrote this little HowTo about building a TWRP image for the ASUS Zenfone 8. The instructions in the HowTo can also be used to create TWRP images for other phones supported by TWRP. The HowTo is for a PC running the Linux OS.
Note that this HowTo can only be used for phones that are officially supported by TWRP.
In the end, creating a TWRP image is also quite easy once you know how it works, thanks to the well-done setup of the development environment by the TWRP developer.
Prereqs
The repositories with the manifests for TWRP are here https://github.com/minimal-manifest-twrp and the repositories with the TWRP files and the device trees for the phones supported by TWRP are here: https://github.com/TeamWin . So you need access to github for creating your own TWRP image.
The tool repo is required to maintain the repositories for TWRP; you can download repo from https://gerrit.googlesource.com/git-repo
It's not necessary to install additional tools for creating an TWRP image -- all necessary tools to create the image are in the repositories for TWRP.
Note
To check if there is a repository with the device tree for another phone for TWRP use the search function on the page https://github.com/TeamWin and search for the device ID of the phone.
To search via script use (I006D is the device ID for the ASUS Zenfone 8):
Bash:
wget "https://api.github.com/search/repositories?q=I006D" -O ./repository_list
Spoiler: search example for the ASUS Zenfone 8
Code:
[ OmniRom 13 Dev - [email protected] /data/develop/android/twrpX ] $ wget "https://api.github.com/search/repositories?q=I006D" -O ./repository_list
--2022-11-27 09:20:27-- https://api.github.com/search/repositories?q=I006D
Resolving api.github.com (api.github.com)... 140.82.121.5
Connecting to api.github.com (api.github.com)|140.82.121.5|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/json]
Saving to: ‘./repository_list’
./repository_list [ <=> ] 46.30K --.-KB/s in 0.01s
2022-11-27 09:20:28 (3.55 MB/s) - ‘./repository_list’ saved [47414]
[ OmniRom 13 Dev - [email protected] /data/develop/android/twrpX ] $
[ OmniRom 13 Dev - [email protected] /data/develop/android/twrpX ] $ grep "full_name" ./repository_list
"full_name": "CaptainThrowback/android_device_asus_I006D",
"full_name": "nguyenhung9xdev2022/android_kernel_asus_I006D",
"full_name": "nguyenhung9xdev2022/android_vendor_asus_I006D",
"full_name": "nguyenhung9xdev2022/android_device_asus_I006D",
"full_name": "asus-development/android_device_asus_I006D",
"full_name": "OpenPecha-Data/I006D4C7E",
"full_name": "dmd79/android_device_asus_I006D",
[ OmniRom 13 Dev - [email protected] /data/develop/android/twrpX ] $
To get the device ID for a phone execute :
Bash:
adb shell getprop ro.product.system.device
e,g.
Code:
#
# on a PC for a connected ASUS Zenfone 8
#
[[email protected] /data/develop/android/twrp]$ adb shell getprop ro.product.system.device
I006D
[[email protected] /data/develop/android/twrp]$
#
# on the ZUK Z2 Pro
#
z2_row:/ # getprop ro.product.system.device
z2_row
z2_row:/ #
The device ID is required for the lunch command used to copy the repositories with the device trees (see below).
Building the ROM
First copy the necessary repositories for building TWRP to your local machine using these commands:
Bash:
#
# create a new directory for the repositories (optional)
#
mkdir twrp
cd twrp
# init the local repositories
#
# As of 27.11.2022 the latest version of the TWRP repositories is 12.1 ;
# to download the default repository version you can omit the parameter "-b twrp-12.1"
# As of 27.11.2022 the repositories for TWRP 12.1 use about 45 GB; to save some
# space (about 12 GB) you could add the parameter --depth=1
#
repo init -u https://github.com/minimal-manifest-twrp/platform_manifest_twrp_aosp.git -b twrp-12.1
# sync the repositories (Parameter -j8 = use 8 parallel jobs; adjust this parameter to
# the number of CPU available on your PC)
#
repo sync -c -j8 --force-sync --no-clone-bundle --no-tags
Next add the device dependent repositories for the ASUS Zenfone 8.
The format of the parameter for the lunch command is
twrp_<device_id>-eng
So the parameter for the ASUS Zenfone 8 is twrp_I006D-eng.
Bash:
#
# init the environment to build the TWRP image
#
. build/envsetup.sh
export ALLOW_MISSING_DEPENDENCIES=true
lunch twrp_I006D-eng
Spoiler: lunch example
Code:
TWRP Dev - [email protected] /data/develop/android/twrp ] $ lunch twrp_I006D-eng
In file included from build/make/core/config.mk:313:
In file included from build/make/core/envsetup.mk:312:
build/make/core/product_config.mk:160: error: Can not locate config makefile for product "twrp_I006D".
11:35:37 dumpvars failed with: exit status 1
Device I006D not found. Attempting to retrieve device repository from TeamWin Github (http://github.com/TeamWin).
Found repository: android_device_asus_I006D
Checking branch info
Calculated revision: android-12.1
Adding dependency:
Repository: android_device_asus_I006D
Branch: android-12.1
Remote: TeamWin
Path: device/asus/I006D
Syncing repository to retrieve project.
Fetching: 100% (1/1), done in 12.846s
NOT Garbage collecting: 0% (0/1), done in 0.001s
repo sync has finished successfully.
Repository synced!
Looking for dependencies
Adding dependencies to manifest
Adding dependency:
Repository: android_device_asus_sm8350-common
Branch: android-12.1
Remote: TeamWin
Path: device/asus/sm8350-common
Syncing dependencies
Fetching: 100% (1/1), done in 15.848s
NOT Garbage collecting: 0% (0/1), done in 0.001s
repo sync has finished successfully.
Looking for dependencies
device/asus/sm8350-common has no additional dependencies.
Done
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=99.87.36
TARGET_PRODUCT=twrp_I006D
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv8-a
TARGET_2ND_CPU_VARIANT=generic
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-6.0.9-200.fc36.x86_64-x86_64-Fedora-Linux-36-(MATE-Compiz)
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=SP2A.220405.004
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES=device/asus/sm8350-common
============================================
[ TWRP Dev - [email protected] /data/develop/android/twrp ] $
And final build the TWRP image
Bash:
mka bootimage
Spoiler: mka bootimage example
Code:
[ TWRP Dev - [email protected] /data/develop/android/twrp ] $ time mka bootimage
build/make/core/soong_config.mk:197: warning: BOARD_PLAT_PUBLIC_SEPOLICY_DIR has been deprecated. Use SYSTEM_EXT_PUBLIC_SEPOLICY_DIRS instead.
build/make/core/soong_config.mk:198: warning: BOARD_PLAT_PRIVATE_SEPOLICY_DIR has been deprecated. Use SYSTEM_EXT_PRIVATE_SEPOLICY_DIRS instead.
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=99.87.36
TARGET_PRODUCT=twrp_I006D
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv8-a
TARGET_2ND_CPU_VARIANT=generic
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-6.0.9-200.fc36.x86_64-x86_64-Fedora-Linux-36-(MATE-Compiz)
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=SP2A.220405.004
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES=device/asus/sm8350-common
============================================
[ 78% 246/312] including bootable/recovery/Android.mk ...
bootable/recovery/prebuilt/Android.mk:437: warning: vendor_hw: bootable/recovery/prebuilt/relink.sh out/target/product/I006D/recovery/root/vendor/bin/hw
[ 95% 299/312] including system/sepolicy/Android.mk ...
system/sepolicy/Android.mk:57: warning: BOARD_PLAT_PUBLIC_SEPOLICY_DIR has been deprecated. Use SYSTEM_EXT_PUBLIC_SEPOLICY_DIRS instead.
system/sepolicy/Android.mk:62: warning: BOARD_PLAT_PRIVATE_SEPOLICY_DIR has been deprecated. Use SYSTEM_EXT_PRIVATE_SEPOLICY_DIRS instead.
[ 30% 8637/28297] //bionic/libc:libc_bionic clang arch-arm64/bionic/setjmp.S
....
Removing unneeded service: keymaster-4-1-citadel
Service_Cleanup script complete.
[100% 28297/28297] Target boot image from recovery: out/target/product/I006D/boot.img
#### build completed successfully (14:50 (mm:ss)) ####
real 14m50.110s
user 182m6.217s
sys 11m58.492s
[ TWRP Dev - [email protected] /data/develop/android/twrp ] $
Note:
For devices without A/B devices use mka recoveryimage.
The TWRP image will be created in file boot.img the directory ./out/target/product/I006D e.g.:
Code:
[ TWRP Dev - [email protected]t15g /data/develop/android/twrp ] $ ls -ltr out/target/product/I006D/boot.img
-rw-rw-r--. 1 xtrnaw7 xtrnaw7 100663296 Nov 27 12:06 out/target/product/I006D/boot.img
[ TWRP Dev - [email protected] /data/develop/android/twrp ] $
To test the image just boot the phone from the image
Bash:
adb reboot bootloader
sudo fastboot boot out/target/product/I006D/boot.img
And check if the boot was succesfull:
Code:
[ OmniRom 13 Dev - [email protected] /data/develop/android/twrpX ] $ adb shell getprop ro.bootmode
unknown
[ OmniRom 13 Dev - [email protected] /data/develop/android/twrpX ] $
unknown is the expected value here.
Trouble Shooting
On some pages I found a hint that the build scripts require python2 and will not work with python3. But this is most probably not true anymore because building the image with python3 worked without problems.
It's strongly recommended to use separate sessions for compiling OmniROM or TWRP or even different versions of TWRP:
All these build environments define the same commands in the file ./build/envsetup.sh but with different functionality.
As of 27.11.2022 there are only 2 branches in the repository with the manifests for TWRP : version 11 and version 12.1.
If there is no branch for one of these versions in the repositories for the device tree of the phone for which you want to create a TWRP image the lunch command will fail.
The repositories with the manifests for TWRP prior to version 11 can be fetched with this command:
Bash:
# Minimal manifest for building TWRP for devices shipped with Android 5.1 through Android 9.0
#
repo init -u https://github.com/minimal-manifest-twrp/platform_manifest_twrp_omni.git -b twrp-9.0
Note that the lunch command in the old repositories does work different.
Notes:
The URL to the repository with the device tree for a phone is also on the page for the device on the TWRP device list: https://twrp.me/Devices/
See https://unofficialtwrp.com/build-compile-twrp-recovery for other possible settings for the build
see here for How to add additional files to an TWRP image
XDA Forum thread about compiling TWRP: How to compile TWRP touch recovery

Categories

Resources