[GUIDE] How To Compile Kernel & DTBO For Redmi K20 - Redmi K20 / Xiaomi Mi 9T Guides, News, & Discussio

Introduction :
I'm not an expert in kernel development, but would like to share the steps that I followed to build my kernel. If any of other kernel developers out there would like to add on some tips or correct something, please do!
Pre-requisites :
Ubuntu or any other Linux based OS
Stable Internet Connection
Patience
Step 1 : Setup Build Environment
Open the terminal and enter the following :
Code:
sudo apt-get install git ccache automake flex lzop bison \
gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 \
g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev \
libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush \
schedtool dpkg-dev liblz4-tool make optipng maven libssl-dev \
pwgen libswitch-perl policycoreutils minicom libxml-sax-base-perl \
libxml-simple-perl bc libc6-dev-i386 lib32ncurses5-dev \
x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev xsltproc unzip
Step 2 : Download Required Files
Download device source :
Code:
git clone --depth=1 https://github.com/MiCode/Xiaomi_Kernel_OpenSource.git -b davinci-p-oss davinci-p-oss
Download a compatible GCC toolchain (Using AOSP's GCC for this guide) :
Code:
cd davinci-p-oss
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9 toolchain
Download a compatible CLANG toolchain (Using AOSP's CLANG for this guide) : Download
Move the downloaded file in the davinci-p-oss folder manually and then extract using the following command :
Code:
tar vxzf linux-x86-android-9.0.0_r48-clang-4691093.tar.gz
Download the device-tree-compiler attached below and place it in /usr/bin
Step 3 : Make device specific changes
Make these changes in the /kernel/module.c file.
If you are not familiar with github, you can check out many github guides available on XDA, for now you can just download the module.c file attached to this thread and replace the one in /kernel folder with the downloaded one!
Now, browse back to davinci-p-oss directory, and open the davinci_user_defconfig located in \arch\arm64\configs
Add the following lines :
Code:
CONFIG_BUILD_ARM64_DT_OVERLAY=y
CONFIG_MODULE_FORCE_LOAD=y
WIFI & Audio won't work if you don't make these changes, apparently Xiaomi decided to skip wlan & audio drivers in pie sources.
Step 4 : Building The Kernel
Code:
cd davinci-p-oss
rm -rf out
mkdir out
export ARCH=arm64
export SUBARCH=arm64
export DTC_EXT=dtc
make O=out ARCH=arm64 davinci_user_defconfig
PATH="${PWD}/bin:${PWD}/toolchain/bin:${PATH}" \
make -j$(nproc --all) O=out \
ARCH=arm64 \
CC=clang \
CLANG_TRIPLE=aarch64-linux-gnu- \
CROSS_COMPILE=aarch64-linux-android- | tee kernel.log
Step 5 : How To Get Help If You Encounter Errors
A kernel.log file will be generated in davinci-p-oss folder, find the line which says error.
If you can't figure out the solution, attach the kernel.log in your reply to this thread.
Step 6 : Booting The Kernel
Once you're done with Step 4, browse to /out/arch/arm64/boot & you'll find the Image.gz-dtb file (compiled zImage)
Download the anykernel template for davinci from attachments and add your Image.gz-dtb file to the archive.
Boot in TWRP, backup your stock kernel & flash the anykernel zip.
References :
Information on compiling Android kernels with Clang by nathanchance
How to compile kernel standalone by Xiaomi
Kernel Builder Virtual Machine & device specific changes by mslezak
AnyKernel3 Template by osm0sis
Wahoo Kernel Tools by frap129
Regards,
acervenky

Using QCom Clang To Compile Kernel [Xiaomi's Guide]
Step 1 : Setup Build Environment
Open the terminal and enter the following :
Code:
sudo apt-get install git ccache automake flex lzop bison \
gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 \
g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev \
libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush \
schedtool dpkg-dev liblz4-tool make optipng maven libssl-dev \
pwgen libswitch-perl policycoreutils minicom libxml-sax-base-perl \
libxml-simple-perl bc libc6-dev-i386 lib32ncurses5-dev \
x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev xsltproc unzip
Step 2 : Download Required Files
Download device source :
Code:
git clone --depth=1 https://github.com/MiCode/Xiaomi_Kernel_OpenSource.git -b davinci-p-oss davinci-p-oss
Download a compatible GCC toolchain (Using AOSP's GCC for this guide) :
Code:
cd davinci-p-oss
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9 toolchain
Download the Qcom CLANG : Download
Move the downloaded file in the davinci-p-oss folder manually and then extract using the following command :
Code:
tar vxzf snapdragon-llvm-compiler-android-linux64-609.tar.gz
Download the device-tree-compiler attached below and place it in /usr/bin
Step 3 : Make device specific changes
Make these changes in the /kernel/module.c file.
If you are not familiar with github, you can check out many github guides available on XDA, for now you can just download the module.c file attached to this thread and replace the one in /kernel folder with the downloaded one!
Now, browse back to davinci-p-oss directory, and open the davinci_user_defconfig located in \arch\arm64\configs
Add the following lines :
Code:
CONFIG_BUILD_ARM64_DT_OVERLAY=y
CONFIG_MODULE_FORCE_LOAD=y
WIFI & Audio won't work if you don't make these changes, apparently Xiaomi decided to skip wlan & audio drivers in pie sources.
Step 4 : Building The Kernel
Code:
cd davinci-p-oss
rm -rf out
mkdir out
export ARCH=arm64
export SUBARCH=arm64
export DTC_EXT=dtc
export CROSS_COMPILE=${PWD}/toolchain/bin/aarch64-linux-android-
make O=out REAL_CC=${PWD}/toolchains/llvm-Snapdragon_LLVM_for_Android_6.0/prebuilt/linux-x86_64/bin/clang CLANG_TRIPLE=aarch64-linux-gnu- davinci_user_defconfig
make -j$(nproc) O=out REAL_CC=${PWD}/toolchains/llvm-Snapdragon_LLVM_for_Android_6.0/prebuilt/linux-x86_64/bin/clang CLANG_TRIPLE=aarch64-linux-gnu- 2>&1 | tee kernel.log
Step 5 : How To Get Help If You Encounter Errors
A kernel.log file will be generated in davinci-p-oss folder, find the line which says error.
If you can't figure out the solution, attach the kernel.log in your reply to this thread.
Step 6 : Booting The Kernel
Once you're done with Step 4, browse to /out/arch/arm64/boot & you'll find the Image.gz-dtb file (compiled zImage)
Download the anykernel template for davinci from attachments and add your Image.gz-dtb file to the archive.
Boot in TWRP, backup your stock kernel & flash the anykernel zip.
This method is mentioned in Xiaomi's Wiki, you can choose any according to your preference!
Regards,
acervenky

How To Compile Custom DTBO
DTBO files have been used on our device primarily to change the refresh rates.
Pre-requisites :
Compiled kernel without any errors
Step 1 : Download Required Files
Download libufdt utils from this link.
Open the terminal in the downloaded file's location.
Code:
tar vxzf libufdt-master-utils.tar.gz
Step 2 : Compile dtbo.img
Code:
cd /libufdt-master-utils/src
python mkdtboimg.py create /home/user/davinci-p-oss/out/arch/arm64/boot/dtbo.img /home/user/davinci-p-oss/out/arch/arm64/boot/dts/qcom/*.dtbo
Step 3 : Flash The Compiled dtbo.img
The compiled dtbo.img file will be located in /davinci-p-oss/out/arch/arm64/boot/ (same output folder of zImage)
Backup your stock dtbo.img and flash the newly compiled dtbo.img
References :
Kernel Builder by mslezak
Regards,
acervenky

reserved3

Nice guide @acervenky
Thank you very much
----------------------------------------------
EDIT: compiled without errors

oddly enough I am not able to compile their kernel using this methodology. I believe it is something to do with Clang.
I can, however, compile the elementalX kernel for the Essential PH1, using both google's and uber's toolchains
https://gitlab.com/westernmass-hosting/android/elemental-x/compiler
I am going to see if I can replicate being able to compile for Mi9 using the same methology

I successfully compiled the kernel and dtbo using the Ubuntu VM linked in OP, but the dtbo.img is only 3MB.
When I dumped my Mi 9T's dtbo it's 32MB. Is this normal?
I compared the output from
Code:
mkdtboimg.py dump
and it seems that dt_entry_count is 24 in the compiled dtbo compared to 28 in my dumped dtbo.
I'm running the global V10.3.11.0 MIUI ROM.
Any ideas?

BLUuuE83 said:
I successfully compiled the kernel and dtbo using the Ubuntu VM linked in OP, but the dtbo.img is only 3MB.
When I dumped my Mi 9T's dtbo it's 32MB. Is this normal?
I compared the output from
Code:
mkdtboimg.py dump
and it seems that dt_entry_count is 24 in the compiled dtbo compared to 28 in my dumped dtbo.
I'm running the global V10.3.11.0 MIUI ROM.
Any ideas?
Click to expand...
Click to collapse
Yes it is normal.
Regards,
acervenky

Hi! Can you please tell me where do i find the files for GPU and CPU frequencies? Thanks!

acervenky said:
Yes it is normal.
Regards,
acervenky
Click to expand...
Click to collapse
Just another question if you don't mind.
What happens if I set too low display timings? I know with a computer monitor it'll just black screen but Windows will reset to defaults after 15 seconds if you don't do anything.
Will I just get a black screen meaning I brick my phone?

draand28 said:
Hi! Can you please tell me where do i find the files for GPU and CPU frequencies? Thanks!
Click to expand...
Click to collapse
You can't change the CPU frequencies, however to edit GPU frequencies you can edit these files:
Code:
arch/arm64/boot/dts/qcom/sm8150-gpu-v2.dtsi
arch/arm64/boot/dts/qcom/sm8150-v2.dtsi
BLUuuE83 said:
Just another question if you don't mind.
What happens if I set too low display timings? I know with a computer monitor it'll just black screen but Windows will reset to defaults after 15 seconds if you don't do anything.
Will I just get a black screen meaning I brick my phone?
Click to expand...
Click to collapse
If you set the timings too low/high they'll reset to the default values.
Regards,
acervenky

Hi! Thanks for answering. I have edited those frequencies but nothing changed on the phone. Still 585mhz maximum on gpu, even though I have tried different modifications (700,800,825). Even tried to add new steps above the original ones. I got the refresh rate mod working though. Also, if you can tell me the location of thermal configuration, that would be great. I have found a sm8150-thermal.dtsi file but can't figure out the actual temperatures, there are just some too low to be correct numbers.
I'll leave you with the modifications that I've made to the gpu and gpu-v2 files.
Code:
/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
&soc {
pil_gpu: qcom,kgsl-hyp {
compatible = "qcom,pil-tz-generic";
qcom,pas-id = <13>;
qcom,firmware-name = "a640_zap";
};
msm_bus: qcom,kgsl-busmon{
label = "kgsl-busmon";
compatible = "qcom,kgsl-busmon";
};
gpubw: qcom,gpubw {
compatible = "qcom,devbw";
governor = "bw_vbif";
qcom,src-dst-ports = <26 512>;
operating-points-v2 = <&suspendable_ddr_bw_opp_table>;
};
gpu_opp_table: gpu-opp-table {
compatible = "operating-points-v2";
opp-825000000 {
opp-hz = /bits/ 64 <825000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_TURBO_L1>;
};
opp-735000000 {
opp-hz = /bits/ 64 <735000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_TURBO_L1>;
};
opp-675000000 {
opp-hz = /bits/ 64 <675000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_NOM_L1>;
};
opp-553850000 {
opp-hz = /bits/ 64 <553850000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_NOM>;
};
opp-486460000 {
opp-hz = /bits/ 64 <486460000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_SVS_L2>;
};
opp-379650000 {
opp-hz = /bits/ 64 <379650000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_SVS_L1>;
};
opp-309110000 {
opp-hz = /bits/ 64 <309110000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_SVS>;
};
opp-215000000 {
opp-hz = /bits/ 64 <215000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_LOW_SVS>;
};
opp-96000000 {
opp-hz = /bits/ 64 <96000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_MIN_SVS>;
};
};
msm_gpu: qcom,[email protected] {
label = "kgsl-3d0";
compatible = "qcom,kgsl-3d0", "qcom,kgsl-3d";
status = "ok";
reg = <0x2c00000 0x40000>, <0x2c61000 0x800>,
<0x6900000 0x44000>, <0x780000 0x6fff>;
reg-names = "kgsl_3d0_reg_memory", "cx_dbgc",
"qdss_gfx", "qfprom_memory";
interrupts = <0 300 0>;
interrupt-names = "kgsl_3d0_irq";
qcom,id = <0>;
qcom,chipid = <0x06040000>;
qcom,initial-pwrlevel = <5>;
qcom,gpu-quirk-secvid-set-once;
qcom,gpu-quirk-cx-gdsc;
qcom,idle-timeout = <64>; //msecs
qcom,no-nap;
qcom,highest-bank-bit = <15>;
qcom,min-access-length = <32>;
qcom,ubwc-mode = <3>;
qcom,snapshot-size = <0x200000>; //bytes
qcom,gpu-qdss-stm = <0x161c0000 0x40000>; // base addr, size
qcom,tsens-name = "tsens_tz_sensor12";
#cooling-cells = <2>;
tzone-names = "gpuss-0-usr", "gpuss-1-usr";
qcom,pm-qos-active-latency = <1000>;
qcom,l2pc-cpu-mask-latency = <1000>;
qcom,pm-qos-wakeup-latency = <100>;
clocks = <&clock_gpucc GPU_CC_CXO_CLK>,
<&clock_gcc GCC_DDRSS_GPU_AXI_CLK>,
<&clock_gcc GCC_GPU_MEMNOC_GFX_CLK>,
<&clock_gpucc GPU_CC_CX_GMU_CLK>,
<&clock_gpucc GPU_CC_AHB_CLK>,
<&clock_cpucc L3_GPU_VOTE_CLK>;
clock-names = "rbbmtimer_clk", "mem_clk",
"mem_iface_clk", "gmu_clk",
"gpu_cc_ahb", "l3_vote";
qcom,isense-clk-on-level = <1>;
/* Bus Scale Settings */
qcom,gpubw-dev = <&gpubw>;
qcom,bus-control;
qcom,msm-bus,name = "grp3d";
qcom,bus-width = <32>;
qcom,msm-bus,num-cases = <13>;
qcom,msm-bus,num-paths = <1>;
qcom,msm-bus,vectors-KBps =
<26 512 0 0>,
<26 512 0 400000>, // 1 bus=100
<26 512 0 600000>, // 2 bus=150
<26 512 0 800000>, // 3 bus=200
<26 512 0 1200000>, // 4 bus=300
<26 512 0 1648000>, // 5 bus=412
<26 512 0 2188000>, // 6 bus=547
<26 512 0 2724000>, // 7 bus=681
<26 512 0 3072000>, // 8 bus=768
<26 512 0 4068000>, // 9 bus=1017
<26 512 0 5184000>, // 10 bus=1296
<26 512 0 6220000>, // 11 bus=1555
<26 512 0 7216000>; // 12 bus=1804
/* GDSC regulator names */
regulator-names = "vddcx", "vdd";
/* GDSC oxili regulators */
vddcx-supply = <&gpu_cx_gdsc>;
vdd-supply = <&gpu_gx_gdsc>;
/* GPU OPP data */
operating-points-v2 = <&gpu_opp_table>;
/* GPU related llc slices */
cache-slice-names = "gpu", "gpuhtw";
cache-slices = <&llcc 12>, <&llcc 11>;
qcom,l3-pwrlevels {
#address-cells = <1>;
#size-cells = <0>;
compatible = "qcom,l3-pwrlevels";
qcom,[email protected] {
reg = <0>;
qcom,l3-freq = <0>;
};
qcom,l3-pwrl[email protected] {
reg = <1>;
qcom,l3-freq = <864000000>;
};
qcom,[email protected] {
reg = <2>;
qcom,l3-freq = <1344000000>;
};
};
/* GPU Mempools */
qcom,gpu-mempools {
#address-cells = <1>;
#size-cells = <0>;
compatible = "qcom,gpu-mempools";
/* 4K Page Pool configuration */
qcom,[email protected] {
reg = <0>;
qcom,mempool-page-size = <4096>;
qcom,mempool-reserved = <2048>;
qcom,mempool-allocate;
};
/* 8K Page Pool configuration */
qcom,[email protected] {
reg = <1>;
qcom,mempool-page-size = <8192>;
qcom,mempool-reserved = <1024>;
qcom,mempool-allocate;
};
/* 64K Page Pool configuration */
qcom,[email protected] {
reg = <2>;
qcom,mempool-page-size = <65536>;
qcom,mempool-reserved = <256>;
};
/* 1M Page Pool configuration */
qcom,[email protected] {
reg = <3>;
qcom,mempool-page-size = <1048576>;
qcom,mempool-reserved = <32>;
};
};
/* Power levels */
qcom,gpu-pwrlevels {
#address-cells = <1>;
#size-cells = <0>;
compatible = "qcom,gpu-pwrlevels";
qcom,[email protected] {
reg = <0>;
qcom,gpu-freq = <600000000>;
qcom,bus-freq = <12>;
qcom,bus-min = <10>;
qcom,bus-max = <12>;
};
qcom,[email protected] {
reg = <1>;
qcom,gpu-freq = <553850000>;
qcom,bus-freq = <10>;
qcom,bus-min = <9>;
qcom,bus-max = <11>;
};
qcom,[email protected] {
reg = <2>;
qcom,gpu-freq = <486460000>;
qcom,bus-freq = <9>;
qcom,bus-min = <8>;
qcom,bus-max = <10>;
};
qcom,[email protected] {
reg = <3>;
qcom,gpu-freq = <379650000>;
qcom,bus-freq = <8>;
qcom,bus-min = <7>;
qcom,bus-max = <9>;
};
qcom,[email protected] {
reg = <4>;
qcom,gpu-freq = <309110000>;
qcom,bus-freq = <5>;
qcom,bus-min = <5>;
qcom,bus-max = <7>;
};
qcom,[email protected] {
reg = <5>;
qcom,gpu-freq = <215000000>;
qcom,bus-freq = <4>;
qcom,bus-min = <3>;
qcom,bus-max = <5>;
};
qcom,[email protected] {
reg = <6>;
qcom,gpu-freq = <0>;
qcom,bus-freq = <0>;
qcom,bus-min = <0>;
qcom,bus-max = <0>;
};
};
};
kgsl_msm_iommu: qcom,[email protected] {
compatible = "qcom,kgsl-smmu-v2";
reg = <0x02CA0000 0x10000>;
/* CB5(ATOS) & CB5/6/7 are protected by HYP */
qcom,protect = <0xa0000 0xc000>;
clocks =<&clock_gcc GCC_GPU_CFG_AHB_CLK>,
<&clock_gcc GCC_DDRSS_GPU_AXI_CLK>,
<&clock_gcc GCC_GPU_MEMNOC_GFX_CLK>;
clock-names = "iface_clk", "mem_clk", "mem_iface_clk";
qcom,secure_align_mask = <0xfff>;
qcom,retention;
qcom,hyp_secure_alloc;
gfx3d_user: gfx3d_user {
compatible = "qcom,smmu-kgsl-cb";
label = "gfx3d_user";
iommus = <&kgsl_smmu 0x0 0x401>;
qcom,gpu-offset = <0xa8000>;
};
gfx3d_secure: gfx3d_secure {
compatible = "qcom,smmu-kgsl-cb";
label = "gfx3d_secure";
iommus = <&kgsl_smmu 0x2 0x400>;
};
};
gmu: qcom,[email protected] {
label = "kgsl-gmu";
compatible = "qcom,gpu-gmu";
reg = <0x2c6a000 0x30000>,
<0xb280000 0x10000>,
<0xb480000 0x10000>;
reg-names = "kgsl_gmu_reg",
"kgsl_gmu_pdc_cfg",
"kgsl_gmu_pdc_seq";
interrupts = <0 304 0>, <0 305 0>;
interrupt-names = "kgsl_hfi_irq", "kgsl_gmu_irq";
qcom,msm-bus,name = "cnoc";
qcom,msm-bus,num-cases = <2>;
qcom,msm-bus,num-paths = <1>;
qcom,msm-bus,vectors-KBps =
<26 10036 0 0>, // CNOC off
<26 10036 0 100>; // CNOC on
regulator-names = "vddcx", "vdd";
vddcx-supply = <&gpu_cx_gdsc>;
vdd-supply = <&gpu_gx_gdsc>;
clocks = <&clock_gpucc GPU_CC_CX_GMU_CLK>,
<&clock_gpucc GPU_CC_CXO_CLK>,
<&clock_gcc GCC_DDRSS_GPU_AXI_CLK>,
<&clock_gcc GCC_GPU_MEMNOC_GFX_CLK>,
<&clock_gpucc GPU_CC_AHB_CLK>;
clock-names = "gmu_clk", "cxo_clk", "axi_clk",
"memnoc_clk", "gpu_cc_ahb";
/* AOP mailbox for sending ACD enable and disable messages */
mboxes = <&qmp_aop 0>;
mbox-names = "aop";
qcom,gmu-pwrlevels {
#address-cells = <1>;
#size-cells = <0>;
compatible = "qcom,gmu-pwrlevels";
/* GMU power levels must go from lowest to highest */
qcom,[email protected] {
reg = <0>;
qcom,gmu-freq = <0>;
};
qcom,[email protected] {
reg = <1>;
qcom,gmu-freq = <200000000>;
};
};
gmu_user: gmu_user {
compatible = "qcom,smmu-gmu-user-cb";
iommus = <&kgsl_smmu 0x4 0x400>;
};
gmu_kernel: gmu_kernel {
compatible = "qcom,smmu-gmu-kernel-cb";
iommus = <&kgsl_smmu 0x5 0x400>;
};
};
};
Code:
/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
&soc {
gpu_opp_table_v2: gpu_opp_table_v2 {
compatible = "operating-points-v2";
opp-825000000 {
opp-hz = /bits/ 64 <825000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_TURBO_L1>;
};
opp-735000000 {
opp-hz = /bits/ 64 <735000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_TURBO_L1>;
};
opp-675000000 {
opp-hz = /bits/ 64 <675000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_NOM_L1>;
};
opp-585000000 {
opp-hz = /bits/ 64 <585000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_NOM>;
};
opp-499200000 {
opp-hz = /bits/ 64 <499200000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_SVS_L2>;
};
opp-427000000 {
opp-hz = /bits/ 64 <427000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_SVS_L1>;
};
opp-345000000 {
opp-hz = /bits/ 64 <345000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_SVS>;
};
opp-257000000 {
opp-hz = /bits/ 64 <257000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_LOW_SVS>;
};
opp-96000000 {
opp-hz = /bits/ 64 <96000000>;
opp-microvolt = <RPMH_REGULATOR_LEVEL_MIN_SVS>;
};
};
};

acervenky said:
How To Compile Custom DTBO
DTBO files have been used on our device primarily to change the refresh rates.
Pre-requisites :
Compiled kernel without any errors
Step 1 : Download Required Files
Download libufdt utils from this link.
Open the terminal in the downloaded file's location.
Code:
tar vxzf libufdt-master-utils.tar.gz
Step 2 : Compile dtbo.img
Code:
cd /libufdt-master-utils/src
python mkdtboimg.py create /home/user/davinci-p-oss/out/arch/arm64/boot/dtbo.img /home/user/davinci-p-oss/out/arch/arm64/boot/dts/qcom/*.dtbo
Step 3 : Flash The Compiled dtbo.img
The compiled dtbo.img file will be located in /davinci-p-oss/out/arch/arm64/boot/ (same output folder of zImage)
Backup your stock dtbo.img and flash the newly compiled dtbo.img
References :
Kernel Builder by mslezak
Regards,
acervenky
Click to expand...
Click to collapse
What is the DTBO ? For what is it and why does it need changes ?

I followed instruction to build on Ubuntu 20.04 and got following console output
make[1]: Entering directory '/home/android/sources/k/davinci-p-oss/out'
../scripts/gcc-version.sh: line 32: printf: Is: invalid number
../scripts/gcc-version.sh: line 32: printf: your: invalid number
../scripts/gcc-version.sh: line 32: printf: PATH: invalid number
../scripts/gcc-version.sh: line 32: printf: set: invalid number
../scripts/gcc-version.sh: line 32: printf: correctly?: invalid number
../scripts/gcc-version.sh: line 32: printf: Is: invalid number
../scripts/gcc-version.sh: line 32: printf: your: invalid number
../scripts/gcc-version.sh: line 32: printf: PATH: invalid number
../scripts/gcc-version.sh: line 32: printf: set: invalid number
../scripts/gcc-version.sh: line 32: printf: correctly?: invalid number
/bin/sh: 1: [: 0000: unexpected operator
HOSTCC scripts/basic/fixdep
GEN ./Makefile
HOSTCC scripts/kconfig/conf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/zconf.lex.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
scripts/kconfig/conf --silentoldconfig Kconfig
***
*** Configuration file ".config" not found!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
make[4]: *** [../scripts/kconfig/Makefile:40: silentoldconfig] Error 1
make[3]: *** [../Makefile:529: silentoldconfig] Error 2
make[2]: Nothing to be done for '/home/android/sources/k/davinci-p-oss/out'.
kernel.log
make[1]: Entering directory '/home/android/sources/k/davinci-p-oss/out'
GEN ./Makefile
scripts/kconfig/conf --silentoldconfig Kconfig
make[1]: Nothing to be done for '/home/android/sources/k/davinci-p-oss/out'.
make[1]: Leaving directory '/home/android/sources/k/davinci-p-oss/out'
#### build completed successfully (21 seconds) ####
Any advice on how to fix it?
Best Regards,

I found issues. Compile successfully with default .bashrc and Ubuntu 18.04

VD171 said:
What is the DTBO ? For what is it and why does it need changes ?
Click to expand...
Click to collapse
DTB=Device Tree Blobs
From Oreo, device hardware blobs load outside of kernel.
When you turn on your device, these components load step by step:
1- first ramdisk. Say how OS may load. Set permission for each partition.
2- second kernel boot. Say any hardware how to communicate with operation system.
3- dtb/dtbo partition load. Help any hardware work property.
Without dtb, your boot.img not booted or boot on old dtbs.img on your phone. (If you lot of changes on your kernel codes, old blobs not enough for standard performance)
For more info see:
https://source.android.com/devices/architecture/dto/partitions

GenomeX said:
DTB=Device Tree Blobs
From Oreo, device hardware blobs load outside of kernel.
When you turn on your device, these components load step by step:
1- first ramdisk. Say how OS may load. Set permission for each partition.
2- second kernel boot. Say any hardware how to communicate with operation system.
3- dtb/dtbo partition load. Help any hardware work property.
Without dtb, your boot.img not booted or boot on old dtbs.img on your phone. (If you lot of changes on your kernel codes, old blobs not enough for standard performance)
For more info see:
https://source.android.com/devices/architecture/dto/partitions
Click to expand...
Click to collapse
With all the details it was very easy to understand what it is and how DTB/DTBO works.
Thank you very much for an amazing answer.

How to make dtbo.img to dts

acervenky said:
Introduction :
I'm not an expert in kernel development, but would like to share the steps that I followed to build my kernel. If any of other kernel developers out there would like to add on some tips or correct something, please do!
Pre-requisites :
Ubuntu or any other Linux based OS
Stable Internet Connection
Patience
Step 1 : Setup Build Environment
Open the terminal and enter the following :
Code:
sudo apt-get install git ccache automake flex lzop bison \
gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 \
g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev \
libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush \
schedtool dpkg-dev liblz4-tool make optipng maven libssl-dev \
pwgen libswitch-perl policycoreutils minicom libxml-sax-base-perl \
libxml-simple-perl bc libc6-dev-i386 lib32ncurses5-dev \
x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev xsltproc unzip
Step 2 : Download Required Files
Download device source :
Code:
git clone --depth=1 https://github.com/MiCode/Xiaomi_Kernel_OpenSource.git -b davinci-p-oss davinci-p-oss
Download a compatible GCC toolchain (Using AOSP's GCC for this guide) :
Code:
cd davinci-p-oss
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9 toolchain
Download a compatible CLANG toolchain (Using AOSP's CLANG for this guide) : Download
Move the downloaded file in the davinci-p-oss folder manually and then extract using the following command :
Code:
tar vxzf linux-x86-android-9.0.0_r48-clang-4691093.tar.gz
Download the device-tree-compiler attached below and place it in /usr/bin
Step 3 : Make device specific changes
Make these changes in the /kernel/module.c file.
If you are not familiar with github, you can check out many github guides available on XDA, for now you can just download the module.c file attached to this thread and replace the one in /kernel folder with the downloaded one!
Now, browse back to davinci-p-oss directory, and open the davinci_user_defconfig located in \arch\arm64\configs
Add the following lines :
Code:
CONFIG_BUILD_ARM64_DT_OVERLAY=y
CONFIG_MODULE_FORCE_LOAD=y
WIFI & Audio won't work if you don't make these changes, apparently Xiaomi decided to skip wlan & audio drivers in pie sources.
Step 4 : Building The Kernel
Code:
cd davinci-p-oss
rm -rf out
mkdir out
export ARCH=arm64
export SUBARCH=arm64
export DTC_EXT=dtc
make O=out ARCH=arm64 davinci_user_defconfig
PATH="${PWD}/bin:${PWD}/toolchain/bin:${PATH}" \
make -j$(nproc --all) O=out \
ARCH=arm64 \
CC=clang \
CLANG_TRIPLE=aarch64-linux-gnu- \
CROSS_COMPILE=aarch64-linux-android- | tee kernel.log
Step 5 : How To Get Help If You Encounter Errors
A kernel.log file will be generated in davinci-p-oss folder, find the line which says error.
If you can't figure out the solution, attach the kernel.log in your reply to this thread.
Step 6 : Booting The Kernel
Once you're done with Step 4, browse to /out/arch/arm64/boot & you'll find the Image.gz-dtb file (compiled zImage)
Download the anykernel template for davinci from attachments and add your Image.gz-dtb file to the archive.
Boot in TWRP, backup your stock kernel & flash the anykernel zip.
References :
Information on compiling Android kernels with Clang by nathanchance
How to compile kernel standalone by Xiaomi
Kernel Builder Virtual Machine & device specific changes by mslezak
AnyKernel3 Template by osm0sis
Wahoo Kernel Tools by frap129
Regards,
acervenky
Click to expand...
Click to collapse

Related

curl: (3) <url> malformed <<installing repo error>>

while trying to install repo and running cmd
$ curl http://android.git.kernel.org/repo >~/bin/repo
i get the following error.
Code:
import optparse
import os
import re
import readline
import subprocess
import sys
home_dot_repo = os.path.expanduser('~/.repoconfig')
gpg_dir = os.path.join(home_dot_repo, 'gnupg')
extra_args = []
init_optparse = optparse.OptionParser(usage="repo init -u url [options]")
# Logging
group = init_optparse.add_option_group('Logging options')
group.add_option('-q', '--quiet',
dest="quiet", action="store_true", default=False,
help="be quiet")
# Manifest
group = init_optparse.add_option_group('Manifest options')
group.add_option('-u', '--manifest-url',
dest='manifest_url',
help='manifest repository location', metavar='URL')
group.add_option('-o', '--origin',
dest='manifest_origin',
help="use REMOTE instead of 'origin' to track upstream",
metavar='REMOTE')
group.add_option('-b', '--manifest-branch',
dest='manifest_branch',
help='manifest branch or revision', metavar='REVISION')
group.add_option('-m', '--manifest-name',
dest='manifest_name',
help='initial manifest file (deprecated)',
metavar='NAME.xml')
group.add_option('--mirror',
dest='mirror', action='store_true',
help='mirror the forrest')
# Tool
group = init_optparse.add_option_group('repo Version options')
group.add_option('--repo-url',
dest='repo_url',
help='repo repository location', metavar='URL')
group.add_option('--repo-branch',
dest='repo_branch',
help='repo branch or revision', metavar='REVISION')
group.add_option('--no-repo-verify',
dest='no_repo_verify', action='store_true',
help='do not verify repo source code')
class CloneFailure(Exception):
"""Indicate the remote clone of repo itself failed.
"""
def _Init(args):
"""Installs repo by cloning it over the network.
"""
opt, args = init_optparse.parse_args(args)
if args or not opt.manifest_url:
init_optparse.print_usage()
sys.exit(1)
url = opt.repo_url
if not url:
url = REPO_URL
extra_args.append('--repo-url=%s' % url)
branch = opt.repo_branch
if not branch:
branch = REPO_REV
extra_args.append('--repo-branch=%s' % branch)
if branch.startswith('refs/heads/'):
branch = branch[len('refs/heads/'):]
if branch.startswith('refs/'):
print >>sys.stderr, "fatal: invalid branch name '%s'" % branch
raise CloneFailure()
if not os.path.isdir(repodir):
try:
os.mkdir(repodir)
except OSError, e:
print >>sys.stderr, \
'fatal: cannot make %s directory: %s' % (
repodir, e.strerror)
# Don't faise CloneFailure; that would delete the
# name. Instead exit immediately.
#
sys.exit(1)
_CheckGitVersion()
try:
if _NeedSetupGnuPG():
can_verify = _SetupGnuPG(opt.quiet)
else:
can_verify = True
if not opt.quiet:
print >>sys.stderr, 'Getting repo ...'
print >>sys.stderr, ' from %s' % url
dst = os.path.abspath(os.path.join(repodir, S_repo))
_Clone(url, dst, opt.quiet)
if can_verify and not opt.no_repo_verify:
rev = _Verify(dst, branch, opt.quiet)
else:
rev = 'refs/remotes/origin/%s^0' % branch
_Checkout(dst, branch, rev, opt.quiet)
except CloneFailure:
if opt.quiet:
print >>sys.stderr, \
'fatal: repo init failed; run without --quiet to see why'
raise
def _CheckGitVersion():
cmd = [GIT, '--version']
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
ver_str = proc.stdout.read().strip()
proc.stdout.close()
proc.wait()
if not ver_str.startswith('git version '):
print >>sys.stderr, 'error: "%s" unsupported' % ver_str
raise CloneFailure()
ver_str = ver_str[len('git version '):].strip()
ver_act = tuple(map(lambda x: int(x), ver_str.split('.')[0:3]))
if ver_act < MIN_GIT_VERSION:
need = '.'.join(map(lambda x: str(x), MIN_GIT_VERSION))
print >>sys.stderr, 'fatal: git %s or later required' % need
raise CloneFailure()
def _NeedSetupGnuPG():
if not os.path.isdir(home_dot_repo):
return True
kv = os.path.join(home_dot_repo, 'keyring-version')
if not os.path.exists(kv):
return True
kv = open(kv).read()
if not kv:
return True
kv = tuple(map(lambda x: int(x), kv.split('.')))
if kv < KEYRING_VERSION:
return True
return False
def _SetupGnuPG(quiet):
if not os.path.isdir(home_dot_repo):
try:
os.mkdir(home_dot_repo)
except OSError, e:
print >>sys.stderr, \
'fatal: cannot make %s directory: %s' % (
home_dot_repo, e.strerror)
sys.exit(1)
if not os.path.isdir(gpg_dir):
try:
os.mkdir(gpg_dir, 0700)
except OSError, e:
print >>sys.stderr, \
'fatal: cannot make %s directory: %s' % (
gpg_dir, e.strerror)
sys.exit(1)
env = dict(os.environ)
env['GNUPGHOME'] = gpg_dir
cmd = ['gpg', '--import']
try:
proc = subprocess.Popen(cmd,
env = env,
stdin = subprocess.PIPE)
except OSError, e:
if not quiet:
print >>sys.stderr, 'warning: gpg (GnuPG) is not available.'
print >>sys.stderr, 'warning: Installing it is strongly encouraged.'
print >>sys.stderr
return False
proc.stdin.write(MAINTAINER_KEYS)
proc.stdin.close()
if proc.wait() != 0:
print >>sys.stderr, 'fatal: registering repo maintainer keys failed'
sys.exit(1)
print
fd = open(os.path.join(home_dot_repo, 'keyring-version'), 'w')
fd.write('.'.join(map(lambda x: str(x), KEYRING_VERSION)) + '\n')
fd.close()
return True
def _SetConfig(local, name, value):
"""Set a git configuration option to the specified value.
"""
cmd = [GIT, 'config', name, value]
if subprocess.Popen(cmd, cwd = local).wait() != 0:
raise CloneFailure()
def _Fetch(local, quiet, *args):
cmd = [GIT, 'fetch']
if quiet:
cmd.append('--quiet')
err = subprocess.PIPE
else:
err = None
cmd.extend(args)
cmd.append('origin')
proc = subprocess.Popen(cmd, cwd = local, stderr = err)
if err:
proc.stderr.read()
proc.stderr.close()
if proc.wait() != 0:
raise CloneFailure()
def _Clone(url, local, quiet):
"""Clones a git repository to a new subdirectory of repodir
"""
try:
os.mkdir(local)
except OSError, e:
print >>sys.stderr, \
'fatal: cannot make %s directory: %s' \
% (local, e.strerror)
raise CloneFailure()
cmd = [GIT, 'init', '--quiet']
try:
proc = subprocess.Popen(cmd, cwd = local)
except OSError, e:
print >>sys.stderr
print >>sys.stderr, "fatal: '%s' is not available" % GIT
print >>sys.stderr, 'fatal: %s' % e
print >>sys.stderr
print >>sys.stderr, 'Please make sure %s is installed'\
' and in your path.' % GIT
raise CloneFailure()
if proc.wait() != 0:
print >>sys.stderr, 'fatal: could not create %s' % local
raise CloneFailure()
_SetConfig(local, 'remote.origin.url', url)
_SetConfig(local, 'remote.origin.fetch',
'+refs/heads/*:refs/remotes/origin/*')
_Fetch(local, quiet)
_Fetch(local, quiet, '--tags')
def _Verify(cwd, branch, quiet):
"""Verify the branch has been signed by a tag.
"""
cmd = [GIT, 'describe', 'origin/%s' % branch]
proc = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd = cwd)
cur = proc.stdout.read().strip()
proc.stdout.close()
proc.stderr.read()
proc.stderr.close()
if proc.wait() != 0 or not cur:
print >>sys.stderr
print >>sys.stderr,\
"fatal: branch '%s' has not been signed" \
% branch
raise CloneFailure()
m = re.compile(r'^(.*)-[0-9]{1,}-g[0-9a-f]{1,}$').match(cur)
if m:
cur = m.group(1)
if not quiet:
print >>sys.stderr
print >>sys.stderr, \
"info: Ignoring branch '%s'; using tagged release '%s'" \
% (branch, cur)
print >>sys.stderr
env = dict(os.environ)
env['GNUPGHOME'] = gpg_dir
cmd = [GIT, 'tag', '-v', cur]
proc = subprocess.Popen(cmd,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
cwd = cwd,
env = env)
out = proc.stdout.read()
proc.stdout.close()
err = proc.stderr.read()
proc.stderr.close()
if proc.wait() != 0:
print >>sys.stderr
print >>sys.stderr, out
print >>sys.stderr, err
print >>sys.stderr
raise CloneFailure()
return '%s^0' % cur
def _Checkout(cwd, branch, rev, quiet):
"""Checkout an upstream branch into the repository and track it.
"""
cmd = [GIT, 'update-ref', 'refs/heads/default', rev]
if subprocess.Popen(cmd, cwd = cwd).wait() != 0:
raise CloneFailure()
_SetConfig(cwd, 'branch.default.remote', 'origin')
_SetConfig(cwd, 'branch.default.merge', 'refs/heads/%s' % branch)
cmd = [GIT, 'symbolic-ref', 'HEAD', 'refs/heads/default']
if subprocess.Popen(cmd, cwd = cwd).wait() != 0:
raise CloneFailure()
cmd = [GIT, 'read-tree', '--reset', '-u']
if not quiet:
cmd.append('-v')
cmd.append('HEAD')
if subprocess.Popen(cmd, cwd = cwd).wait() != 0:
raise CloneFailure()
def _FindRepo():
"""Look for a repo installation, starting at the current directory.
"""
dir = os.getcwd()
repo = None
while dir != '/' and not repo:
repo = os.path.join(dir, repodir, REPO_MAIN)
if not os.path.isfile(repo):
repo = None
dir = os.path.dirname(dir)
return (repo, os.path.join(dir, repodir))
class _Options:
help = False
def _ParseArguments(args):
cmd = None
opt = _Options()
arg = []
for i in xrange(0, len(args)):
a = args[i]
if a == '-h' or a == '--help':
opt.help = True
elif not a.startswith('-'):
cmd = a
arg = args[i + 1:]
break
return cmd, opt, arg
def _Usage():
print >>sys.stderr,\
"""usage: repo COMMAND [ARGS]
repo is not yet installed. Use "repo init" to install it here.
The most commonly used repo commands are:
init Install repo in the current working directory
help Display detailed help on a command
For access to the full online help, install repo ("repo init").
"""
sys.exit(1)
def _Help(args):
if args:
if args[0] == 'init':
init_optparse.print_help()
else:
print >>sys.stderr,\
"error: '%s' is not a bootstrap command.\n"\
' For access to online help, install repo ("repo init").'\
% args[0]
else:
_Usage()
sys.exit(1)
def _NotInstalled():
print >>sys.stderr,\
'error: repo is not installed. Use "repo init" to install it here.'
sys.exit(1)
def _NoCommands(cmd):
print >>sys.stderr,\
"""error: command '%s' requires repo to be installed first.
Use "repo init" to install it here.""" % cmd
sys.exit(1)
def _RunSelf(wrapper_path):
my_dir = os.path.dirname(wrapper_path)
my_main = os.path.join(my_dir, 'main.py')
my_git = os.path.join(my_dir, '.git')
if os.path.isfile(my_main) and os.path.isdir(my_git):
for name in ['git_config.py',
'project.py',
'subcmds']:
if not os.path.exists(os.path.join(my_dir, name)):
return None, None
return my_main, my_git
return None, None
def _SetDefaultsTo(gitdir):
global REPO_URL
global REPO_REV
REPO_URL = gitdir
proc = subprocess.Popen([GIT,
'--git-dir=%s' % gitdir,
'symbolic-ref',
'HEAD'],
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
REPO_REV = proc.stdout.read().strip()
proc.stdout.close()
proc.stderr.read()
proc.stderr.close()
if proc.wait() != 0:
print >>sys.stderr, 'fatal: %s has no current branch' % gitdir
sys.exit(1)
def main(orig_args):
main, dir = _FindRepo()
cmd, opt, args = _ParseArguments(orig_args)
wrapper_path = os.path.abspath(__file__)
my_main, my_git = _RunSelf(wrapper_path)
if not main:
if opt.help:
_Usage()
if cmd == 'help':
_Help(args)
if not cmd:
_NotInstalled()
if cmd == 'init':
if my_git:
_SetDefaultsTo(my_git)
try:
_Init(args)
except CloneFailure:
for root, dirs, files in os.walk(repodir, topdown=False):
for name in files:
os.remove(os.path.join(root, name))
for name in dirs:
os.rmdir(os.path.join(root, name))
os.rmdir(repodir)
sys.exit(1)
main, dir = _FindRepo()
else:
_NoCommands(cmd)
if my_main:
main = my_main
ver_str = '.'.join(map(lambda x: str(x), VERSION))
me = [main,
'--repo-dir=%s' % dir,
'--wrapper-version=%s' % ver_str,
'--wrapper-path=%s' % wrapper_path,
'--']
me.extend(orig_args)
me.extend(extra_args)
try:
os.execv(main, me)
except OSError, e:
print >>sys.stderr, "fatal: unable to start %s" % main
print >>sys.stderr, "fatal: %s" % e
sys.exit(148)
if __name__ == '__main__':
main(sys.argv[1:])
curl: (3) <url> malformed
Thoughts?
nm, got it..... thanks for all the quick help.
/sarcasm
I have the same issue. Could you please tell me what you've done to get rid of this error?
Thanks,
I just went to the url, copied the text into gedit(as root) and saved as repo.

[REQ] to565 program

Can someone give me link for working to565 program which helps convert raw image files to rle ?
1. Need linux.
2. Script. Name Do.sh
Code:
#!/bin/sh
convert -depth 8 logo.png rgb:logo.raw
./to565 -rle < logo.raw > initlogo.rle
And source. Name to565.c
Code:
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#define to565(r,g,b) \
((((r) >> 3) << 11) | (((g) >> 2) << 5) | ((b) >> 3))
#define from565_r(x) ((((x) >> 11) & 0x1f) * 255 / 31)
#define from565_g(x) ((((x) >> 5) & 0x3f) * 255 / 63)
#define from565_b(x) (((x) & 0x1f) * 255 / 31)
void to_565_raw(void)
{
unsigned char in[3];
unsigned short out;
while(read(0, in, 3) == 3) {
out = to565(in[0],in[1],in[2]);
write(1, &out, 2);
}
return;
}
void to_565_raw_dither(int width)
{
unsigned char in[3];
unsigned short out;
int i = 0;
int e;
int* error = malloc((width+2) * 3 * sizeof(int));
int* next_error = malloc((width+2) * 3 * sizeof(int));
memset(error, 0, (width+2) * 3 * sizeof(int));
memset(next_error, 0, (width+2) * 3 * sizeof(int));
error += 3; // array goes from [-3..((width+1)*3+2)]
next_error += 3;
while(read(0, in, 3) == 3) {
int r = in[0] + error[i*3+0];
int rb = (r < 0) ? 0 : ((r > 255) ? 255 : r);
int g = in[1] + error[i*3+1];
int gb = (g < 0) ? 0 : ((g > 255) ? 255 : g);
int b = in[2] + error[i*3+2];
int bb = (b < 0) ? 0 : ((b > 255) ? 255 : b);
out = to565(rb, gb, bb);
write(1, &out, 2);
#define apply_error(ch) { \
next_error[(i-1)*3+ch] += e * 3 / 16; \
next_error[(i)*3+ch] += e * 5 / 16; \
next_error[(i+1)*3+ch] += e * 1 / 16; \
error[(i+1)*3+ch] += e - ((e*1/16) + (e*3/16) + (e*5/16)); \
}
e = r - from565_r(out);
apply_error(0);
e = g - from565_g(out);
apply_error(1);
e = b - from565_b(out);
apply_error(2);
#undef apply_error
++i;
if (i == width) {
// error <- next_error; next_error <- 0
int* temp = error; error = next_error; next_error = temp;
memset(next_error, 0, (width+1) * 3 * sizeof(int));
i = 0;
}
}
free(error-3);
free(next_error-3);
return;
}
void to_565_rle(void)
{
unsigned char in[3];
unsigned short last, color, count;
unsigned total = 0;
count = 0;
while(read(0, in, 3) == 3) {
color = to565(in[0],in[1],in[2]);
if (count) {
if ((color == last) && (count != 65535)) {
count++;
continue;
} else {
write(1, &count, 2);
write(1, &last, 2);
total += count;
}
}
last = color;
count = 1;
}
if (count) {
write(1, &count, 2);
write(1, &last, 2);
total += count;
}
fprintf(stderr,"%d pixels\n",total);
}
int main(int argc, char **argv)
{
if ((argc == 2) && (!strcmp(argv[1],"-rle"))) {
to_565_rle();
} else {
if (argc > 2 && (!strcmp(argv[1], "-w"))) {
to_565_raw_dither(atoi(argv[2]));
} else {
to_565_raw();
}
}
return 0;
}
Then build.
Code:
gcc -o to565 to565.c
Can you put the to565 program in $PATH?
Will the to565 program work if you put it in the $PATH?

[Q] Getting error unknown relocation : 27 for an Android kernel module after insmod

I've compiled a basic hello world Android kernel module
Code:
#include /* Needed by all modules */
#include /* Needed for KERN_INFO */
#include /* Needed for the macros */
static int hello3_data __initdata = 3;
static int __init hello_3_init(void)
{
printk(KERN_INFO "Hello, world %d\n", hello3_data);
return 0;
}
static void __exit hello_3_exit(void)
{
printk(KERN_INFO "Goodbye, world 3\n");
}
module_init(hello_3_init);
module_exit(hello_3_exit);
and written the following in the Makefile :
Code:
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 29
EXTRAVERSION =
obj-m += hello_3.o
KDIR=/home/aniket/beproject/htconev/android/goldfish
PWD := $(shell pwd)
all:
make -C $(KDIR) ARCH=arm CROSS_COMPILE=/home/aniket/beproject/android/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi- SUBDIRS=$(PWD) modules
clean:
make -C $(KDIR) ARCH=arm CROSS_COMPILE=/home/aniket/beproject/android/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi- SUBDIRS=$(PWD) clean
However after running make, pushing it to the Android device and running insmod it gives me an error :
insmod: init_module _.ko failed (Exec format error)
I got rid of that error using
Code:
make CFLAGS_MODULE=-fno-pic
on the kernel module
Now i can use insmod module.ko and module gets installed and is shown as live by running cat /proc/modules
However dmesg gives the output as :
hello_3: module license 'unspecified' taints kernel.
hello_3: unknown relocation: 27
hello_3: no version for "magic" found: kernel tainted.
Can anyone please tell me where I've gone wrong ?

[SOLVED] Help to root a Medion LifeTab X10302 (MD 60347)

Hi everyone,
Like the title said, I'm searching a way to root this tablet based on MediaTek.
Aida64 Information :
CPU : MT8783 (64 Bits ARMv8-A Cortex A53 octa-cores @ 1.3Ghz)
Platform : MT6753
Hardware : MT6735
Manufacturer : Lenovo
Brand : Medion
Display : Mali-T720 [email protected], 225 dpi
RAM : 2GB DDR3
ROM : 32GB MMC
After unlocking the bootloader :
I have tried some tools like iRoot, KingRoot, Kingo Root, Genius Root, and more that I can find with some search with google, but no one work.
I have tried to boot a TWRP/CWM Recovery image based on the same hardware or platform (fastboot boot myrecovery.img), the device reboot in normal mode, or I need to make these recovery for my hadware, but I think it need a rooted device...
I have tried to use MTK Droid Tools 2.5.3d, this software couldn't found the rom structure (this software doesn't found my IMEI too), and manualy with adb :
cat /proc/mtd
file is empty
cat /proc/emmc
file doesn't exist
cat /proc/partitions
Code:
major minor #blocks name
7 0 1254 loop0
254 0 975236 zram0
179 0 30535680 mmcblk0
179 1 3072 mmcblk0p1
179 2 5120 mmcblk0p2
179 3 10240 mmcblk0p3
179 4 10240 mmcblk0p4
179 5 512 mmcblk0p5
179 6 512 mmcblk0p6
179 7 16384 mmcblk0p7
179 8 16384 mmcblk0p8
179 9 8192 mmcblk0p9
179 10 10240 mmcblk0p10
179 11 512 mmcblk0p11
179 12 2048 mmcblk0p12
179 13 6144 mmcblk0p13
179 14 8192 mmcblk0p14
179 15 5120 mmcblk0p15
179 16 5120 mmcblk0p16
179 17 1024 mmcblk0p17
179 18 32768 mmcblk0p18
179 19 37888 mmcblk0p19
179 20 2621440 mmcblk0p20
179 21 409600 mmcblk0p21
179 22 27307520 mmcblk0p22
179 23 16384 mmcblk0p23
179 96 4096 mmcblk0rpmb
179 64 4096 mmcblk0boot1
179 32 4096 mmcblk0boot0
179 128 7565312 mmcblk1
179 129 7564288 mmcblk1p1
253 0 2600764 dm-0
253 1 27307520 dm-1
cat /etc/recovery.fstab
Code:
# mount point fstype device [device2]
/boot emmc boot
/cache ext4 /dev/block/mmcblk0p4
/data ext4 /dev/block/mmcblk0p5
/misc emmc misc
/recovery emmc recovery
/sdcard vfat /dev/block/mmcblk0p6
/system ext4 /dev/block/mmcblk0p3
ls -l /dev/block/platform/mtk-msdc.0/11230000.msdc0/by-name
Permission denied
After some search, it's possible that this device has the same hardware like the Lenovo Phab 2 Plus (correct me if i'm wrong).
If anyone has some idea to root this device, It's would be great ^^
Regards
PS : Sorry if my english is wrong
Would like to know too :good:
As do i.
Me too
Sent from my D6503 using Tapatalk
I have follow a lot of "how to", create a scatter file and try to read-back with SPFT from Windows 7, 10 and Ubuntu 16.04 LTS all I have is
=> BROM_ERROR S_DL_GET_DRAM_SETTING_FAIL (5054)
With Miracle Box v2.27A, it don't find the device....
I have trying to boot a custom recovery based on same hardware / cpu, the device reboot in normal mode ^^'
So, now, we have just to see with Medion, they can send the source-code and maybe stock-rom.
(I don't know why it's not available on their support website... :/ )
I've been in contact with [email protected] and they stated, that they only release a recovery kit (what we need for safely rooting the tablet) when they release an update for the tablet that gives users problems and they need to go back/recover the tablet themselves.
I think it would be helpful if people who would like to root their tablet contact Medion at [email protected] to let them see that there is a demand for those files. Hopefully they will release it then.
I got the same answer. After ota we will have recovery kit. But I am not sure we will have updates
Guys, can you see which app is using the battery? I only get the graph and battery usage data isn't available. I tried with hard reset and it didn't help
diyabolic said:
I got the same answer. After ota we will have recovery kit. But I am not sure we will have updates
Guys, can you see which app is using the battery? I only get the graph and battery usage data isn't available. I tried with hard reset and it didn't help
Click to expand...
Click to collapse
I didn't realise it before but I have the same bug. I also only have the graph.
Hey, maybe that's a reason for an OTA!
Sure it is I bought an app accubattery, at least I can see something
Sent from my D6503 using Tapatalk
Hey guys
I have found a way to root this device and worked for me, and work certainly for all other un-rooted device.
For some curious, I explain below what I have doing to dump recovery partition and boot.
For other, you can find the ZIP link at the end of this post.
With the DirtyCow exploit, it's very easy to dump our boot or recovery partition but need a little time without a custom recovery working...
In a first step, read this : h**ps://github.com/jcadduono/android_external_dirtycow#running
(a big thank's to jcadduono ! )
Ok, it's need an Android OS Environnement and it's not for our device, but it's not realy a problem.
A little modification to this file < recowvery-applypatch.c > to dump our recovery or boot partition, like this :
Code:
#include <unistd.h>
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <fcntl.h>
#include <sys/stat.h>
#define APP_NAME "recowvery"
#define HOST_NAME "applypatch"
#ifdef DEBUG
#include <android/log.h>
#define LOGV(...) { __android_log_print(ANDROID_LOG_INFO, APP_NAME, __VA_ARGS__); printf(__VA_ARGS__); printf("\n"); }
#define LOGE(...) { __android_log_print(ANDROID_LOG_ERROR, APP_NAME, __VA_ARGS__); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); }
#else
#define LOGV(...) { printf(__VA_ARGS__); printf("\n"); }
#define LOGE(...) { fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); }
#endif
#define SEP LOGV("------------")
#include "bootimg.h"
/* Time delay in microsecond for next loop (1000 = 1ms)
* 1ms is good for every PC
* (you can try less than 1ms to speed the process, but you can have an <unexpected EOF>)
*/
#define DELAY_T 1000
/* For Medion LifeTab X10302 (May work on same hardware MT6735/MT6753)
* You can define BLOCK_EMMC to other path if needed.
* Use < adb shell mount > for help.
*/
#define BLOCK_EMMC "/dev/block/platform/mtk-msdc.0/11230000.msdc0/by-name/boot"
//#define BLOCK_EMMC "/dev/block/platform/mtk-msdc.0/11230000.msdc0/by-name/recovery"
//#define BLOCK_EMMC "/dev/block/platform/any-folder-point-to-by-name-folder/by-name/boot"
void delay(long t)
{
long timens = t * 1000;
nanosleep((const struct timespec[]){{0, timens}}, NULL);
}
int main(int argc, char **argv)
{
int ret = 0;
int i = 0;
LOGV("Welcome to %s! (%s)", APP_NAME, HOST_NAME);
for (i = 30; i > 0; i--)
{
LOGV("The process start in %is", i);
sleep(1);
}
byte rb[32];
char *content = malloc(256);
FILE *filetest;
size_t nread;
filetest = fopen(BLOCK_EMMC, "r");
if (filetest) {
LOGV("*** DUMP START ***");
LOGV("* BLOCK_EMMC = %s", BLOCK_EMMC);
while ((nread = fread(rb, 1, sizeof rb, filetest)) > 0)
{
sprintf(content, "HEXDUMP = [");
for (i = 0; i < (int)nread; i++)
{
if (i == 0)
sprintf(content, "%s%.2x", content, rb[i]);
else
sprintf(content, "%s,%.2x", content, rb[i]);
}
sprintf(content, "%s];", content);
LOGV("%s", content);
/* sleep to prevent any unexpected EOF with with pipe stream
* ex : adb logcat | my-prg.exe
*/
delay(DELAY_T);
}
if (ferror(filetest)) {
ret = 1;
LOGE("*** DUMP ERROR ***");
LOGE("Error while reading the file...");
}
LOGV("*** DUMP END ***");
fclose(filetest);
}
else
{
LOGV("Can't read the file...");
ret = 1;
goto oops;
}
return 0;
oops:
LOGE("*** DUMP ERROR ***");
LOGE("Error %d: %s", ret, strerror(ret));
LOGE("Exiting...");
return ret;
}
(Edit : Added a delay in loop, there is some time an <unexpected EOF> during the process)
What it does ?
When launched by <recowvery-app_process>, it only open "/dev/block/platform/mtk-msdc.0/11230000.msdc0/by-name/boot" (in my exemple) in read-only and do like a HexDump, or something else.
It's human readable, and visible from Windows or any Linux distribution via the command adb logcat -s recowvery. But, we need something to do the revert :silly:
To solve this issue, I have made a to do this for me
C# code version : (not opti)
Code:
/*
* Created by SharpDevelop.
* User: vince
* Date: 16/01/2017
* Time: 17:34
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.IO;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Diagnostics;
namespace HexDumpReader
{
class Program
{
private static string workingDir = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + Path.DirectorySeparatorChar;
private static string outfile = null;
private static List<string> datalist = new List<string>();
public static int Main(string[] args)
{
int val = 0;
int ncrash = 0;
if (args.Length == 0 || Console.In.Peek() == -1)
{
DisplayUsage();
return 1;
}
try
{
// Shorter regex is possible, but I prefer like that.
// Used to start the process
Regex rs = new Regex("\\*\\*\\* DUMP START \\*\\*\\*");
// Used to match all data block, and populate < datalist >
Regex rl = new Regex("^\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}.\\d{3}\\s{1,2}\\d{3,5}\\s{1,2}\\d{3,5} I recowvery: HEXDUMP = \\[([^\\]].*)\\];$");
// Used to break the infinite loop and start parsing all data
Regex rf = new Regex("\\*\\*\\* DUMP END \\*\\*\\*");
// Used to intercept error from < recowvery-applypatch >
Regex re = new Regex("\\*\\*\\* DUMP ERROR \\*\\*\\*");
outfile = args[0];
bool start = false;
bool reboot = false;
/* If we want a reboot while finish */
if (args.Length > 1)
reboot = (args[1] == "-r");
while (true)
{
string line = Console.In.ReadLine();
/*
* If an unexpected EOF from recowvery-applypatch...
* We can't receive a null string, close fsout, set start to false and break the loop after 3 crashs.
*/
if (line == null)
{
Console.WriteLine("* < null > received !");
Console.WriteLine("Try again...");
break;
}
/*
* *** DUMP START ***
* set start = true, and init fsout FileStream
*/
if (rs.IsMatch(line))
start = true;
/*
* Add all matched group from HEXDUMP line to datalist.
* Note :
* It's possible to have matched line before intercept DUMP START,
* If we convert now, it's a good idea to have a broken output file.
* Important :
* Never try to parse all data on the fly, you can have a mysterious "unexpected EOF" error.
*/
if (start && rl.IsMatch(line))
{
datalist.Add(rl.Replace(line, "$1"));
Console.CursorLeft = 0;
Console.Write("Block read : " + datalist.Count);
}
/*
* Display the other lines (for debuging, logging...)
*/
else if (!rl.IsMatch(line) && (!rf.IsMatch(line) && !start) && line.Length > 1)
{
Console.WriteLine(line);
}
/*
* *** DUMP END ***
* Flush and close fsout, inform the user, and break the loop.
*/
if (start && rf.IsMatch(line))
break;
/*
* *** DUMP ERROR ***
* An error intercepted from ADB, close fsout, set start to false.
* < applypatch > will restart every 3 min.
* We break the loop after 3 errors.
*/
if (re.IsMatch(line))
{
Console.WriteLine("* Error received from ADB *");
start = false;
if (ncrash == 3)
{
Console.WriteLine("* Too many tries, please check your < recowvery-applypatch.c > and try again.");
break;
}
Console.WriteLine("* Be patient, recowvery-applypatch will restart in a few minutes.");
ncrash++;
}
}
Console.WriteLine();
Console.WriteLine("Parsing blocks...");
/* recowvery-applypatch read by block of 32 bytes.
* so, we can calculate the final size.
*/
double finalSize = 32 * datalist.Count;
/* used to display the new progression */
int lastprogress = 0;
FileStream fsout = File.OpenWrite(outfile);
fsout.SetLength(0);
foreach(string s in datalist)
{
string[] data = s.Split(',');
for (int c = 0; c < data.Length; c++)
{
try
{
byte[] b = StringToByteArrayFastest(data[c]);
fsout.Write(b, 0, b.Length);
/* Calculate progression */
int progress = (int)(((double)fsout.Position / finalSize) * 100);
/* Display the progression if needed */
if (progress != lastprogress)
{
Console.CursorLeft = 0;
Console.Write("Processing... " + progress + "% ");
lastprogress = progress;
}
}
catch(Exception ex)
{
Console.WriteLine();
Console.WriteLine("** Exception **");
Console.WriteLine(" - When convert : " + data[c]);
Console.WriteLine(" - Message : " + ex.Message);
Console.WriteLine(" - StackTrace : " + ex.StackTrace);
}
}
}
fsout.Flush();
fsout.Close();
Console.WriteLine();
Console.WriteLine("Finish !");
if (reboot)
rebootDevice();
else
Console.WriteLine("You can reboot your device.");
}
catch(Exception e)
{
Console.WriteLine("*** Exception ***");
Console.WriteLine(" - Message : " + e.Message);
Console.WriteLine(" - Source : " + e.Source);
Console.WriteLine(" - StackTrace : " + e.StackTrace);
val = e.HResult;
}
return val;
}
public static void DisplayUsage()
{
Console.WriteLine("Usage :");
Console.WriteLine(" adb logcat -s recowvery | " + System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".exe myImage-output.img [-r]");
Console.WriteLine();
Console.WriteLine(" -r : Reboot your device when finish.");
Console.WriteLine(" (Run \"adb reboot\" for you)");
}
public static void rebootDevice()
{
ProcessStartInfo psi;
Process p;
string strout = "";
string strerr = "";
psi = new ProcessStartInfo("adb.exe", "reboot");
psi.WorkingDirectory = workingDir;
psi.RedirectStandardError = true;
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
Console.WriteLine("Rebooting your device...");
p = new Process();
p.StartInfo = psi;
p.Start();
if (!p.StandardError.EndOfStream)
strerr = p.StandardError.ReadToEnd();
if (!p.StandardOutput.EndOfStream)
strout = p.StandardOutput.ReadToEnd();
if (strout.Length > 0)
Console.WriteLine(strout);
if (strerr.Length > 0)
{
Console.WriteLine(strerr);
}
p.WaitForExit();
}
public static byte[] StringToByteArrayFastest(string hex) {
if (hex.Length % 2 == 1)
throw new Exception("The binary key cannot have an odd number of digits");
byte[] arr = new byte[hex.Length >> 1];
for (int i = 0; i < hex.Length >> 1; ++i)
{
arr[i] = (byte)((GetHexVal(hex[i << 1]) << 4) + (GetHexVal(hex[(i << 1) + 1])));
}
return arr;
}
public static int GetHexVal(char hex) {
int val = (int)hex;
//For uppercase A-F letters:
//return val - (val < 58 ? 48 : 55);
//For lowercase a-f letters:
return val - (val < 58 ? 48 : 87);
//Or the two combined, but a bit slower:
//return val - (val < 58 ? 48 : (val < 97 ? 55 : 87));
}
}
}
To compile the C# code, you need :
An IDE like SharpDevelop, MonoDevelop, or VisualStudio
Create a <New Project> and select <Console Application>
copy the code below, and replace all to your main.cs or program.cs.
Run it
C++ code version : (Working good on Ubuntu 16.04, Windows too but not tested)
Code:
#include <iostream>
#include <regex>
#include <stdio.h>
typedef unsigned char byte;
using namespace std;
void DisplayUsage()
{
cout << string("Usage :") << endl;
cout << string(" adb logcat -s recowvery | ") << string("HexDumpReader") << string(".exe myImage-output.img [-r]") << endl;
cout << endl;
cout << string(" -r : Reboot your device when finish.") << endl;
cout << string(" (Run \"adb reboot\" for you)") << endl;
}
void split(const string &s, char delim, vector<string> &elems) {
stringstream ss;
ss.str(s);
string item;
while (getline(ss, item, delim)) {
elems.push_back(item);
}
}
vector<string> split(const string &s, char delim) {
vector<string> elems;
split(s, delim, elems);
return elems;
}
void string_to_bytearray(std::string str, unsigned char* &array, int& size)
{
int length = str.length();
// make sure the input string has an even digit numbers
if(length%2 == 1)
{
str = "0" + str;
length++;
}
// allocate memory for the output array
array = new unsigned char[length/2];
size = length/2;
std::stringstream sstr(str);
for(int i=0; i < size; i++)
{
char ch1, ch2;
sstr >> ch1 >> ch2;
int dig1, dig2;
if(isdigit(ch1)) dig1 = ch1 - '0';
else if(ch1>='A' && ch1<='F') dig1 = ch1 - 'A' + 10;
else if(ch1>='a' && ch1<='f') dig1 = ch1 - 'a' + 10;
if(isdigit(ch2)) dig2 = ch2 - '0';
else if(ch2>='A' && ch2<='F') dig2 = ch2 - 'A' + 10;
else if(ch2>='a' && ch2<='f') dig2 = ch2 - 'a' + 10;
array[i] = dig1*16 + dig2;
}
}
void rebootDevice()
{
system("adb reboot");
}
int main(int argc, char** argv)
{
/* Display help if no argument */
if (argc == 1)
{
DisplayUsage();
return 1;
}
cout << string("*** HexDumpReader ***") << endl;
int val = 0;
vector<string> datalist;
string outfile = string(argv[1]);
bool reboot = false;
int ncrash = 0;
/* Output image file */
cout << string("* Output file : ") << outfile << endl;
/* If we want a reboot while finish */
if (argc > 2)
{
reboot = (string(argv[2]) == "-r");
}
cout << string("* Reboot device : ") << reboot << endl;
try
{
// Shorter regex is possible, but I prefer like that.
// Used to start the process
regex rs("^.+I recowvery: (\\*\\*\\* DUMP START \\*\\*\\*)\\s+");
// Used to match all data block, and populate < datalist >
regex rl("^.+I recowvery: HEXDUMP = \\[([^\\]]+)\\];\\s+");
// Used to break the infinite loop and start parsing all data
regex rf("^.+I recowvery: (\\*\\*\\* DUMP END \\*\\*\\*)\\s+");
// Used to intercept error from < recowvery-applypatch >
regex re("^.+I recowvery: (\\*\\*\\* DUMP ERROR \\*\\*\\*)\\s+");
/* write or not to output file */
bool start = false;
FILE *fsout;
fsout = fopen(outfile.c_str(), "wb");
int nBlock = 0;
long currentSize = 0;
while (true)
{
string line;
getline(cin, line);
/*
* If an unexpected EOF from recowvery-applypatch or if no <pipe>...
* We can't receive a null string, so break the loop, close fsout, and exit the program.
*/
if (line.empty())
{
cout << string("* < null > received !") << endl;
cout << string("Try again...") << endl;
break;
}
/*
* *** DUMP START ***
* set start = true to write parsed data to fsout
*/
if (regex_match(line, rs))
{
start = true;
}
/*
* Parse all string received if match
* Note :
* It's possible to have matched string before intercept DUMP START,
* If we convert now, it's a good idea to have a broken output file.
*/
if (start && regex_match(line, rl))
{
string s = regex_replace(line, rl, "$1");
vector<string> data = split(s, ',');
for (int c = 0; c < (int)data.size(); c++)
{
try
{
byte *b = NULL;
int sb;
string_to_bytearray(data[c], b, sb);
fwrite(b, 1, sb, fsout);
}
catch (const std::exception &ex)
{
std::cout << std::endl;
std::cout << std::string("** Exception **") << std::endl;
std::cout << std::string(" - When convert : ") << data[c] << std::endl;
std::cout << std::string(" - Message : ") << ex.what() << std::endl;
}
}
nBlock++;
currentSize = nBlock * 32;
std::cout << "\r";
std::cout << std::string("Block read : ") << nBlock << string(" (Size : ") << currentSize << string(")");
}
/*
* Display the other lines (for debuging, logging...)
*/
else if (!regex_match(line, rl) && (!regex_match(line, rf) && !start) && line.length() > 1)
{
std::cout << line << std::endl;
}
/*
* *** DUMP END ***
* Flush and close fsout, inform the user, and break the loop.
*/
if (start && regex_match(line, rf))
{
break;
}
/*
* *** DUMP ERROR ***
* An error intercepted from ADB, close fsout, set start to false.
* < applypatch > will restart every 3 min.
* We break the loop after 3 errors.
*/
if (regex_match(line, re))
{
cout << std::string("* Error received from ADB *") << std::endl;
start = false;
if (ncrash == 3)
{
cout << std::string("* Too many tries, please check your < recowvery-applypatch.c > and try again.") << std::endl;
break;
}
cout << std::string("* Be patient, recowvery-applypatch will restart in a few minutes.") << std::endl;
ncrash++;
}
}
cout << endl;
fclose(fsout);
cout << std::endl;
cout << std::string("Finish !") << std::endl;
if (reboot)
{
rebootDevice();
}
else
{
std::cout << std::string("You can reboot your device.") << std::endl;
}
}
catch (const std::exception &e)
{
std::cout << std::string("*** Exception ***") << std::endl;
std::cout << std::string(" - Message : ") << e.what() << std::endl;
}
return val;
}
To build it, you need these CFLAGS : -m32 -std=C++11 -Wall (maybe -g for debug)
Ex :
g++ -Wall -fexceptions -g -Wall -std=c++11 -m32 -g -c main.cpp -o main.o
g++ -o HexDumpReader main.o -m32
Now, how It work ?
How can I dump my boot or recovery partition and make my own TWRP ? :crying:
It's like jcadduono explain here : h**ps://github.com/jcadduono/android_external_dirtycow
Follow only this steps :
Code:
adb push dirtycow /data/local/tmp
adb push recowvery-applypatch /data/local/tmp
adb push recowvery-app_process64 /data/local/tmp
adb push recowvery-run-as /data/local/tmp
adb shell
$ cd /data/local/tmp
$ chmod 0777 *
$ ./dirtycow /system/bin/applypatch recowvery-applypatch
"<wait for completion>"
$ ./dirtycow /system/bin/app_process64 recowvery-app_process64
"<wait for completion, your phone will look like it's crashing>"
$ exit
(It's change here =>)
adb logcat -s recowvery | HexDumpReader %USERPROFILE%\Documents\my-image-output.img -r
Wait a moment, you will see that it's finish, and you may see <my-image-output.img> in <%USERPROFILE%\Documents> folder.
You can try to extract your image from MKTool or any Kitchen tools, it's work, and finally make your TWRP, boot from it, backup your roms (if you have never doing this) and finally root your device.
I know that some of you can't do all these steps, or need simply the final image, you can download it from this url :
ZIP File : h**ps://goo.gl/IT7dpl (Contains original boot, recovery, TWRP & a readme)
(Bug found : battery stuck at 50%)
Thanks dude for your effort , you're the man ?
Is there a chance to fix the battery bug?
Sent from my D6503 using Tapatalk
diyabolic said:
Thanks dude for your effort , you're the man
Is there a chance to fix the battery bug?
Sent from my D6503 using Tapatalk
Click to expand...
Click to collapse
Hmmm... Without source code of this device, it's difficult to say if it's a TWRP issue or Kernel issue, or something else (It's possible that I miss something).
About the source code, a mail has been sent to Medion a days ago, but no answer...
In case if I've miss something, if someone can help, or give me a way to solve this ^^
Vince_02100 said:
Hmmm... Without source code of this device, it's difficult to say if it's a TWRP issue or Kernel issue, or something else (It's possible that I miss something).
About the source code, a mail has been sent to Medion a days ago, but no answer...
In case if I've miss something, if someone can help, or give me a way to solve this ^^
Click to expand...
Click to collapse
It's it charging till 50% or only indicating that is charged till 50 but actually is fully charged?
Sent from my D6503 using Tapatalk
It's only indicating at 50%. When you boot android, the real value about the battery is displayed
Ok. That's not a problem. Will root
Sent from my D6503 using Tapatalk
Working great!
For a permanent recovery I just renamed /system/recovery-from-boot.p
I try to root MD60348. I UNLOCK BOOTLOADER. Then stop. I cant do nothing. Device only back to factory setings...
kamilodiabolo said:
I try to root MD60348. I UNLOCK BOOTLOADER. Then stop. I cant do nothing. Device only back to factory setings...
Click to expand...
Click to collapse
Hi kamilodiabolo, after booting into TWRP you have to flash the UPDATE-SuperSU-v2.79.zip. After flashing the zip your tablet should boot without any problem. Without flashing the SuperSU update my tablet also stuck in bootloader.
Gadgetto said:
Hi kamilodiabolo, after booting into TWRP you have to flash the UPDATE-SuperSU-v2.79.zip. After flashing the zip your tablet should boot without any problem. Without flashing the SuperSU update my tablet also stuck in bootloader.
Click to expand...
Click to collapse
O know but i i dont know how to get my oryginal boot.img and stok recovery...
Adb pull
Guys, do you have problem with stuttering videos (yt, vimeo)? Before it was working perfectly, now every video stutters. I would rather not hard reset if I don't have to
Sent from my D6503 using Tapatalk

Problem about kernel compilation, "Warning (reg_format)"

Hi all. I'm trying to compile the kernel for my HTC 5G HUB, as a first step in transforming it into a great IoT device.
It has a Snapdragon 855 SOC and runs Android 9.0.
After more than a week of work, I tried out a mostly correct environment and solved most of problems by myself, but there are still some issues that are bothering me.
I'm not expecting anyone to helping me solve problems hand by hand, but just hoping someone experienced in similar devices(Pixel 4; Mi 9; OnePlus 7, etc...) will give me some clues. Thanks!
1. Device Tree Compiler Warning
At the beginning, I got lots of warnings about"Warning (reg_format)" in various of nodes. I managed to resolve these warnings by carefully adding `#address-cells` and `#size-cells` in their parent node. Except for the following two.
Code:
Warning (reg_format): "reg" property in /[email protected]/__overlay__/qcom,[email protected] has invalid length (4 bytes) (#address-cells == 2, #size-cells == 1)
Warning (reg_format): "reg" property in /[email protected]/__overlay__/qcom,[email protected] has invalid length (4 bytes) (#address-cells == 2, #size-cells == 1)
Take smb1390 for example, its content is shown as below:
Code:
#include <dt-bindings/interrupt-controller/irq.h>
smb1390: qcom,[email protected] {
compatible = "qcom,i2c-pmic";
reg = <0x10>;
#address-cells = <1>;
#size-cells = <0>;
interrupt-parent = <&spmi_bus>;
interrupts = <0x2 0xC5 0x0 IRQ_TYPE_LEVEL_LOW>;
interrupt_names = "smb1390";
interrupt-controller;
#interrupt-cells = <3>;
qcom,periph-map = <0x10>;
status = "disabled";
smb1390_revid: qcom,revid {
compatible = "qcom,qpnp-revid";
reg = <0x100>;
};
smb1390_charger: qcom,charge_pump {
compatible = "qcom,smb1390-charger";
qcom,pmic-revid = <&smb1390_revid>;
interrupt-parent = <&smb1390>;
status = "disabled";
qcom,core {
interrupts = <0x10 0x0 IRQ_TYPE_EDGE_BOTH>,
<0x10 0x1 IRQ_TYPE_EDGE_BOTH>,
<0x10 0x2 IRQ_TYPE_EDGE_BOTH>,
<0x10 0x3 IRQ_TYPE_EDGE_BOTH>,
<0x10 0x4 IRQ_TYPE_EDGE_BOTH>,
<0x10 0x5 IRQ_TYPE_EDGE_RISING>,
<0x10 0x6 IRQ_TYPE_EDGE_RISING>,
<0x10 0x7 IRQ_TYPE_EDGE_RISING>;
interrupt-names = "switcher-off-window",
"switcher-off-fault",
"tsd-fault",
"irev-fault",
"vph-ov-hard",
"vph-ov-soft",
"ilim",
"temp-alarm";
};
};
};
and it is included by sm8150-qrd.dtsi, sm8150-sdx50m-qrd.dtsi and sm8150-mtp.dtsi like this
Code:
&qupv3_se4_i2c {
#include "smb1390.dtsi"
#include "smb1355.dtsi"
};
Code:
&smb1390 {
pinctrl-names = "default";
pinctrl-0 = <&smb_stat_default>;
status = "ok";
};
&smb1390_charger {
io-channels = <&pm8150b_vadc ADC_AMUX_THM2>;
io-channel-names = "cp_die_temp";
status = "ok";
};
searching qupv3_se4_i2c I got this in sm8150-audio-rt5-xb.dtsi (RTX is the codename of HTC 5G HUB)
Code:
&soc{
/* TI config for spk chip */
[email protected] { /* qupv3_se4_i2c */
#address-cells = <1>;
#size-cells = <0>;
[email protected] {
...
};
};
};
I believe tas2557s is an unrelated device so I ignored the details of this.
So, where is the problem?
2. vmlinux warning at the end of compilation
Code:
WARNING: EXPORT symbol "gsi_write_channel_scratch" [vmlinux] version generation failed, symbol will not be versioned.
Fortunately, they were only warnings instead of errors. So I was still able to complete the entire compilation process.
If these problems are hard to fix easily, I'd like to know if I can safely ignore them.
My build environment:
Ubuntu 14.04 in docker
aarch64-linux-android-4.9
clang-4691093
DTC from AOSP 9.0.0. when I run "dtc -v", it told me "1.4.2"
You can get kernel source code from here

Categories

Resources