yashsingh1/xdaforums huggingface dataset:
[Android Software Development] JoJakson:
Hi,

I want to build a TWRP recovery for a new device in order to install OpenGapps (and yes I want to do this myself) and possibly later a custom ROM.

I have analysed the device and I have retrieved information on fstab, partitions, SOC, version, RAM, ROM etc. and retrieved also the vendor files (a lot of libs and some fw, etc.). I think in know the device configuration.

Questions:

1.) BUT do I need all vendor information if I only want to build a recovery image or do I need the this only if I want to build a custom ROM?

3.) I also found the kernel config for the original ROM on the device and tried to build from kernel sources just to try - which lead to some compilation errors ...

BUT Do I need the full android/linux kernel sources to build a recovery image or only for the custom ROM?

2.) The devices runs on Android 8.1 and has rather old SOC (snapdragon 210 / msm8909 ) I could not find a TWRP "example" for 8.1 with an SOC msm8909. I started with the configuration of an device existing in twrp-8.1 "/lge/bullhead".

BUT Can I / is it better to use the device info from an existing old device with msm8909 running under 6.0 as starting point?

What is the minimum configuration (files) needed to build TWRP, please?

Thanks,

JoJakson
[Android Software Development] a-dead-trousers:
Hi @JoJakson

1) Vendor files are mostly needed in a recovery to get "special" configurations to work. e.g. data encryption. On the other hand as of Android 9 or 10 someone who wants to build a custom ROM would leave the vendor image untouched and only tempers with the device specific files found on system.

3) You don't need to have a kernel as source code, but it helps nevertheless (e.g. security updates). Even though the build environment warns in big purple letters it is still possible to use a prebuilt (stock) kernel.

2) I would suggest you try to find the most recent device tree for a device with the same chipset as a starting point. The android version itself is not the primary basis for decisions. Even newer editions are able to boot with an older kernel and especially a recovery doesn't need much to work. Most of the time it only takes 4 config files, the stock fstab and the kernel to get a recovery to work.

wkr ADT
[Android Software Development] JoJakson:
@adt

Thanks for that it clarifies a lot

--> start from SOC and not the Android version!

BR. JoJakson
[Android Software Development] nikolai_g:
Hello,

I have two silly questions before trying to build my TWRP (for Nokia 8.3 running Android 11):

- at this point, it is a pointless exercise to attempt doing it given that Android 11 does not seem to be officially supported (yet)?

- the guide on the first page from 2012 - is it still sufficiently up-to-date or the page 2xx contains more updated one by any chance? ;) I admit I did not go through all 234 pages in this mega-thread.

Thanks!
[Android Software Development] djvinniev77:
Hi guys!

Figure I'd throw it out there as I'm stuck on TWRP 3.5 not working to modify system partitions as it's read-only..

Device is Umidigi BISON, android 10, I checked and doesn't have A/B partition but does have a "super" img file when flashing with SP Flash.

I was successful in building TWRP for this with the latest minimal omni source twrp 10.0. I think my mounts are not correct.

I pulled my data using SebaUbuntu's TWRP device tree generator and my factory recovery.img

I've been trying to modify the recovery.fstab then rebuilding but I think I'm missing the fundamentals regarding android 10, it mounts system, vendor, product as read-only.

my device tree

GitHub - djvinniev77/android_device_umidigi_bison: stuff for Umidigi Bison

stuff for Umidigi Bison. Contribute to djvinniev77/android_device_umidigi_bison development by creating an account on GitHub.

github.com

Anyone got a fully functional TWRP for mediatek device running Android 10 and a "super" partition? How did you do it?

Thanks!
[Android Software Development] a-dead-trousers:
Have a look on mine:

GitHub - ADeadTrousers/twrp_device_Unihertz_Atom_XL_EEA: Device tree for the Unihertz Atom XL EEA (european union)

Device tree for the Unihertz Atom XL EEA (european union) - GitHub - ADeadTrousers/twrp_device_Unihertz_Atom_XL_EEA: Device tree for the Unihertz Atom XL EEA (european union)

github.com

I'm currently stuck on decryption.

/data/system gets decrypted.

/data/media/0 doesn't decrypt.

/data/system_de doesn't decrypt (it's where te user keys are stored for /data/media/0)

EDIT: Honestly, keep away from those "device tree generators". They only do the bare minimum and even fail on that on such (rare breed) devices like mediatek.
[Android Software Development] djvinniev77:
Thanks! Will do!
[Android Software Development] djvinniev77:
I think I'm on the same boat.

I see folder structure when I go into file manager, but all the items are garbled and it complains that I don't have the right keys to make changes.

I tried to remount / as RW from twrp shell, but the encryption/decryption part seems to be not working with TWRP.

I'm rebuilding it again with some of the encryption items you have in BoardConfig.mk but most likely I'll be facing the same deal..

under /data/system - trying to add a "test" file, says required key not available.
[Android Software Development] a-dead-trousers:
Best way to start is analyzing your stock rom (vendor partition) to see which trustkernel service implementation it uses (mine is teed/t6). Then recreate that in the recovery. Next is copying keymaster service from stock. If you are lucky you have a gatekeeper.password.key or gatekeeper.pattern.key file on your /data/system then it's simply configuring/copying gatekeeper service. If you don't have one of theese two you share the same fate as me.
[Android Software Development] djvinniev77:
So both your device and my device use AVB files found in the boot ramimage. I grabbed the stock files for your phone as well to compare on mine and dissected the boot.img file with CarlivImageKitchen. found the avb folder referenced by the boot fstab file. I ended up using that as recovery.fstab, and ensured I copied the avb folder I pulled from boot, into the recovery/root folder.

The net result is that I no longer have any issues with TWRP reading /system_root (maybe it's a combination of something else but I've never gotten this far on my build) and the funny part is that it's still being marked as read only. The boot fstab calls on the partitions as ro when mounting, I'm currently building it again with marking the partitions as rw, hoping something comes out of this.

When I included the AVB files, I also no longer have an issue with the /nvram when trying to flash magisk or dm-verity zips to install. The only error I see in TWRP at first boot is that it's unable to update logical partition: /odmdtbo - not sure how important that is.

The storage is still "encrypted" where I see gibberish in some locations, but /system_root was fully readable, just did not let me save any edits as it's "read only" .. I'm hoping to change that.
[Android Software Development] a-dead-trousers:
/odmdtbo is not there, trust me. It seems that this ROM is partly used for other devices too which offer such a partition.

The encryption, like I said, is different per device/vendor so only a rough course of actions can be given. Maybe, if you can identify the trustkernel implementaion you could hopefully find similar device trees on github & co like I did.

About ro and rw: I don't think it's possible to get system, vendor and product into rw-mode cause they are all part of the bigger super partition. The only way to get things onto them, I believe, is to use a "flash" operation (sideload, zip or img).

EDIT: Use the "twrp.fstab" of my device tree as a templae and NOT the "fstab.mt6771" (it's only there for me for reference purposes and is not integrated into the recovery)
[Android Software Development] jannat24bd:
Need to download
[Android Software Development] djvinniev77:
regarding flashing img: Been finding out some odd things about flash operations on this device (BISON) as for flashing, need fastbootd mode to flash system.img properly (available in stock recovery) but you should also flash a patched vbmeta to make it boot properly, which is not in fastbootd mode (just on bootloader mode) - did this trying to get a GSI up and running. (failed)

most of the docs about this only deal with flashing things in the same mode (userspace/fastbootd mode) but the device setup seems to have them split.

I would figure the TWRP system should also recognize the partitions properly, to flash directly. If I try to flash an img vs a zip, I have the option on dumping it into super, which doesn't work. In your current build do you see the same thing? Curious to see if your device behaves just like mine.
[Android Software Development] a-dead-trousers:
super can be flashed from bootloader too (at least on my device) same as vbmeta, boot and recovery. You need to deactivate the OEM lock from within the ROM though.

zip flashing (and sideload for that matter) uses script files inside the archive to determine the target while with img you decide which partition to target.

So using zip I'm not able to select anything within TWRP and using img all partitions (sans system, product and vendor as they are part of super) are available to flash onto. Crutial for that to work of course is that the fstab features the correct entries.
[Android Software Development] djvinniev77:
Regarding this:

super can be flashed from bootloader too (at least on my device) same as vbmeta, boot and recovery. You need to deactivate the OEM lock from within the ROM though.

Whoa whoa. Didn't know there's an OEM lock in the rom itself. (That's not bootloader unlock is it?) Using all stock on this device I can't go through the steps to flash GSI, errors out on trying to flash due to super, need the reboot to fastbootd mode in order to touch the super partition. I know of the bootloader unlock, that's done. But everything else doesn't follow through, and I think this device may not be the only one to suffer (others reported similar situation in the treble experiments thread in GitHub)
[Android Software Development] Stockarm:
Can u support a205f it's hard to build it
[Android Software Development] DiamondJohn:
This thread is about getting help with YOU building TWRP, not having others build it for you. Try, and then come back with any errors for help.
[Android Software Development] james28909:
Is there a way to pull configs and everything needed from a rooted device if you do not have source for said device? I have a twrp that is a little older but would like to update it if possible. I tried to manually patch it with mtk auto twrp, and while it seems to build it and it boots, I can not get it to actually mount anything no matter what I try. Would be neat to be able to build it.
[Android Software Development] a-dead-trousers:
You'd need the kernel, the fstab and maybe some init.rc-scripts from the stock ROM (not the recovery). With that and some similar devices to your own as a "template" you could set up a twrp device tree. Don't use a "auto" twrp tool as they tend to be too straightforward to consider every aspect of your device especially the mediatek ones.

As you seem to have a mediatek device the best thing to do is to find out your chipset (mine is mt6771 or Helios P60) and search for that on github. Chances are there is a quite similar device tree there you can use a guideline.

EDIT: The fstab and init.rc-scripts can be pulled from the running stock rom or from an official stock rom update file. The kernel itself can be obtained by some tools or also from an official stock rom update file.
[Android Software Development] a-dead-trousers:
My bad. You are right. It's in fact the same. My LOS reports this switch as "OEM unlock" and with a smaler font underneath "Permit bootloader unlocking".
[Android Software Development] james28909:
I have a twrp that does work, but it is an older version I think. Do you think If I upload it could you look at it and tell me how I could patch in new twrp?
[Android Software Development] a-dead-trousers:
You are going at this the wrong way. Like I said: First analyze the chipset. Then find a similar device (or use the device tree your twrp is based on). Next set up your own device tree (using this threads OP as guideline). And finally build your own twrp.
[Android Software Development] a-dead-trousers:
Now I've a problem that I need help with solving:

https://xdaforums.com/t/help-twrp-stuck-on-half-decrypted-data.4249013/

I couldn't find any other similar device that did something different than me and they all claim that they are able to decrypt. I also tried to seek help from the developers at the TWRP irc-channel but no one was willing (or able) to help me with that. Maybe here "in the wild" I can find someone who had this problem and was able to solve it.
[Android Software Development] Stockarm:
K
[Android Software Development] chris_groessler:
Where do I find an up-to-date source code?

On https://github.com/omnirom/android_bootable_recovery the latest change (in branch android-9.0) was 15 moths ago. But recently TWRP versions were released, for example 3.5.2 on April 7th.

regards,

chris
[Android Software Development] :
Can I compile it for SM-T805S? No TWRP found for SM-T805S!

CODENAME = chagallhlteskt
[Android Software Development] a-dead-trousers:
The correct link is https://github.com/TeamWin/android_bootable_recovery (as in the text on the first post, not in the actual link). But best is to use the minimal-manifest.
[Android Software Development] a-dead-trousers:
I can't see a reason why not.
[Android Software Development] kodein:
Can anyone compile the file I sent?

I would be grateful for instructions on how to do it ...
[Android Software Development] tyler19820201:
I am trying to build a TWRP for my device OP8T. As i never did this before no experience and i do not know what does it mean this:

"If you add or change any flags, you will need to make clean or make clobber before recompiling or your flag changes will not be picked up."

What is this clobber thing??
[Android Software Development] tyler19820201:
minimal manifest does not support android 11 ? As i saw 10 is the highest branch...
[Android Software Development] DiamondJohn:
Clobber wipes a partial build and starts the whole build process from the begining.

make clobber;

For TWRP, its not such a big ask, as it only takes 8 minutes (on my box) to build it from go to woah, but doing a clobber on a full ROM can be arduous, as that could take 2hrs to start again and get to where your up to, with some people taking >24hrs. Starting from where it left off could save you a lot of time on a full ROM.

Perssonally, I run the clobber on any build I expect to flash to my phone. Just to ensure I have a "clean" repeatable build.
[Android Software Development] a-dead-trousers:
That's because it's not officially supported yet. They just recently made the jump to 10.0 as it needed a code restructuring. But that's no problem. You could still build TWRP for 10.0 and use it with a 11.0 ROM as they are two seperate entities and don't interact with each other.

If you are interested in building 11.0 reguardless of it being officially supported you could change the branch values inside the manifests xml from "10" to "11". But as there are quite many different repositories with different naming schemes you'd need to check if the name is indeed the right branch.

Maybe someone already did that on one of the many forks of platform_manifest_twrp_omni. You'd just need to search.
[Android Software Development] tyler19820201:
#### build completed successfully (1 seconds) ####

============================================

PLATFORM_VERSION_CODENAME=REL

PLATFORM_VERSION=16.1.0

TARGET_PRODUCT=omni_OnePlus8T

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=armv7-a-neon

TARGET_2ND_CPU_VARIANT=generic

HOST_ARCH=x86_64

HOST_2ND_ARCH=x86

HOST_OS=linux

HOST_OS_EXTRA=Linux-5.4.0-56-generic-x86_64-Ubuntu-20.04.2-LTS

HOST_CROSS_OS=windows

HOST_CROSS_ARCH=x86

HOST_CROSS_2ND_ARCH=x86_64

HOST_BUILD_TYPE=release

BUILD_ID=QQ3A.200805.001

OUT_DIR=/home/tyler/Dokumentumok/android_bootable_recovery/out

ROM_BUILDTYPE=HOMEMADE

============================================

[ 31% 139/444] including applypatch/Android.mk ...

FAILED:

build/make/core/base_rules.mk:325: error: applypatch: MODULE.TARGET.STATIC_LIBRARIES.libapplypatch already defined by applypatch.

09:47:01 ckati failed with: exit status 1

#### failed to build some targets (01:14 (mm:ss)) ####

I was trying to find this module.target.static_libraries but could not. What is this error exactly? Also have found applypatch folder and applypatch.h and .cpp file but i do not really know what to modify there...

Also base_rules.mk file says:

ifdef $(module_id)

$(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id)))

endif

$(module_id) := $(LOCAL_PATH)

but no idea what to change in order to fix this error...

Also was trying google this issue. It looks like libapplypatch duplicated...however i could not find the duplication...
[Android Software Development] chris_groessler:
Thank you! People who can read are better off :)
[Android Software Development] Lossyx:
No, building TWRP with A11 sources is required, considering the binder changes and due to the fact his device is using keymaster4.1. Right now, one must sync the whole AOSP source, specifically 11_r29.
[Android Software Development] PEACH-PIT:
I'm trying to build twrp for moto g 5g (Motorola One 5G Ace).

GitHub - moto-sm7250/android_device_motorola_kiev at android-10

DT for Moto G 5G / One 5G Ace. Contribute to moto-sm7250/android_device_motorola_kiev development by creating an account on GitHub.

github.com

How do I build this?

I have installed bbqlinux in VirtualBox, which is required for the build.

This is my first time to build it.

GitHub - minimal-manifest-twrp/platform_manifest_twrp_omni at twrp-10.0-deprecated

Minimal manifest for building TWRP for devices shipped with Android 5.1 through Android 9.0 - GitHub - minimal-manifest-twrp/platform_manifest_twrp_omni at twrp-10.0-deprecated

github.com

I don't understand it even if I look here.
[Android Software Development] bobbyp1086:
It failed for me using the Linux for windows, Ubuntu 16.04. But it's pretty much all commands. Get the recovery img, out it in folder and ya. Hard to follow I know. But if you give me a bit I just cracked my bios so I can get bbq up and going as a os instead of emulator. And try again. This Android 10 is a tricky little firefly
[Android Software Development] PEACH-PIT:
There is no twrp for "moto g 5g" yet, but the source was available.

https://github.com/moto-sm7250/android_device_motorola_kiev/tree/android-10

You can download the code from here.

I downloaded the code from here and placed it in /twrp/device/motorola/kiev

repo init -u git://github.com/minimal-manifest-twrp/platform_manifest_twrp_omni.git -b twrp-10.0
repo sync

make clean
. build/envsetup.sh
export LC_ALL=C
lunch omni_kiev-eng
make -j4 recoveryimage 2>&1 | tee twrp_$(date '+%Y%m%d_%H-%M-%S').log

This was the first time I built a twrp.

I used bbqlinux in VirtualBox.

The build was somehow successful.

I was able to control it with otg.

However, the touch does not work.

How can I fix this?
[Android Software Development] Animux:
I tried to build TWRP with A11 sources, it builds but it did not work. No touch and no otg on startup. Any ideas? The same device tree works with A10 sources.
[Android Software Development] ineedroot69:
you provably need to add the extracted ramdisk content via PRODUCT_COPY_FILES or import proprietary vendor files
[Android Software Development] PEACH-PIT:
In the thread, the modified kernel has been uploaded.

I built it using it.

The touch panel now works if no password, pin, or pattern is set on the smartphone.

However, if they are set, the touch panel will not work on the password, pin, and pattern input screen.

Since the password, pin, and pattern cannot be entered, the protection cannot be released without the otg mouse.

I think the cause is that I am loading the necessary modules from the main unit and updating the driver of the main unit.

What should I do?
[Android Software Development] ineedroot69:
look like somebody push some changes for your TWRP device tree for your device moto g 5g in the last 2 days i recommend doing repo sync and compiling it once again if that issue still persist file issue complain on your TWRP device tree github page
[Android Software Development] PEACH-PIT:
I didn't realize there was a change.

It seemed that the kernel had been fixed.

There were no errors in the build, but the touch panel was not perfect.

If you set up passwords, pins, etc. on android, twrp cannot read the module and you cannot enter passwords, pins, or patterns.

You end up needing an otg mouse.
[Android Software Development] tyler19820201:
I have done platform_manifest_twrp_omni repo sync and I have created device tree. But ./build/envsetup.sh: command not found...is this python related issue? Or what is going wrong?

Also where need to copy device/oneplus/kebab folder? manifest_twrp root folder??
[Android Software Development] ineedroot69:
what is your device folder structure? for instance

device/samsung/galaxy_y
[Android Software Development] tyler19820201:
device/oneplus/kebab
[Android Software Development] ineedroot69:
you have vendorsetup.sh?
[Android Software Development] tyler19820201:
yes.

however if i try to run . build/envsetup.sh or ./envsetup.sh (depends where i am at the directory structure) i am getting command not found.

why is that? my bashrc set up already.
[Android Software Development] ineedroot69:
you are using minimal twrp?

just do cd command on where you have done repo sync for minimal TWRP ...

Doing . build/envsetup.sh outside the folder would provably result on command not found

for instance i created multiple folder on home directory named twrp8.1,twrp9,twrp10 ..etc then i would do cd command then repo sync that specific branch of twrp minimal on that folder ...

also are you on ubuntu?
[Android Software Development] tyler19820201:
I am on kubuntu 20.04. So yeah basically ubuntu. :) But i try to build android 11 based twrp so i downloaded only the latest 10 branch...i did the device kernel and copied into the root of minimal twrp i created. device/oneplus/kebab
[Android Software Development] tyler19820201:
dogbin - epemetylop

Device tree: https://github.com/tyler820201/OnePlus8T Vendor tree: prebuilt Kernel Source: prebuilt

del.dog

I am facing with this ninja issue now. How can i fix it?
[Android Software Development] ineedroot69:
can i suggest something?
[Android Software Development] tyler19820201:
yes, go for it.

I was heading over this error but i have a new one. :( ckati error. I should have enough RAM and also was trying make -j2 recoveryimage reducing the number from 4 but does not help.
[Android Software Development] ineedroot69:
I know this is pretty off topic but i don't have trouble compiling TWRP so far i compiled for Android 5 ,6 ,7 , 8.1 and 9 but i like to compile for Android 10 but my virtual machine is already 89GB in size ... i only have 7GB left on my Local Disk C: on my windows and it won't let me do repo sync for minimal twrp android 10.0 since it's say not enough memory

it look like virtual machine is not actually freeing my memory even i deleted old compiled projects on recycle bin of the virtual machine what can i do??