twrpdtgen / twrpdtgen Goto Github PK
View Code? Open in Web Editor NEWA Python library/script to automatically generate TWRP-compatible device tree from a boot/recovery image
A Python library/script to automatically generate TWRP-compatible device tree from a boot/recovery image
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
.
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?
uh, so a kinda weird and strange issue, the thing is i have installed twrpdtgen but when i execute twrpdtgen -h
it gives me the output -bash: twrpdtgen: command not found
Commands executed:
bruh-buildbot@bruh-buildbot:~/android$ pip3 install twrpdtgen Collecting twrpdtgen Downloading twrpdtgen-1.2.2-py3-none-any.whl (16 kB) Requirement already satisfied: GitPython<4.0.0,>=3.1.11 in /usr/local/lib/python3.8/dist-packages (from twrpdtgen) (3.1.12) Requirement already satisfied: Jinja2<3.0.0,>=2.11.2 in /usr/local/lib/python3.8/dist-packages (from twrpdtgen) (2.11.2) Requirement already satisfied: gitdb<5,>=4.0.1 in /usr/local/lib/python3.8/dist-packages (from GitPython<4.0.0,>=3.1.11->twrpdtgen) (4.0.5) Requirement already satisfied: MarkupSafe>=0.23 in /usr/lib/python3/dist-packages (from Jinja2<3.0.0,>=2.11.2->twrpdtgen) (1.1.0) Requirement already satisfied: smmap<4,>=3.0.1 in /usr/local/lib/python3.8/dist-packages (from gitdb<5,>=4.0.1->GitPython<4.0.0,>=3.1.11->twrpdtgen) (3.0.4) Installing collected packages: twrpdtgen Successfully installed twrpdtgen-1.2.2 bruh-buildbot@bruh-buildbot:~/android$ twrpdtgen -h -bash: twrpdtgen: command not found
Note
just to see if it was just a "fluke", i tried installing on my local pc (the above output was done on a gcp vm instance) and it was the same as above, output as follows:
bruh@bruh-ROG-Strix-b10esx:~$ twrpdtgen -h twrpdtgen: command not found
i have tried installing it with sudo pip install
and sudo pip3 install
yet it yields the same output
i do have cpio installed and configured.
any help would be appreciated!
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
hello, i have a build error
mkbootimg: error: unrecognized arguments: --dtb device/xiaomi/vayu/prebuilt/dtb.img
on tree https://github.com/kiam001/twrp_device_xiaomi_vayu
jenkins full log https://jenkins.home.kiam001.tk/job/recovery_vayu/3/console
i have a same type of recovery (redmi 9a) but device tree was generated successfully
but there is no system partition location device tree
Originally posted by @darkkingredian in #22 (comment)
log https://del.dog/eravifeste
recovery image https://drive.google.com/file/d/1p3FQ160e1INvgyNy-pyAg3uBi80hLQjP/view?usp=sharing
tree from tree generator https://drive.google.com/file/d/1ZzP3sRTQq1HU_HF66ZzR6QaN19imgrLC/view?usp=sharing
How to solve it?
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.
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
when I had builded Lenovo tb j706,show:Error: Recovery image doesn't exist.
Should recovery.img be unpacked? Or img format?
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
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
I have been following the wiki step by step however nothing I do can get over this problem. Anyone know the solution?
Не могу понять почему у меня такая ошибка?
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
Hey there, not really an issue but im asking if it supports marvell chips, the device is a samsung too btw
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
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
$ 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
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
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
[ 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
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
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
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
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.
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
This is the error when 'magic' file are windows encode but 'androidbootimg.magic' file are unix
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.
log: https://del.dog/phinginone
recovery image file: https://drive.google.com/file/d/1p3FQ160e1INvgyNy-pyAg3uBi80hLQjP/view?usp=sharing
I dumped recovery image from my phone with stock firmware.
I have right repo.
Why do I get this error?
Which ways exists to get a recovery image for a smartphone? This would be nice to know so I can generate a twrp build.
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
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
AssertionError: Device codename could not be found in build.prop
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
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`
I have succesfully generated a TWRP device tree, but I got a directory with some files. To flash TWRP i need a .img. What have I to do now to make it able for flashing?
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'
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.
See recovery.img-recovery_dtbo
instead of recovery.img-dtbo
in extract/split_img
, but seems python code checks xxx-dtbo
and unable to found dtbo
Seems AIK also expected -recovery_dtbo
in repackimg
https://github.com/SebaUbuntu/AIK-Linux-mirror/blob/master/repackimg.sh#L186-L189
https://github.com/SebaUbuntu/AIK-Windows-mirror/blob/master/repackimg.bat#L179-L181
https://github.com/SebaUbuntu/TWRP-device-tree-generator/blob/master/twrpdtgen/twrp_dt_gen.py#L83
https://github.com/SebaUbuntu/TWRP-device-tree-generator/blob/master/twrpdtgen/info_extractors/recovery_image.py#L26
In Termux I get No module named twrpdtgen.
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
[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'
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
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?
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
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
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'
I flashed the compiled twrp for my phone (SM-J337U) and it booted into a black screen.
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.
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.
Okay so I was looking to add this to a python script. However I wasn't able to add the library due to it not being found. Could someone help me?
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
Sorry, I have more errors with new .py tool.
when feeding an android 10 recovery.img i get an error "no expected binary found"
and when i tried a pie device recovery.img i got "SameFileError" error
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.