Code Monkey home page Code Monkey logo

twrpdtgen's Introduction

twrpdtgen

PyPi version Codacy Badge

Create a TWRP-compatible device tree only from an Android recovery image (or a boot image if the device uses non-dynamic partitions A/B) of your device's stock ROM It has been confirmed that this script supports images built starting from Android 4.4 up to Android 12

Requires Python 3.8 or greater

Installation

pip3 install twrpdtgen

Linux only: Be sure to have cpio installed in your system (Install cpio using sudo apt install cpio or sudo pacman -S cpio based on what package manager you're using)

Instructions

python3 -m twrpdtgen <path to image>

When an image is provided, if everything goes well, there will be a device tree at output/manufacturer/codename

You can also use the module in a script, with the following code:

from twrpdtgen.device_tree import DeviceTree

# Get image info
device_tree = DeviceTree(image_path)

# Dump device tree to folder
device_tree.dump_to_folder(output_path)

License

#
# Copyright (C) 2022 The Android Open Source Project
#
# SPDX-License-Identifier: Apache-2.0
#

twrpdtgen's People

Contributors

dependabot[bot] avatar dereference23 avatar hemantsachdeva avatar sebaubuntu avatar techyminati avatar tiann avatar trkzmn avatar yshalsager avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twrpdtgen's Issues

AssertionError: Device codename could not be found in build.prop

Device: Huawei Y6 Prime 2018
Model: ATU-L31


`python3 -m twrpdtgen --huawei --recovery_kernel RECOVERY_KERNEL --recovery_ramdisk RECOVERY_RAMDISK --recovery_vendor RECOVERY_VENDOR
TWRP device tree generator
Version 1.3.0

[INFO] Cloning AIK...
[INFO] Cloning AIK...
[INFO] Cloning AIK...
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/hadenix/.local/lib/python3.8/site-packages/twrpdtgen/main.py", line 52, in
dt = DeviceTree(args.output, recovery_image=args.recovery_image,
File "/home/hadenix/.local/lib/python3.8/site-packages/twrpdtgen/device_tree.py", line 60, in init
self.build_prop_reader = BuildPropReader(self.build_prop)
File "/home/hadenix/.local/lib/python3.8/site-packages/twrpdtgen/info_extractors/buildprop.py", line 28, in init
self.codename = self.get_prop(DEVICE_CODENAME, "codename")
File "/home/hadenix/.local/lib/python3.8/site-packages/twrpdtgen/info_extractors/buildprop.py", line 61, in get_prop
raise AssertionError(f"Device {error} could not be found in build.prop")
AssertionError: Device codename could not be found in build.prop`

Is it normal for me to have to remote - from my device name>

Thank you for your work.

I have a question about my lenovo TB-8403F1 that I was hoping you could answer? Everytime I run the generator it creates output/lenovo/TB-8403F, and when I try to compile with TWRP it complains about unable to find device omni_tb. The only way I have been getting by this is using SED to remove all traces of the - between TB-8403 and make it TB8403F. Is this going to affect anything in my recovery build by doing this?

No such file or directory

[INFO] Cloning AIK...
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/data/data/com.termux/files/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/twrpdtgen/main.py", line 28, in
dt = generate_device_tree(args.recovery_image, args.output, no_git=args.no_git, keep_aik=args.keep_aik)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/twrpdtgen/twrp_dt_gen.py", line 30, in generate_device_tree
aik.extract(recovery_image)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/twrpdtgen/utils/aik_manager.py", line 64, in extract
self.get_image_infos()
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/twrpdtgen/utils/aik_manager.py", line 79, in get_image_infos
self.base_address = self.read_recovery_file(self.get_extracted_info("base"))
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/twrpdtgen/utils/aik_manager.py", line 108, in read_recovery_file
return file.read_text().splitlines()[0]
File "/data/data/com.termux/files/usr/lib/python3.9/pathlib.py", line 1255, in read_text
with self.open(mode='r', encoding=encoding, errors=errors) as f:
File "/data/data/com.termux/files/usr/lib/python3.9/pathlib.py", line 1241, in open
return io.open(self, mode, buffering, encoding, errors, newline,
File "/data/data/com.termux/files/usr/lib/python3.9/pathlib.py", line 1109, in _opener
return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/data/data/com.termux/files/usr/tmp/tmpois75698/split_img/recovery.img-base'

AssertionError: Property ro.product.cpu.abi could not be found in build.prop

The script crashes on failing to find a ro.product.cpu.abi property in the build.prop file.

My understanding is that ro.product.cpu.abi is in fact deprecated, and ro.product.cpu.abilist is the current
property name. ro.product.cpu.abilist lists the supported ABIs in descending order of feature-richness.

That's how my ROMs build.prop file looks like :

> cat recovery/ramdisk/vendor/build.prop | grep cpu
ro.vendor.product.cpu.abilist=arm64-v8a,armeabi-v7a,armeabi
ro.vendor.product.cpu.abilist32=armeabi-v7a,armeabi
ro.vendor.product.cpu.abilist64=arm64-v8a

Adding ro.product.cpu.abi=arm64-v8a to the build.prop file allows the script to continue.

Fix idea : Check if ro.product.cpu.abilist / ro.vendor.product.cpu.abilist exists, if it does pick the leftmost property. Otherwise look for ro.product.cpu.abi.

How to deal with this problem

root@PC:/home/pc/tee# python3 -m twrpdtgen recovery.img
TWRP device tree generator
Version 2.0.1

Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/pc/tee/twrpdtgen/main.py", line 6, in
main()
File "/home/pc/tee/twrpdtgen/main.py", line 31, in main
device_tree = DeviceTree(image=args.image, debug=args.debug)
File "/home/pc/tee/twrpdtgen/devicetree.py", line 62, in init
self.deviceinfo = DeviceInfo(self.buildprop)
File "/home/pc/tee/twrpdtgen/utils/deviceinfo.py", line 74, in init
self.codename = self.get_prop(DEVICE_CODENAME)
File "/home/pc/tee/twrpdtgen/utils/deviceinfo.py", line 93, in get_prop
raise AssertionError(f'Property {props[0]} could not be found in build.prop')
AssertionError: Property ro.product.device could not be found in build.prop

Any solutions Sir

$ python3 -m twrpdtgen recovery.img
TWRP device tree generator
Version 1.2.5

[INFO] Cloning AIK...
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/data/data/com.termux/files/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/twrpdtgen/main.py", line 52, in
dt = DeviceTree(args.output, recovery_image=args.recovery_image,
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/twrpdtgen/device_tree.py", line 49, in init
aik.extract(recovery_image)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/twrpdtgen/utils/aik_manager.py", line 74, in extract raise RuntimeError(f"AIK extraction failed, return code {returncode}") RuntimeError: AIK extraction failed, return code 1

Can't unpack if magic and androidbootimg.magic are in windows langage

Hello i post you an issue and how to resolve it. i investigate and see what the problem and how to correct.

I clone your repository on windows and use py -m twrpdtgen TWRP331-BV9900_Android9-2019.img
For me py are python3 and python are for python2
Screenshot_1

After this i manually catch AIK from your repo and unzip in folder extract and try like this, oh nice it's working.

i compare with WinMerge original AIK and my github zip from your repo and see this
Screenshot_2

Due to this i search what the difference and all this file have something common, all are encoded in windows where other files are encoded on unix.

Screenshot_6

Simple fix and the really blocking file are 'androidbootimg.magic' and 'magic' need to changed to unix encoding and after this work fine.

This is the error when 'magic' file are unix encode but 'androidbootimg.magic' file are windows
Screenshot_9

This is the error when 'magic' file are windows encode but 'androidbootimg.magic' file are unix
Screenshot_8

Python errors?

First, Thank you very much for putting this together. I am very grateful for your efforts and hard work. I am building for a Sonim XP8. This is the error that I am getting,

dfghom1:/home/glenn/TWRP-device-tree-generator # python3 -m twrpdtgen XP8A_ATT-   user-8A.0.5-11-8.1.0-10.54.00.zip
TWRP device tree generator
Python Edition
Version 1.0.0

AIK is up-to-date
Getting device infos...
Traceback (most recent call last):
  File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
   exec(code, run_globals)
  File "/home/glenn/TWRP-device-tree-generator/twrpdtgen/__main__.py", line 6, in <module>
    main()
  File "/home/glenn/TWRP-device-tree-generator/twrpdtgen/twrp_dt_gen.py", line 56, in main
    build_prop = BuildPropReader(aik_ramdisk_path / "default.prop")
  File "/home/glenn/TWRP-device-tree-generator/twrpdtgen/info_extractors/buildprop.py", line 46, in __init__
   self._content = self._filename.read_text()
  File "/usr/lib64/python3.6/pathlib.py", line 1196, in read_text
   with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib64/python3.6/pathlib.py", line 1183, in open
   opener=self._opener)
  File "/usr/lib64/python3.6/pathlib.py", line 1037, in _opener
    return self._accessor.open(self, flags, mode)
  File "/usr/lib64/python3.6/pathlib.py", line 387, in wrapped
    return strfunc(str(pathobj), *args)
  FileNotFoundError: [Errno 2] No such file or directory: '/home/glenn/TWRP-device-tree-generator/extract/ramdisk   /default.prop'

Is the problem with my Python version (3.6.10), or possibly with the zip file that I am using?
Thanks for taking the time to read this, as well as answering if you choose to do so. Kindest regards. Glenn

Ошибка Phuton

Не могу понять почему у меня такая ошибка?

D:\TWRP-device-tree-generator-master>python -m twrpdtgen D:\Users\Chapay\Desktop\recovery.img
Traceback (most recent call last):
File "C:\Python\lib\site-packages\git_init_.py", line 83, in
refresh()
File "C:\Python\lib\site-packages\git_init_.py", line 73, in refresh
if not Git.refresh(path=path):
File "C:\Python\lib\site-packages\git\cmd.py", line 278, in refresh
raise ImportError(err)
ImportError: Bad git executable.
The git executable must be specified in one of the following ways:
- be included in your $PATH
- be set via $GIT_PYTHON_GIT_EXECUTABLE
- explicitly set via git.refresh()

All git commands will error until this is rectified.

This initial warning can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
- quiet|q|silence|s|none|n|0: for no warning or exception
- warn|w|warning|1: for a printed warning
- error|e|raise|r|2: for a raised exception

Example:
export GIT_PYTHON_REFRESH=quiet

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Python\lib\runpy.py", line 194, in _run_module_as_main
return run_code(code, main_globals, None,
File "C:\Python\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "D:\TWRP-device-tree-generator-master\twrpdtgen_main
.py", line 3, in
from twrpdtgen.twrp_dt_gen import main
File "D:\TWRP-device-tree-generator-master\twrpdtgen\twrp_dt_gen.py", line 9, in
from git import Repo
File "C:\Python\lib\site-packages\git_init
.py", line 85, in
raise ImportError('Failed to initialize: {0}'.format(exc)) from exc
ImportError: Failed to initialize: Bad git executable.
The git executable must be specified in one of the following ways:
- be included in your $PATH
- be set via $GIT_PYTHON_GIT_EXECUTABLE
- explicitly set via git.refresh()

All git commands will error until this is rectified.

This initial warning can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
- quiet|q|silence|s|none|n|0: for no warning or exception
- warn|w|warning|1: for a printed warning
- error|e|raise|r|2: for a raised exception

Example:
export GIT_PYTHON_REFRESH=quiet

help

when I had builded Lenovo tb j706,show:Error: Recovery image doesn't exist.
Should recovery.img be unpacked? Or img format?

twrp_dt_gen.py issue

there is one more error

default recovery.fstab location set in twrp_dt_gen.py is

ramdisk/etc/recovery.fstab

but some recovery image's fstab file is located in

ramdisk/system/etc/recovery.fstab

So I had to edit it myself. I think you have to fix it too.

Script should ask for build.prop values manually if it can't find them.

I attempted to use this script on a recovery image from the Realme V5 (shipped with Android 10). The recovery ramdisk does have a default.prop, but it's a symlink to another file in the system partition, and the script can't read from it.

Instead of raising an exception, it would be helpful if the script could ask the user if it can't find the default.prop or any values in an existing default.prop.

Traceback error (Apparently that's it)

I tried to use this generator, but I received this error, I don't understand if something I'm doing, although it's probably that, I will still leave the message that the terminal

licht@q4os-desktop:~/Documentos/twrp$ python3 -m twrpdtgen recovery.img
Traceback (most recent call last):
  File "/home/licht/.local/lib/python3.7/site-packages/git/__init__.py", line 83, in <module>
    refresh()
  File "/home/licht/.local/lib/python3.7/site-packages/git/__init__.py", line 73, in refresh
    if not Git.refresh(path=path):
  File "/home/licht/.local/lib/python3.7/site-packages/git/cmd.py", line 278, in refresh
    raise ImportError(err)
ImportError: Bad git executable.
The git executable must be specified in one of the following ways:
    - be included in your $PATH
    - be set via $GIT_PYTHON_GIT_EXECUTABLE
    - explicitly set via git.refresh()

All git commands will error until this is rectified.

This initial warning can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
    - quiet|q|silence|s|none|n|0: for no warning or exception
    - warn|w|warning|1: for a printed warning
    - error|e|raise|r|2: for a raised exception

Example:
    export GIT_PYTHON_REFRESH=quiet


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/licht/.local/lib/python3.7/site-packages/twrpdtgen/__main__.py", line 6, in <module>
    from twrpdtgen.device_tree import DeviceTree
  File "/home/licht/.local/lib/python3.7/site-packages/twrpdtgen/device_tree.py", line 7, in <module>
    from git import Repo
  File "/home/licht/.local/lib/python3.7/site-packages/git/__init__.py", line 85, in <module>
    raise ImportError('Failed to initialize: {0}'.format(exc)) from exc
ImportError: Failed to initialize: Bad git executable.
The git executable must be specified in one of the following ways:
    - be included in your $PATH
    - be set via $GIT_PYTHON_GIT_EXECUTABLE
    - explicitly set via git.refresh()

All git commands will error until this is rectified.

This initial warning can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
    - quiet|q|silence|s|none|n|0: for no warning or exception
    - warn|w|warning|1: for a printed warning
    - error|e|raise|r|2: for a raised exception

Example:
    export GIT_PYTHON_REFRESH=quiet

some errors occurred

shaw@ubuntu:~/TWRP-device-tree-generator-master$ python3 -m twrpdtgen '/home/shaw/Desktop/11/669boot.img'
TWRP device tree generator
Version 2.0.1

Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/shaw/TWRP-device-tree-generator-master/twrpdtgen/main.py", line 6, in
main()
File "/home/shaw/TWRP-device-tree-generator-master/twrpdtgen/main.py", line 31, in main
device_tree = DeviceTree(image=args.image, debug=args.debug)
File "/home/shaw/TWRP-device-tree-generator-master/twrpdtgen/devicetree.py", line 49, in init
self.aik = AIKManager(image, debug=debug)
File "/home/shaw/TWRP-device-tree-generator-master/twrpdtgen/utils/aikmanager.py", line 74, in init
raise RuntimeError(f"AIK extraction failed, return code {returncode}")
RuntimeError: AIK extraction failed, return code 1

aise AssertionError(f"Device {error} could not be found in build.prop") when generting tree from android 9.0 twrp image

Device raphael (k20 pro)

image used twrp-3.5.2_9-0-raphael.img

comand used python3 -m twrpdtgen -v --output OUTPUT -k twrp-3.5.2_9-0-raphael.img

output

nato66613@Compute:/datadrive/TWRP-device-tree-generator$ python3 -m twrpdtgen -v --output OUTPUT -k twrp-3.5.2_9-0-raphael.img
TWRP device tree generator
Version 1.3.1

[aik_manager.py:46 INFO] init: Cloning AIK...
[cmd.py:814 DEBUG] execute: Popen(['git', 'clone', '-v', 'https://github.com/SebaUbuntu/AIK-Linux-mirror', '/datadrive/TWRP-device-tree-generator/extract'], cwd=/datadrive/TWRP-device-tree-generator, universal_newlines=True, shell=None, istream=None)
[base.py:1048 DEBUG] _clone: Cmd(['git', 'clone', '-v', 'https://github.com/SebaUbuntu/AIK-Linux-mirror', '/datadrive/TWRP-device-tree-generator/extract'])'s unused stdout:
[device_tree.py:55 DEBUG] init: Getting device infos...
[device_tree.py:58 DEBUG] init: Using /datadrive/TWRP-device-tree-generator/extract/ramdisk/default.prop as build.prop
Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/datadrive/TWRP-device-tree-generator/twrpdtgen/main.py", line 52, in
dt = DeviceTree(args.output, recovery_image=args.recovery_image,
File "/datadrive/TWRP-device-tree-generator/twrpdtgen/device_tree.py", line 60, in init
self.build_prop_reader = BuildPropReader(self.build_prop)
File "/datadrive/TWRP-device-tree-generator/twrpdtgen/info_extractors/buildprop.py", line 28, in init
self.codename = self.get_prop(DEVICE_CODENAME, "codename")
File "/datadrive/TWRP-device-tree-generator/twrpdtgen/info_extractors/buildprop.py", line 61, in get_prop
raise AssertionError(f"Device {error} could not be found in build.prop")
AssertionError: Device codename could not be found in build.prop

run error

python3 -m twrpdtgen -v
TWRP device tree generator
Version 1.3.1

usage: python3 -m twrpdtgen [-h] [-o OUTPUT] [-k] [--no-git] [--huawei]
[--recovery_kernel RECOVERY_KERNEL]
[--recovery_ramdisk RECOVERY_RAMDISK]
[--recovery_vendor RECOVERY_VENDOR] [-v]
[recovery_image]
python3 -m twrpdtgen: error: the following arguments are required: recovery_image

Crashes when cloning AIK

Latest version 1.2.3 crashes when cloning AIK

Version 1.2.3

[aik_manager.py:41 INFO] __init__: Cloning AIK...
[cmd.py:718 DEBUG] execute: Popen(['git', 'clone', '-v', 'https://github.com/SebaUbuntu/AIK-Linux-mirror', '/tmp/tmpdpjwdzer'], cwd=/home/alice/Desktop/Bramble, universal_newlines=True, shell=None, istream=None)
[base.py:972 DEBUG] _clone: Cmd(['git', 'clone', '-v', 'https://github.com/SebaUbuntu/AIK-Linux-mirror', '/tmp/tmpdpjwdzer'])'s unused stdout: 
Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/alice/.local/lib/python3.9/site-packages/twrpdtgen/__main__.py", line 28, in <module>
    dt = generate_device_tree(args.recovery_image, args.output, no_git=args.no_git, keep_aik=args.keep_aik)
  File "/home/alice/.local/lib/python3.9/site-packages/twrpdtgen/twrp_dt_gen.py", line 30, in generate_device_tree
    aik.extract(recovery_image)
  File "/home/alice/.local/lib/python3.9/site-packages/twrpdtgen/utils/aik_manager.py", line 64, in extract
    self.get_image_infos()
  File "/home/alice/.local/lib/python3.9/site-packages/twrpdtgen/utils/aik_manager.py", line 79, in get_image_infos
    self.base_address = self.read_recovery_file(self.get_extracted_info("base"))
  File "/home/alice/.local/lib/python3.9/site-packages/twrpdtgen/utils/aik_manager.py", line 108, in read_recovery_file
    return file.read_text().splitlines()[0]
  File "/usr/lib/python3.9/pathlib.py", line 1255, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib/python3.9/pathlib.py", line 1241, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/usr/lib/python3.9/pathlib.py", line 1109, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpdpjwdzer/split_img/recovery.img-base'

Creates a Problem while Allocating Path

When creating a device tree for me it created a path "tecno spark lite" while linux doesnt read path like this and the path is only read as tecno. Causing error during the build.

About repurchasing AIK on every run

Hello brother

As for the problem that AIK needs to be repurchased every time it runs, can we remove this problem? It takes a long time to generate the device tree every time. Can we change it to the first run, repurchase AIK, and no longer repurchase AIK after running

Successful build(s), TWRP not booting on device

Both Twrpdtgen and Omni ROM TWRP builds went fine. Tried loading boot.img via fastboot and also using Qualcomm emergency download system (EDL) to flash the image. In addition, I did an unrooted build from a completely stock boot.img, as well as a build using a Magisk patched boot.img that was rooted and tried those using fastboot and EDL as well. Note that this device has A/B slots. Any suggestions?
Thanks Sebastian for all of your hard work on this impressive project, as well as for your patience helping me with my earlier questions. Best regards.

Succesful Build, Bootloop, How do I debug?

Hi, thanks so much for this twrp config generator. Everything went pretty smooth for the most part in getting an image to build. I know this isn't the TWRP repo, but this is the only active place I can find about twrp building issues.

I have the image built and can succesfully flash it, but i just end up in a bootloop that eventually just boots to system after 2-3 reboot loops. Can you just point me to somewhere that I can try to debug this, somewhere with logs? I tried looking in /cache/recovery/ in a booted system but there is nothing new that gets created there.

If it helps, I am building for an Android 9 system. It is NOT A/B, just normal. It has a boot.img and a recovery.img, but the recovery.img is the one that holds the ramdisk. I am using twrp-device-tree-generator on the recovery.img and then building twrp using the "mka recoveryimg" command

clang++.real: error: unable to execute command: Segmentation fault (core dumped)

clang++.real: error: unable to execute command: Segmentation fault (core dumped)
clang++.real: error: clang frontend command failed due to signal (use -v to see invocation)
Android clang version 5.0.300080 (based on LLVM 5.0.300080)
Target: x86_64--linux-gnu
Thread model: posix
InstalledDir: prebuilts/clang/host/linux-x86/clang-4053586/bin
clang++.real: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang++.real: note: diagnostic msg:


PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++.real: note: diagnostic msg: /tmp/versioner-aaa46e.cpp
clang++.real: note: diagnostic msg: /tmp/versioner-aaa46e.sh
clang++.real: note: diagnostic msg:


[ 82% 9325/11354] //bionic/tools/versioner/src:versioner clang++ DeclarationDatabase.cpp [linux]
ninja: build stopped: subcommand failed.
13:32:13 ninja failed with: exit status 1

How do I solve?

failed to build some targets (15:13 (mm:ss))

Crashes after "Cloning AIK"

Steps:

divkix@Inspiron5459:~/TWRP_Device_Generator$ python3 -m twrpdtgen boot.img
TWRP device tree generator
Version 1.2.3

[INFO] Cloning AIK...
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/divkix/.local/lib/python3.8/site-packages/twrpdtgen/__main__.py", line 28, in <module>
    dt = generate_device_tree(args.recovery_image, args.output, no_git=args.no_git, keep_aik=args.keep_aik)
  File "/home/divkix/.local/lib/python3.8/site-packages/twrpdtgen/twrp_dt_gen.py", line 34, in generate_device_tree
    raise AssertionError("Couldn't find any build.prop")
AssertionError: Couldn't find any build.prop

I'm using Asus ROG Phone 2 boot.img for testing and this error is thrown, have also used ROG Phone 3 boot.img, still same result.

Samsung SM-T590 bricked, impossible to reach download mode

I have tried to compile OrangeFox recovery using device tree generated by this script, it went fine. I flashed it, the recovery isn't even loading, just flashes the screen once and goes black. Adb is not available, and it doesn't matter which key combination I press, it goes straight to recovery again and again.

Any ideas on how to fix this?

Here is the device tree I used: https://github.com/UDPSendToFailed/twrp_device_samsung_gta2xlwifi

Error when building TWRP for Motorola Foles

FAILED: ninja: '/home/user/Dev/twrp/out/target/product/foles/obj/STATIC_LIBRARIES/bootctrl.sm6150_intermediates/export_includes', needed by '/home/user/Dev/twrp/out/target/product/foles/obj/SHARED_LIBRARIES/[email protected]_intermediates/import_includes', missing and no known rule to make it
11:44:34 ninja failed with: exit status 1

Device Info:
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=16.1.0
TARGET_PRODUCT=omni_foles
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.9.1-arch1-1-x86_64-Arch-Linux
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/user/Dev/twrp/out
ROM_BUILDTYPE=HOMEMADE

BOARD_KERNEL_IMAGE_NAME is not set in BoardConfig.mk

[ 99% 396/397] finishing build rules ...
FAILED: 
vendor/omni/build/tasks/kernel.mk:94: error: BOARD_KERNEL_IMAGE_NAME not defined..
11:36:19 ckati failed with: exit status 1

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

The tree generator should probably set this value. I was able to get it to build by manually setting the value in BoardConfig.mk

Does it work on marvell?

Hey there, not really an issue but im asking if it supports marvell chips, the device is a samsung too btw

Not packing properly

I know it says Android 10 is beta.
I know recovery is not fully working on Android 10.

When I build twrp. The image is not packed correctly. I manually unpack it, add the correct flags and files to image, and it will boot.

Stock has both ::
recovery.img-dtb
recovery.img-recoverydtbo

Built recovery only has ::
recovery.img-recoverydtbo

There are some differences in recovery.img-dtboff and recovery.img-secondoff

Device == Blu g90 g0310ww

Device dump with recovery img

https://github.com/mrmazakblu/blu_g0310ww_dump

Device tree
https://github.com/mrmazakblu/Blu_G90_G0310WW-twrp

I think I'm making some noob mistake, maybe you can help

What's with "clang policy_define.c" ?

FAILED: /home/aqua/Twrp/out/soong/.intermediates/external/selinux/checkpolicy/checkpolicy/linux_x86_64/gen/lex/external/selinux/checkpolicy/policy_scan.c
prebuilts/misc/linux-x86/flex/flex-2.5.39 -o/home/aqua/Twrp/out/soong/.intermediates/external/selinux/checkpolicy/checkpolicy/linux_x86_64/gen/lex/external/selinux/checkpolicy/policy_scan.c external/selinux/checkpolicy/policy_scan.l
flex-2.5.39: loadlocale.c:130: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
Aborted (core dumped)
[ 20% 2326/11354] //external/selinux/checkpolicy:checkpolicy clang policy_define.c [linux]
ninja: build stopped: subcommand failed.
00:17:54 ninja failed with: exit status 1

failed to build some targets (05:31 (mm:ss))

I have been following the wiki step by step however nothing I do can get over this problem. Anyone know the solution?

AssertionError while using the script.

Trying this script to generate a dt for my device. But getting below error, and also Below is the link for my recovery..

raise AssertionError(f"Device {error} could not be found in build.prop")
AssertionError: Device arch could not be found in build.prop

RECOVERY

erro

Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 185, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.8/runpy.py", line 144, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/usr/lib/python3.8/runpy.py", line 111, in _get_module_details
import(pkg_name)
File "/home/zfz/TWRP-device-tree-generator/twrpdtgen/init.py", line 2, in
from jinja2 import Environment, FileSystemLoader
ModuleNotFoundError: No module named 'jinja2'

posixpath error

root@LAPTOP-9Q27PVAC:/home/steve/TWRP-device-tree-generator# python3 -m twrpdtgen /home/steve/TWRP/recovery.img
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.6/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/usr/lib/python3.6/runpy.py", line 109, in _get_module_details
import(pkg_name)
File "/home/steve/TWRP-device-tree-generator/twrpdtgen/init.py", line 10, in
jinja_env = Environment(loader=FileSystemLoader(current_path / 'templates'),
File "/usr/lib/python3/dist-packages/jinja2/loaders.py", line 163, in init
self.searchpath = list(searchpath)
TypeError: 'PosixPath' object is not iterable

AssertionError: Couldn't find any build.prop [oppo CPH909]

Device : Oppo A5s
Model : CPH1909

recovery : https://we.tl/t-FHw6tMc3G1


python3 -m twrpdtgen -o Oppo -v recovery.img
TWRP device tree generator
Version 1.3.1

[aik_manager.py:46 INFO] init: Cloning AIK...
[cmd.py:832 DEBUG] execute: Popen(['git', 'clone', '-v', 'https://github.com/SebaUbuntu/AIK-Linux-mirror', '/tmp/tmp9q3159yw'], cwd=/home/josh/Desktop/TWRP-device-tree-generator, universal_newlines=True, shell=None, istream=None)
[base.py:1085 DEBUG] _clone: Cmd(['git', 'clone', '-v', 'https://github.com/SebaUbuntu/AIK-Linux-mirror', '/tmp/tmp9q3159yw'])'s unused stdout:
[device_tree.py:55 DEBUG] init: Getting device infos...
Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/josh/Desktop/TWRP-device-tree-generator/twrpdtgen/main.py", line 52, in
dt = DeviceTree(args.output, recovery_image=args.recovery_image,
File "/home/josh/Desktop/TWRP-device-tree-generator/twrpdtgen/device_tree.py", line 57, in init
raise AssertionError("Couldn't find any build.prop")
AssertionError: Couldn't find any build.prop

FileNotFoundError: Specified file doesn't exist

osanosa@HOME-PC:~$ python3 -m twrpdtgen --no-git C:\recovery.img
TWRP device tree generator
Version 1.3.0

Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/osanosa/.local/lib/python3.8/site-packages/twrpdtgen/main.py", line 52, in
dt = DeviceTree(args.output, recovery_image=args.recovery_image,
File "/home/osanosa/.local/lib/python3.8/site-packages/twrpdtgen/device_tree.py", line 44, in init
raise FileNotFoundError("Specified file doesn't exist")
FileNotFoundError: Specified file doesn't exist

dtbo image check use wrong filename

ninja: error

When I build boot.img (Payton uses boot instead of recovery) with my tree made with TWRP-device-tree-generator (https://github.com/blap/twrp_device_motorola_payton):

make clean
source build/envsetup.sh
export ALLOW_MISSING_DEPENDENCIES=true 
export LC_ALL=C
lunch omni_payton-eng 
mka adbd recoveryimage

I got this error:

[ 99% 689/690] glob vendor/omni/overlay/common/**/*
ninja: error: '/home/bruno/twrp/out/target/product/payton/obj/STATIC_LIBRARIES/bootctrl.default_intermediates/export_includes', needed by '/home/bruno/twrp/out/target/product/payton/obj/EXECUTABLES/update_engine_sideload_intermediates/import_includes', missing and no known rule to make it
13:55:38 ninja failed with: exit status 1

But with "mka adbd bootimage" instead of "mka adbd recoveryimage" is sucessfull but boot.img is only 17.842.176 bytes. When I build with the original tree from TWRP (https://github.com/TeamWin/android_device_motorola_payton) instead of mine made with TWRP-device-tree-generator boot.img is 35.909.632 bytes and "mka adbd recoveryimage" builds ramdisk-recovery.cpio for twrp installer too (using https://gerrit.omnirom.org/#/c/android_build/+/33182/). Am I doing something wrong? It would be nice TWRP-device-tree-generator build twrp installer zip too.

Pip3 installs version 2.0.1

When I install with pip3, the help menu shows it's version 2.0.1 instead of 2.1.0.

TWRP device tree generator
Version 2.0.1

usage: python3 -m twrpdtgen [-h] [-o OUTPUT] [--git] [-d] image

positional arguments:
  image                 path to an image (recovery image or boot image if the
                        device is A/B)

optional arguments:
  -h, --help            show this help message and exit
  -o OUTPUT, --output OUTPUT
                        custom output folder
  --git                 create a git repo after the generation
  -d, --debug           enable debugging features

UPDATE:
Pls update the README to change install keywords:
pip3 install twrpdtgen to pip3 install twrpdtgen==<latest_release_version>

my device build.prop dont have ro.board.platform=

Hi, i tried use de script, but, Always i go to create device-tree i get one error that says "ro.board.platform", and i go check my build.prop, and he dont have | ro.board.platform

Some Samsung devices have this problem, i checked on two more devices on my house

my build.prop:https://drive.google.com/file/d/102zc-4v4N9EkZ7VpU2Lg85GfPuwU2TLs/view?usp=drivesdk

stock recovery:https://drive.google.com/file/d/105n506bNQVDVFAKoakC6Ao-2lLSMgQgV/view?usp=drivesdk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.