patcher-oss icon indicating copy to clipboard operation
patcher-oss copied to clipboard

Doesn't work on Redmi 6 boot.img

Open megafon929 opened this issue 3 years ago • 11 comments

Hello. I ran into a strange problem. Patcher works with Redmi 6A boot.img, but does not work with Redmi 6 boot.img. I'm trying to understand the reason. The log is attached

C:\Users\yarpopkov\Desktop\patcher-oss-main>python main.py boot.img
INFO: Found 7-Zip at: C:\Program Files\7-Zip\7z.exe
INFO: Unpacking kernel data...
INFO: Patching kernel data...
INFO: Packing kernel data...
Traceback (most recent call last):
  File "C:\Users\yarpopkov\Desktop\patcher-oss-main\main.py", line 192, in <module>
    main()
  File "C:\Users\yarpopkov\Desktop\patcher-oss-main\main.py", line 53, in main
    BootWork(in_fn)
  File "C:\Users\yarpopkov\Desktop\patcher-oss-main\main.py", line 82, in init
    p = Patch(zimg_fobj)
  File "C:\Users\yarpopkov\Desktop\patcher-oss-main\main.py", line 102, in init
    self.split_zimg(zimg_file)
  File "C:\Users\yarpopkov\Desktop\patcher-oss-main\main.py", line 138, in split_zimg
    raise Exception(
Exception: ERROR: Can't find offset of orig GZIP size field

C:\Users\yarpopkov\Desktop\patcher-oss-main>

megafon929 avatar Jul 04 '21 21:07 megafon929

boot.zip Stock boot Redmi 6

megafon929 avatar Jul 04 '21 21:07 megafon929

thanks for the file, i will look into it once i have some free time.

YaAlex3 avatar Jul 06 '21 15:07 YaAlex3

Okay

megafon929 avatar Jul 06 '21 15:07 megafon929

cereus is arm32 sar too? pie boot image? some recent update?

YaAlex3 avatar Jul 06 '21 15:07 YaAlex3

  1. Yes
  2. Yes
  3. Yes, I used the latest version of patcher. Redmi 6 and 6A are almost identical, but for some reason the tool cannot patch boot.img for Redmi 6. I provide boot.img from Redmi 6A boot.zip

megafon929 avatar Jul 06 '21 17:07 megafon929

Log with boot.img for Redmi 6A

C:\Users\yarpopkov\Desktop\patcher-oss-main-1>python main.py boot.img
INFO: Found 7-Zip at: C:\Program Files\7-Zip\7z.exe
INFO: Unpacking kernel data...
INFO: Patching kernel data...
INFO: Packing kernel data...
INFO: Getting all back together...

C:\Users\yarpopkov\Desktop\patcher-oss-main-1>

Log with boot.img for Redmi 6

C:\Users\yarpopkov\Desktop\patcher-oss-main-2>python main.py boot.img
INFO: Found 7-Zip at: C:\Program Files\7-Zip\7z.exe
INFO: Unpacking kernel data...
INFO: Patching kernel data...
INFO: Packing kernel data...
Traceback (most recent call last):
  File "C:\Users\yarpopkov\Desktop\patcher-oss-main-2\main.py", line 192, in <module>
    main()
  File "C:\Users\yarpopkov\Desktop\patcher-oss-main-2\main.py", line 53, in main
    BootWork(in_fn)
  File "C:\Users\yarpopkov\Desktop\patcher-oss-main-2\main.py", line 82, in __init__
    p = Patch(zimg_fobj)
  File "C:\Users\yarpopkov\Desktop\patcher-oss-main-2\main.py", line 102, in __init__
    self.split_zimg(zimg_file)
  File "C:\Users\yarpopkov\Desktop\patcher-oss-main-2\main.py", line 138, in split_zimg
    raise Exception(
Exception: ERROR: Can't find offset of orig GZIP size field

C:\Users\yarpopkov\Desktop\patcher-oss-main-2>

megafon929 avatar Jul 06 '21 17:07 megafon929

boot.zip tell me if this one boots

YaAlex3 avatar Jul 07 '21 17:07 YaAlex3

Not working

megafon929 avatar Jul 09 '21 16:07 megafon929

@YaAlex3 There should be no need to patch the pointer to the original size, you could just leave/replace the size field in it's original location. I've added Magisk-Support for zImages in topjohnwu/Magisk#4526 and topjohnwu/Magisk#4527 doing it this way, though who knows when/if that will ever be merged. Other than that the attached boot.img has another issue, the specified dtb-size exceeds the kernel-size specified in it's header, maybe that image was modified previously?

chaosmaster avatar Jul 30 '21 14:07 chaosmaster

@chaosmaster i have found out already that the sizes dont match, for the record, all of the factory redmi 6 (cereus) images have this same issue, i couldn't get anything to boot and tried many things thank you for working on this though, im impressed to see someone finally do it, but im unsure if this will get any support from magisk developers

YaAlex3 avatar Jul 30 '21 22:07 YaAlex3

I have only looked at one other boot.img for cereus, that didn't seem to have the size mismatch. For your script that shouldn't be an issue though, since you are just copying all of it anyway. Magisk however will truncate the dtb according to the size specified in the header.

I have attached two boot images patched with magiskboot, one is truncated because of the size mismatch. The other one has the complete dtb and the header size fixed.

I would be interested to know if either of these images (or both) boot. The bootloader should only load the size specified in the header anyway, so if the stock-image worked, I would expect both of them to work as well.

NOTE: These images only have the skip_initramfs -> want_initramfs change and do not include a Magisk ramdisk

boot_patched.zip

chaosmaster avatar Jul 31 '21 15:07 chaosmaster