My Poco M3 compiled kernel won't boot - POCO M3 Questions & Answers

I'm trying to compile thus kernel https://github.com/MiCode/Xiaomi_Kernel_OpenSource/tree/lime-q-oss for my Poco M3
I did:
export ARCH=arm64 && export SUBARCH=arm64
export CROSS_COMPILE=/opt/aosp_prebuilts/aarch64-linux-android-4.9/bin/aarch64-linux-android-
export DTC_EXT="/opt/google_misc/misc/linux-x86/dtc/dtc"
make ARCH=arm64 CC=clang CLANG_TRIPLE=aarch64-linux-gnu- vendor/citrus-perf_defconfig
make ARCH=arm64 CC=clang CLANG_TRIPLE=aarch64-linux-gnu- EXTRA_CFLAGS="-I $PWD/techpack/display/pll/ -I $PWD/techpack/camera/drivers/cam_sensor_module/cam_cci/ -I $PWD/techpack/camera/drivers/cam_req_mgr -DSDCARDFS_VERSION= -I $PWD/" -j$(nproc --all) 2>&1 | tee kernel.log
and unpacked/repacked boot.img with
unpackbootimg -i boot.img -o boot_img_unpacked
mkbootimg --kernel "$SCRIPT_DIR/devices/$DEVICE/kernel/k/arch/arm64/boot/Image.gz" \
--ramdisk boot.img-ramdisk \
--dtb boot.img-dtb \
--cmdline "$(< boot.img-cmdline)" \
--base "$(< boot.img-base)" \
--kernel_offset "$(< boot.img-kernel_offset)" \
--ramdisk_offset "$(< boot.img-ramdisk_offset)" \
--tags_offset "$(< boot.img-tags_offset)" \
--dtb_offset "$(< boot.img-dtb_offset)" \
--os_version "$(< boot.img-os_version)" \
--os_patch_level "$(< boot.img-os_patch_level)" \
--pagesize "$(< boot.img-pagesize)" \
--header_version "$(< boot.img-header_version)" \
--hashtype "$(< boot.img-hashtype)" \
--board "$(< boot.img-board)" \
-o ../boot.img
but it won't boot. I get stuck on the Poco M3 screen. I tried unpacking/repacking the original boot.img with the original kernel just to see if I was repacking wrong but it worked, so my repack is working.
I think the issue might be with dtbo inside the kernel, because my compiled kernel has 28mb vs 32mb from the original one. It's worth noting that the original one is for Android 11 and the one I compiled is for Android 10 but I doubt this is the problem because both are 4.19.x and usually one kernel works over 2 Android versions.
I also tried adding CONFIG_BUILD_ARM64_DT_OVERLAY=y to
vendor/citrus-perf_defconfig but it also won't boot.

Related

Mkbootimg Repacking - Proper command?

I have unpacked some boot.img files and wanted to repack them after editing the ramdisk. Does anyone know the proper command to repack for the LG G2?
I am currently using:
./bins/mkbootimg --kernel $kernel --ramdisk $ramdisk \
--cmdline "console=ttyHSL0,115200,n8 androidboot.hardware=g2 user_debug=31 msm_rtb.filter=0x0 mdss_mdp.panel=1:dsi:0:qcom,mdss_dsi_g2_lgd_cmd" \
--base 0x00000000 --pagesize 2048 --tags-addr 0x4800000 --offset 0x5000000 \
--dt ./bins/dt_g2.img --output new_boot.img
(From a script I modified)
It builds the correct addresses but the phone goes into a bootloop. Before I got the addresses right, I got fastboot. If tried the above command (which I modified). I've also tried using the command the unpack tool said to use. In addition, if tried the command in the script used to build the bootimg when omnirom is compiling. I've tried varying combos.
Yes, I am using the custom mkbootimg. I fished it out of the kernel objects directory after a successful recovery compile.
Thanks!

[Tutorial]Kernel Post Compilation Guide; how to turn kernel into img

There are many great guides online on how to compile a kernel, but they often skimp on the last and most important part, how to get it into a working img. Therefore, without further ado, these are the steps
Prerequisites:
-Linux
-Good-ish command line experience
-Mkbootimg https://github.com/Team-DevElite/mkbootimg-python3
-you will need this https://forum.xda-developers.com/showthread.php?t=2073775
-Python 3
Step 1:
-Extract image kitchen
-Download a working kernel and extract boot image
-Place it into image kitchen's folder
-Type this into the terminal(of course, set permissions first)
Code:
./unpackimg.sh <boot image>
You will now get something similar to this.
Code:
BOARD_KERNEL_CMDLINE androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 [email protected] coherent_pool=2M enforcing=0
BOARD_KERNEL_BASE 80000000
BOARD_NAME
BOARD_PAGE_SIZE 4096
BOARD_HASH_TYPE sha1
BOARD_KERNEL_OFFSET 00008000
BOARD_RAMDISK_OFFSET 02200000
BOARD_SECOND_OFFSET 00f00000
BOARD_TAGS_OFFSET 02000000
SAVE THE OUTPUT INTO A TEXT FILE
Step 2: Getting the Ramdisk
-Go to the folder, split_img
-Copy ramdisk.cpio.gz into a conveinient folder
Step 3:
Now, get the values from Step 1
-Seperate them like this and get rid of whitespace between the \s
Code:
--ramdisk <ramdisk location> \
--cmdline "androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 [email protected] coherent_pool=2M enforcing=0" \
--base 0x80000000 \
--pagesize 4096 \
--ramdisk_offset 0x02200000 \
--tags_offset 0x02000000 \
Now Figure out the directory of your compiled kernel
64bit
Code:
arch/arm64/boot/
32bit
Code:
arch/arm/boot
Depending on your kernel, the kernel file will either be image-gz.dtb or zImage.
Either way its the same step.
Next, add this argument to the one we made above
Code:
--kernel <path to kernel output file>
Step 4 FINAL:
-Set the permissons for mkbootimg
-add this argument to the one above
Code:
--output boot.img
Now your arguments list should look something like this
Code:
--kernel <kernel file> \
--ramdisk <ramdisk file> \
--cmdline "androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 [email protected]
coherent_pool=2M enforcing=0" \
--base 0x80000000 \
--pagesize 4096 \
--ramdisk_offset 0x02200000 \
--tags_offset 0x02000000 \
--output boot.img \
-cd into the directory containing mkbootimg
-Now add ./mkbootimg to the front of it and execute!
-Check that it looks something like this
Code:
./mkbootimg \
--kernel <kernel file> \
--ramdisk <ramdisk file> \
--cmdline "androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 [email protected] coherent_pool=2M enforcing=0" \
--base 0x80000000 \
--pagesize 4096 \
--ramdisk_offset 0x02200000 \
--tags_offset 0x02000000 \
--output boot.img \
you should now see a boot.img generated
HIT Thanks if I helped
thanks to @osm0sis for his awesome tools!
Thanks for nice and easy guide
Manjot xda said:
There are many great guides online on how to compile a kernel, but they often skimp on the last and most
Thanks for nice and easy guide
Click to expand...
Click to collapse
Thank you, and please don't quote the op, please edit and shorten your post.
Regards
-LLJY
Sry mostly i use other forums there is no rule like don't quote whole op so ignore that post edited. Again nice tutorial
Missed the ramdisk flag while building the new image and my device failed to boot multiple times. Thanks for the detailed guide (pressed the button )!
Can you make a guide video ? And this can not work on Windows ?
shinigami_tsin said:
Can you make a guide video ? And this can not work on Windows ?
Click to expand...
Click to collapse
No to both
I know this is a rather old thread, but I just wanted to say thank you for this. I do a lot of modding and other tricks and hacks on Amazon Fire HD 10 (we were just recently able to unlock them) and it was nice to read a small and straight forward guide without anything being deleted or commented out. As such, I was able to use this method to make a fresh boot.img and it booted the very first time. It's an awesome feeling when that happens, given we often do more unintentional (or intentional) destruction to them.

Can't repack boot image

Hello,
I am trying to edit the boot.img (modified to not force encrypt the userdata) of my device.
I extracted the boot image with umkbootimage and then I extracted the initramfs with the following command:
Code:
gunzip -c ../initramfs.cpio.gz | cpio -i
Then i repacked the ramfs with the command (without changing nothing):
Code:
find . | cpio -o -H newc | gzip > ../new-ramdisk.cpio.gz
Finally, I repacked the boot image with mkbootimg and the following arguments:
Code:
mkbootimg --kernel zImage --ramdisk new-ramdisk.cpio.gz --base 0x0 --ramdisk_offset 0x002000000 --tags_offset 0x01e00000 --cmdline 'androidboot.hardware=angler androidboot.console=ttyHSL0 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 boot_cpus=0-3' --pagesize 4096 -o new_boot.img
The new boot image won't boot up. When I use the original initramfs to create the boot image, everything works great.
Another issue is that after the repacking the size of the initramfs changed.
Someone have any idea what should I do?
@batman1010 you need that

SM-T280 Need help tying to compile stock kernel

Hi,
I'm trying to compile the stock Samsung Kernel for my SM-T280 (Android 5.1.1) because I plan to make some modifications later on. The build currently just stops with no obvious error message I could debug from.
Code:
...
In file included from include/soc/sprd/sci_glb_regs.h:169:0,
from drivers/usb/gadget/dwc_otg/usb_hw.c:23:
include/soc/sprd/./chip_x30g/__regs_ap_apb.h:69:0: warning: "BIT_CKG_SOFT_RST" redefined [enabled by default]
#define BIT_CKG_SOFT_RST ( BIT(18) )
^
In file included from include/soc/sprd/sci_glb_regs.h:154:0,
from drivers/usb/gadget/dwc_otg/usb_hw.c:23:
include/soc/sprd/./chip_x30g/__regs_aon_apb_tshark3.h:153:0: note: this is the location of the previous definition
#define BIT_CKG_SOFT_RST ( BIT(22) )
^
LD drivers/usb/gadget/dwc_otg/dwc_otg.o
LD drivers/usb/gadget/dwc_otg/built-in.o
LD drivers/usb/gadget/built-in.o
LD drivers/usb/built-in.o
LD drivers/built-in.o
To make things easy to reproduce, I use Docker:
Code:
FROM ubuntu:18.04
RUN apt-get -y update \
&& apt-get -y install make gcc python wget abootimg unzip curl \
&& apt-get clean
# Go to https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8
# Click Branch "master"
# Download [tgz]
COPY arm-eabi-4.8-refs_heads_master.tar.gz /data/arm-eabi.tar.gz
# Go to http://opensource.samsung.com/
# Search "T280XXU0AQA4"
# Download "SM-T280_EUR_LL_Opensource.zip"
COPY SM-T280_EUR_LL_Opensource.zip /data/tools.zip
ENV PATH /usr/sbin:/usr/bin:/sbin:/bin:/data/arm-eabi/bin
ENV ARCH arm
ENV SUBARCH arm
ENV CROSS_COMPILE arm-eabi-
RUN mkdir /data/arm-eabi \
&& mkdir /data/src \
&& tar -xf /data/arm-eabi.tar.gz -C /data/arm-eabi/ \
&& unzip /data/tools.zip -d /data \
&& tar -xf /data/Kernel.tar.gz -C /data/src/ \
&& rm /data/tools.zip \
&& rm /data/arm-eabi.tar.gz \
&& rm /data/Kernel.tar.gz
WORKDIR /data/src
RUN make mrproper \
&& make gtexswifi-dt_defconfig \
&& make -j4 zImage
#RUN abootimg -u /data/boot.img -k /data/src/arch/arm/boot/zImage
The description Samsung provides to compile the kernel is pretty poor. I already tried different toolchains (tag "android-5.1.1_r38" instead of "master") and "ubuntu:16.04" as base image.
https://forum.xda-developers.com/ga...rnel-galaxy-tab-7-0-2016-lte-sm-t285-t3474967 states the Kernel source for SM-T285 provided by Samsung is actually broken... Maybe this one too? I have almost no experience in compiling anything on linux, so I'm stuck for now. (I tried the same with a stock Android Kernel for a Nexus 7 and it worked.)
Help would be appreciated
Okay... After hours of trying different software packages used in https://github.com/lineage-gtexslte/build_guide/blob/master/Dockerfile , I found that "bc" was missing. Now it compiles :victory:
Code:
FROM ubuntu:18.04
RUN apt-get -y update \
&& apt-get -y install make gcc python wget abootimg unzip curl [B][COLOR="DarkRed"]bc[/COLOR][/B] \
&& apt-get clean
# Go to https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8
# Click Tag "android-5.1.1_r38"
# Download [tgz]
COPY arm-eabi-4.8-26e93f6af47f7bd3a9beb5c102a5f45e19bfa38a.tar.gz /data/arm-eabi.tar.gz
# Go to http://opensource.samsung.com/
# Search "T280XXU0AQA4"
# Download "SM-T280_EUR_LL_Opensource.zip"
COPY SM-T280_EUR_LL_Opensource.zip /data/tools.zip
ENV PATH /usr/sbin:/usr/bin:/sbin:/bin:/data/arm-eabi/bin
ENV ARCH arm
ENV SUBARCH arm
ENV CROSS_COMPILE arm-eabi-
RUN mkdir /data/arm-eabi \
&& mkdir /data/src \
&& tar -xf /data/arm-eabi.tar.gz -C /data/arm-eabi/ \
&& unzip /data/tools.zip -d /data \
&& tar -xf /data/Kernel.tar.gz -C /data/src/ \
&& rm /data/tools.zip \
&& rm /data/arm-eabi.tar.gz \
&& rm /data/Kernel.tar.gz
WORKDIR /data/src
RUN make mrproper \
&& make gtexswifi-dt_defconfig \
&& make -j4 zImage
Edit: Just wanted to let you know that I now also generated a boot.img successfully and it actually booted my recompiled kernel.
To create a boot.img out of zImage I used https://github.com/chiefwigms/degas-mkbootimg/tree/galaxy_tab_a_smt285 and a original boot.img I created from my device using TWRP.
Code:
degas-unpackbootimg -i /data/boot.img -o /data/boot
degas-mkbootimg --kernel /data/src/arch/arm/boot/zImage --ramdisk /data/boot/boot.img-ramdisk.gz --cmdline "console=ttyS1,115200n8" --dt /data/boot/boot.img-dt --signature /data/boot/boot.img-signature -o /data/boot-mkbootimg.img
mkT280bootimg -i /data/boot-mkbootimg.img -o /data/boot-mkt280.img
The image created by degas-mkbootimg won't boot. Using mkT280bootimg OR https://github.com/osm0sis/dhtbsign on it will create an image that boots.
I've used TWRP again to flash the image.
hey bud sorry for bumping up the post...i have sm-t280 and im trying to install it as my car stereo. currently i have problems with otg host with charging at the same time. do you have any solution or advice?

How to repack boot.img

Hi.
I have successfully rooted SM-T725 device and installed twrp. After booting in twrp I get boot.img.
Code:
dd if=/dev/block/by-name/boot of=/data/media/0/Download/boot.img
I unpack boot.img with tool from github /osm0sis/pxa-mkbootimg.git with command
Code:
./pxa-unpackbootimg -i boot.img -o out
When I try to pack it again with command
Code:
./pxa-mkbootimg --kernel out/boot.img-zImage --dt out/boot.img-dt --base 0 --pagesize 4096 --board SRPRL03A001 --kernel_offset 0x00008000 --ramdisk_offset 0x02000000 --second_offset 0x00f00000 --tags_offset 0x00000001 --cmdline "console=null androidboot.hardware=qcom video=vfb:640x400,bpp=32,memsize=3072000 msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 service_locator.enable=1 swiotlb=1" --output boot-new.img
it makes file with different size then original boot.img
and after flashing to boot partition, the device boots in download mode with the following error:
"partition vbmeta
Reason vbmeta: Error verifying vbmeta image: O_O_INDIVLDVMT_EDRHS_IMTHSGAUEMSAC"
How can I fix this?
I solved it. I used wrong pxamkbootimg. You need to use mkbootimg, not pxamkbootimg.
I used all parameters that unpackbootimg shows when unpacking boot.img, so the correct command is
Code:
./mkbootimg --kernel out.boot/boot.img-zImage --ramdisk out.boot/boot.img-ramdisk.gz --output boot-new.img \
--board SRPRL03A001 --base 0 --pagesize 4096 --hash sha1 \
--os_version 9.0.0 --os_patch_level 2019-03 --header_version 1 \
--kernel_offset 00008000 --ramdisk_offset 02000000 --second_offset 00f00000 --tags_offset 01e00000 \
--cmdline "console=null androidboot.hardware=qcom video=vfb:640x400,bpp=32,memsize=3072000 msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 service_locator.enable=1 swiotlb=1"
Now my boot-new.img is working and tablet boots to android well.
Hi,
I just bought same model and like to know wich method you used.
i don't ask for a comlete guide as i know the amount of time and answer it comes with, but just know i you find a sm-t725 specific way or used a wifi version designed for.
Thx.
LtGarcia said:
Hi,
I just bought same model and like to know wich method you used.
i don't ask for a comlete guide as i know the amount of time and answer it comes with, but just know i you find a sm-t725 specific way or used a wifi version designed for.
Thx.
Click to expand...
Click to collapse
At first I got root, instruction is here https://forum.xda-developers.com/tab-s5e/how-to/galaxy-tab-s5e-sm-t720-root-t3947806
After that I found that twrp is ready and flashed it, but lost root. I think because twrp and magisk lives in recovery now. https://twrp.me/samsung/samsunggalaxytabs5ewifi.html
Then I rooted twrp and flashed it again and now I have my device with twrp and root.
I used twrp for wifi version and it works.
Thanks i rooted yesterday with this post thinking i can use sm-t720 method and you just confirmed me i can use sm-t720 twrp (for sm-t725) too. I will try to do same as you did. My final challenge will be to find a way to change my TVV csc into XEF as this tablet seems to be regionnaly locked.
Thanks again for your help.

Categories

Resources