androidlinux-kernelkernelandroid-kernel

Android device vendor flashing 32-bit kernels on 64-bit SOCs?


I'm trying to recompile the kernel for an Android device. The device is Xioami Redmi 7A. It has a 64-bit processor Qualcomm Snapdragon 439. I compiled the kernel without errors, got the Image file under arch/arm64/boot/, so far so good.

I've tried to flash it onto the device. Firstly, I have downloaded the stock boot image. Then, I unpacked it using Android Image Kitchen:

./unpackimg original-boot

So now, according to all the tutorial out there, one should replace the old boot image with the newly compiled one, repack the image and flash it onto the device.

# replace the boot-img in the split-img folder
./repackimg
# now I get a fresh image-new.img, so I flash it
fastboot flash boot image-new.img

I tried that, but the device goes back into the fastboot mode.

So I started searching the forums. I've found this question on stackoverflow. The guy basically noticed that the image he got from the compiler is of different format than the original boot image. I checked that and got this:

Original boot image:

file boot-kernel
boot-kernel: Linux kernel ARM boot executable zImage (little-endian)

The compiled one:

file Image
Image: Linux kernel ARM64 boot executable Image, little-endian, 4K pages

I see two main differences:

  1. I compiled for ARM64, obviously, since the device has a 64 bit processor. But for some reason the original image seems to be ARM.
  2. My image is not compressed, and the original one is zImage.

This stackoverflow question suggests that only 32 bit ARM processors support zImage images. OK, that's cool, but wait... Does this mean that my 64 bit arm device runs a 32 bit arm boot image?

To make sure that it's not Android-Image-Kitchen error, that the script is good, I unpacked the original image, then repacked it and flashed it onto the device unmodified:

./unpackimg original-img
./repackimg
fastboot flash boot image-new.img

It boots! So, Android-Image-Kitchen must be out of the question.

Am I missing something or does it mean this device really is working under a 32-bit system, even though the processor supports 64-bit? Proof that it's 64-bit on qualcomm official website.

Is there a way to make sure of it? How can I find it out? Because if it's true, I must compile it with a 32-bit arm toolchain instead of the 64-bit one. Help?

UPD: I did getconf LONG_BIT on the device. Stupidly enough, it returned 32. So yeah, Xiaomi just flashed 32 bit kernel onto a 64 bit SOC. Lol. I'm gonna try to compile the kernel as 32 bit and answer my own question, if I succeed.


Solution

  • Hi the Redmi 8A has the same SoC but it has 64 bit kernel and OS... Some guys successfully ported 8A kernel to 7A of course not without problems.. In your case you may be able to combine 8A images with 7A... Hope this information helps you.