Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Unpack RockChip Boot Image #755

Closed
DarknessChild opened this issue Nov 3, 2018 · 49 comments
Closed

Unable to Unpack RockChip Boot Image #755

DarknessChild opened this issue Nov 3, 2018 · 49 comments
Labels
confirmed Issue confirmed to exist and the reason is known

Comments

@DarknessChild
Copy link

Device: Geekbox (RockChip RK3368)
Attempted to modify boot.img from Magisk Manager
Android 6.0.1

Log:https://drive.google.com/open?id=1bRc4r5AzXdjS1AdK4KLvM8VoXSaCOJgU

boot.img: https://drive.google.com/open?id=1vKl74AqkbvjpKVwQO5mn31ggk-Q_iNe-

@omgiafs
Copy link

omgiafs commented Nov 5, 2018

Same problem with another Rockchip device - Beelink R89 (RockChip RK3288).
TWRP Log: recovery.log.

Firmware files (including TWRP recovery and stock boot.img):
Wasser-4.0.11_with_TWRP_3.zip (13 MB)

@osm0sis
Copy link
Collaborator

osm0sis commented Dec 2, 2018

@topjohnwu,

@DarknessChild's "boot.img" isn't normal, even for RK. It's possibly just a raw ramdisk without any header. Not sure what you can do with that.

@omgiafs's "boot.img" and "recovery.img" are in the normal RK KRNL headered format, which is basically just a normal .cpio.gz ramdisk signed with their rkcrc tool. "kernel.img" is the uncompressed(?) kernel Image, also apparently signed with rkcrc.

The latter is definitely easy to support, since I already support it in AIK and AK2; basically just skipping 8 bytes to dump the ramdisk past the header, then signing it with rkcrc on repack, and presumably you could do something similar with the kernel Image (if that's even needed).

rkcrc source is here: https://github.com/rockchip-linux/rkflashtool

@topjohnwu topjohnwu added the confirmed Issue confirmed to exist and the reason is known label Dec 9, 2018
@osm0sis

This comment has been minimized.

@topjohnwu topjohnwu changed the title Unable to Unpack Boot Image Unable to Unpack RockChip Boot Image Feb 26, 2019
@bentwire
Copy link

Having similar issues with the NanoPC-T4. Any updates? Love this product BTW!

Repository owner deleted a comment Feb 27, 2019
Repository owner deleted a comment Feb 27, 2019
@tightly4849
Copy link

Having similar issues with the NanoPC-T4. Any updates? Love this product BTW!

Same device with same problem......
Manully patch boot image works on AmLogic platform(Khadas Vim),but not RK......

@Tiemichael
Copy link

Same problem here with NanoPC-T4 ...

@proditaki
Copy link

proditaki commented Mar 25, 2019

Same problem with RK3328
Device : A5X max
Android: 7.1.1
see attached boot.img
boot.zip

@proditaki
Copy link

@topjohnwu

I can unpack alle the needed files manually. Just dont know how to manually deploy Magisk into this system.

I can also get a root Shell on the running system with adb.

One of these options would allow me to manually install magisk?

@tightly4849
Copy link

@topjohnwu

I can unpack alle the needed files manually. Just dont know how to manually deploy Magisk into this system.

I can also get a root Shell on the running system with adb.

One of these options would allow me to manually install magisk?

Just use "dd" command in root shell to overwrite patched image to boot block
For example

dd if=/sdcard/patched_boot.img of=/dev/block/platform/soc/7824900.sdhci/by-name/boot

Reboot the device,and you should have it rooted with Magisk.
BTW,what method did you used to solve the problem that Magisk doesn't recognize some kinds of Rockchip boot image?

@proditaki
Copy link

@zengpinyi

No i mean manually insert Magisk into the image. Since we can manually unpack the boot.img and repack and resign it.

@osm0sis
Copy link
Collaborator

osm0sis commented May 11, 2019

Another fun trick is, using AIK-mobile, to unpack the ramdisk, then just take the whole ramdisk.cpio.gz, put it in a generic AOSP format boot.img. Then have Magisk Manager patch that, and then unpack magisk_patched.img to get the patched ramdisk.cpio.gz and then repack it as RK in AIK-mobile again. 👍

That said, @topjohnwu has said he will likely support RK "KRNL" headered images, since rkcrc is pretty trivial code, but it's not a priority.

@proditaki
Copy link

@osm0sis
Thank you. I Will try that

@traversone
Copy link

Hi all,

just successfully completed all the steps suggested by @osm0sis but now...what to do more?

After new patched boot has been flashed, system restarted, Magisk Manager (just installed) says "Magisk not installed".....probably I miss some further steps, please guide me.

thank you all

@proditaki
Copy link

proditaki commented May 13, 2019

@traversone
Did you install the latest version? 19.1?
I saw a bug where someone had the same problem (not installed) after a normal install.

You could try version 18 if that's the case

@traversone
Copy link

I have used latest 19.1 version meaning that I patched the (modified in AIK as suggested earlier) with Manager 7.1.2 !

Now you are suggesting to patch the same (AOSP wise) file with Manager 6.1.0, aren't you?

thank you

@proditaki
Copy link

@traversone
Yes.
It's worth a try

@traversone
Copy link

sure, I will try again!

So, our expectaion is that - by simply flashing proper boot.img - Manager running in the System will see the root working.

thanks

@proditaki
Copy link

@traversone i tried 7.1.2 too. Same result: Magisk not found

@traversone
Copy link

..which steps have you followed?

I am a bit suprised as - once the AOSP boot.img is repacked with "boot_ori.img-ramdisk.cpio.gz" file taken from KRNL boot.img and overwritten to the original - a new "ramdisk-new.cpio.gz" appears in the AIK root directory.

What is this?

@proditaki
Copy link

@traversone
I put the ramdisk with the kernel in a generic AOSP image. Patched that with Magisk manager.

Then replaced the ramdisk with the patched one and created a RK boot image and flashed it to the device.

I dont know if there are other steps that need to be done after this.

Ill check the filesystem of the device when i get home and see if the Magisk binaries are on the system.

@traversone
Copy link

Manager 7.0.0 needs (mandatory?) to be upgraded to 7.1.2 thus making impossible to patch the boot.img.....I really hope @topjohnwu will manage to make his fantastic tool able to work with such kind of images!

@tugaz
Copy link

tugaz commented May 14, 2019

I have done like osm0sis told and it works very well with last version. My rockchip device is a px3 car unit with android 7.1

@proditaki
Copy link

@tugaz
weird. could you explain what you did? maybe i missed a step.

@tugaz
Copy link

tugaz commented May 14, 2019

First I unpacked in AIK windows my AOSP recovery.img, after I copyed the split_img files from this img to another folder with my unpacked boot.img and packed in AOSP format, then I exported my boot.img to my device, then patched in magisk, unpack it with AIK-mobile, change the imgtype file from AOSP to KRNL, repack it again and flashed in my device and it works fine.

@traversone
Copy link

@tugaz

How to change the image format?

Sorry for the stupid question maybe

@proditaki
Copy link

proditaki commented May 15, 2019

@tugaz
What recovery image did you use?
A generic one?

I cant unpack the image i have for my device with AIK
(The one that's flashed on it now)

I used rkunpack to extract the recovery image and got the boot.img and kernel.img of that

@tugaz
Copy link

tugaz commented May 15, 2019

I used recovery image from my device that is AOSP format.

@proditaki
Copy link

Ok. Mine wont unpack in AIK :(

@tugaz
Copy link

tugaz commented May 15, 2019

I think that you can use the split_img files from any AOSP image to use in your boot image but I not sure of that

@proditaki
Copy link

proditaki commented May 15, 2019

hmk. I reflashed it manually (the patched patched boot.img) with dd
but magisk manager says: magisk not installed.

When i dump the bootimg from my device, and i unpack it, i see the smaller init file that magisk installes (326 kb)

when i look on my device with adb shell i see when i do ls -al /
-rwxr-x--- 1 root root 1.4M 2019-05-15 18:26 init

anyone know whats going on ? :)

edit: weird.. the files are there.. magisk is just not starting
rk3328_box:/sbin # ls
charger magisk magiskhide magiskinit magiskpolicy mkdosfs resetprop su supolicy ueventd watchdogd
rk3328_box:/sbin #

@Ziggy815
Copy link

On what System did you patch the boot.img ? I had the same problem .. made a boot.img with the ramdisk from the rk image and patched it on a 64bit qcom device ... so magisk replaced the init file in the ramdisk with the 64bit version but my rk was 32bit so it could not work...
Try to unpack the modified boot.img again using AIK ... in the ramdisk folder is a file called init, when you open the magisk.zip you see in the arm directory magiskinit and magiskinit64 ... unpack the magiskinit and replace the initfile in your ramdisk with it. repack the image and flash it, everything should work

@proditaki
Copy link

proditaki commented May 15, 2019

@Ziggy815

I patched it on my rockchip device, so the target device.

I will try your suggestions tho. Thanks

Edit: turns out the SoC is 64bit but the OS is 32bit.
edit: os is 64 bit too.. idk why it doesnt work. weird.

I looked at dmesg | grep magisk and see the folowwing.
Looks like it's an access problem or something?

dmesg log is here
https://pastebin.com/raw/seRaLaeV

@mo123
Copy link

mo123 commented May 17, 2019

I patched a Rockchip RK3328 Oreo boot.img and Magisk works sometimes.
After power on, Magisk Manager says 'Magisk is not installed'.
But after I do a restart and wait 2 minutes and open Magisk Manager then it says 'Magisk is installed' and it works correctly. But sometimes a Restart also doesn't work, only half of the time.

Magisk 19.1 Canary build also never gives the popup message that Additional setup is required like in older 17.1 versions, So that is also a bug.
After power off and on again, Magisk status is lost again then you need to do a restart again.

So what is different in a 'Restart' compared to a cold boot/power on that Magisk Manager says it's not installed?

I think Magisk might be loaded too early in the boot process or maybe something to do with the 64-bit patched boot.img files that have a problem compared to 32-bit?

Magisk is fully supported on Rockchip on Android Pie firmware by Rockchip themselves.
But Pie uses a completely different boot process compared to older OS's.
https://gitlab.com/rockchip-group/docs/android/blob/rk33/mid/android-9.0/Rockchip_Magisk_installation_guidelines.pdf

Here is a logcat of Magisk 19.1 Canary build on RK3328 Oreo when it worked and I used 'Restart' after power on.
logcat.log

We really need to get it working on earlier Android OS's correctly so it doesn't say 'Magisk is not installed' with a manually patched boot.img.

@topjohnwu Please check the Magisk issue on Rockchip devices, mounting to early, Magisk not loaded, Rockchip krnl repacking support etc.

@proditaki
Copy link

proditaki commented May 17, 2019

@mo123
I have the same problem on my rk3328.
Good to know its not just me.

Im on android 8.1

@mo123
Copy link

mo123 commented May 17, 2019

@mo123
I have the same problem on my rk3328.
Good to know its not just me.

Im on android 8.1

Can you also try - TvSettings - About - Restart then wait 2 minutes and open Magisk Manager again a few times?
Also try Restart after power on but then open
a File Manager that needs root to view /root folder and click multiple times on it to request root, Magisk might wake up and then grant root access and say it's installed if you open Magisk Manager.

Here is my patched boot.img for RK3328 Oreo, unzip it first.
newboot.img.gz

@proditaki
Copy link

proditaki commented May 17, 2019

@mo123

For me it worked once, and it told me that Additional setup is required, so i think my bootimg is patched correctly.

I will try the 2 minutes after restart when i get home.

Edit: fun fact is i wanted to install magisk to use the Sony Framework module, which isn't even updated for 19.1 lol.

update:I couldnt get magisk to work.
Then I downgraded my box to android 7.1.2 and it worked instantly....

@uudruid74
Copy link

I'm using a Libre Renegade with a RK3328, 4GB. OS is Station OS, Android 7.1. The on-board recovery is basically useless since it wants you to use vol up/down and those keys don't exist. I managed to use the latest Magisk Manager to patch the boot.img from the last update.zip and applied it with the proprietary 'upgrade_tool' for RockUSB mode. It applies, but the system won't boot and I'm stuck at recovery. Using upgrade_tool to flash the original boot.img lets it boot.

Magisk displays no errors patching the file. Any ideas where to start?

@proditaki
Copy link

proditaki commented May 19, 2019

@uudruid74
Maybe your patched image is still in AOSP format.
You can unpack it with AIK and check the imgtype in the split_img folder.

If IT says AOSP change it to KRNL and repack the image and flash it to your device.

@CatMe0w
Copy link

CatMe0w commented Jul 6, 2019

#1595 Related issue, Magisk Manager cannot determine RockChip boot image location.

@uudruid74
Copy link

@uudruid74
Maybe your patched image is still in AOSP format.
You can unpack it with AIK and check the imgtype in the split_img folder.

If IT says AOSP change it to KRNL and repack the image and flash it to your device.

The new Magisk Manager correctly identifies that it doesn't understand this format. Unpacking it shows it to be in AOSP format. Changing it to KRNL format drops the size down to about 1/10, so I'm guessing some information is lost. I need to put this back into the upgrade.zip (if Magisk ever recognizes it). However, this unpack/change format/repack doesn't give me a format that Magisk understands. I just want to root this thing!

Is there another way?

@proditaki
Copy link

proditaki commented Aug 24, 2019

@uudruid74

The boot partiton is 32MB i think (OR 16, dont remember exactly). But most of it is empty.

So when u repack it it strips all.the empty data at the end. Mine ends up about 1.6 MB i think.

When its patched with magisk repack it to KRNL format and Just dd it to the boot partition

@tobalr
Copy link

tobalr commented Oct 11, 2019

I was able to successfully install magisk on Android 8.1, RockPro64 (Rockchip3399) using the directions by @tugaz and @osm0sis
I used this AOSP boot.img (attached) and AIK

  1. Unpack generic boot.img. Move this to folder "G"
  2. Unpack rockchip boot.img. Move this to folder "R"
  3. Move ramdisk folder from R into G
  4. Repack content of G and move resulting image-new.img to any device with latest magisk manager installed. Use this to patch the image. Lets call resulting image "image-new.patched.img"
  5. Unpack image-new.patched.img. Move this folder to "P"
  6. Move ramdisk folder from P into R
  7. Repack R. The resulting img file can be applied using dd.
    boot img files.zip

@julianfairfax
Copy link

I was able to successfully install magisk on Android 8.1, RockPro64 (Rockchip3399) using the directions by @tugaz and @osm0sis
I used this AOSP boot.img (attached) and AIK

  1. Unpack generic boot.img. Move this to folder "G"
  2. Unpack rockchip boot.img. Move this to folder "R"
  3. Move ramdisk folder from R into G
  4. Repack content of G and move resulting image-new.img to any device with latest magisk manager installed. Use this to patch the image. Lets call resulting image "image-new.patched.img"
  5. Unpack image-new.patched.img. Move this folder to "P"
  6. Move ramdisk folder from P into R
  7. Repack R. The resulting img file can be applied using dd.
    boot img files.zip

I tried to follow along with these steps using the Linux/macOS version and the mobile version of AIK but so far I've had no luck. I have an RK3229 board on 8.1 Oreo, that came factory rooted with koush's Superuser. I'll supply my boot.img if anyone can help with this. Then comes the fun part of removing Superuser and the su binary without TWRP (since I don't have it) and without bricking :/

Thanks for anyone's help. I really appreciate it.
boot.img.zip

@topjohnwu
Copy link
Owner

After evaluating the effort of bringing up support for Rockchip, I have decided not to spend time on such drastically different image format, as it requires significant code changes.

@winstonma
Copy link

winstonma commented Apr 30, 2020

Hi, I got an Onyx Boox Nova which is Android 6.0.1 on RK3288. Since the device has no TWRP therefore I used the Magisk Manager method.

Here are my steps:

  1. Entered the fastboot mode and dumped the whole system image from rkdumper

  2. Patched boot.img using Magisk Manager 7.5.1 (on another phone, because I have problem patching the boot.img on my device)

  3. Load the patched boot.img back to my device using AndroidTool

But my device it goes to recovery directly after the reboot. I have to flash the original boot.img back to the system in order to get the system back to work.

There are several questions I would like to seek help from the experts

  1. Is my procedure mentioned similar to the method used by @DarknessChild?

  2. Is it possible to use the procedure mentioned by @tobalr in order to get Magisk work on my device? Or is boot.img I obtained using rkdumper and AOSP boot.img same? If it is different then I am screwed since their update package is encrypted.

  3. I know it is a bit off topic but since KingRoot is closed last year I have problem obtaining root from this Android Device. If Magisk wouldn't work for me is it possible for me to obtain root using alternative method?

Thanks in advance

I attached the boot.zip as a backup.

@winstonma
Copy link

winstonma commented May 3, 2020

I was able to successfully install magisk on Android 8.1, RockPro64 (Rockchip3399) using the directions by @tugaz and @osm0sis
I used this AOSP boot.img (attached) and AIK

  1. Unpack generic boot.img. Move this to folder "G"
  2. Unpack rockchip boot.img. Move this to folder "R"
  3. Move ramdisk folder from R into G
  4. Repack content of G and move resulting image-new.img to any device with latest magisk manager installed. Use this to patch the image. Lets call resulting image "image-new.patched.img"
  5. Unpack image-new.patched.img. Move this folder to "P"
  6. Move ramdisk folder from P into R
  7. Repack R. The resulting img file can be applied using dd.
    boot img files.zip

I tried to follow along with these steps using the Linux/macOS version and the mobile version of AIK but so far I've had no luck. I have an RK3229 board on 8.1 Oreo, that came factory rooted with koush's Superuser. I'll supply my boot.img if anyone can help with this. Then comes the fun part of removing Superuser and the su binary without TWRP (since I don't have it) and without bricking :/

Thanks for anyone's help. I really appreciate it.
boot.img.zip

In addition I did the following procedure:

  1. Unpack the boot.img

  2. Repack the unpacked content

  3. Load the newly packed image back to the device

And it won't boot. So I am not sure if the repack tool really can generate a boot.img the device needed.

@julianfairfax
Copy link

I was able to successfully install magisk on Android 8.1, RockPro64 (Rockchip3399) using the directions by @tugaz and @osm0sis
I used this AOSP boot.img (attached) and AIK

  1. Unpack generic boot.img. Move this to folder "G"
  2. Unpack rockchip boot.img. Move this to folder "R"
  3. Move ramdisk folder from R into G
  4. Repack content of G and move resulting image-new.img to any device with latest magisk manager installed. Use this to patch the image. Lets call resulting image "image-new.patched.img"
  5. Unpack image-new.patched.img. Move this folder to "P"
  6. Move ramdisk folder from P into R
  7. Repack R. The resulting img file can be applied using dd.
    boot img files.zip

I followed these steps only to be met with an error at number 4 :/

! Boot image patched by unsupported programs
! Please restore back to stock boot image

@Vishalattri2110
Copy link

Help me when i am patching my boot.img through magisk manager it is saying unable to unpack /unknown image format please help me. I am providing you my boot.img please help me.
I am providing in zip format because the website is not allowing me to send .img . So just extract it and see what is the problem.please help me . I am using oppo f15 (cph2001) and the boot image which iam sending is from the latest firmware of oppo f15 ( CPH2001PUEX_11_OTA_1470_all_GlioAPybO0Vk) software version - CPH2001EX_11_C.47
boot.zip

@osm0sis
Copy link
Collaborator

osm0sis commented Jan 5, 2021

Help me when i am patching my boot.img through magisk manager it is saying unable to unpack /unknown image format please help me. I am providing you my boot.img please help me.
I am providing in zip format because the website is not allowing me to send .img . So just extract it and see what is the problem.please help me . I am using oppo f15 (cph2001) and the boot image which iam sending is from the latest firmware of oppo f15 ( CPH2001PUEX_11_OTA_1470_all_GlioAPybO0Vk) software version - CPH2001EX_11_C.47
boot.zip

The image header is OPPOENCRYPT! So unless you can decrypt it first you won't be able to patch it.

Also don't necro-bump old unrelated issues.

Repository owner locked as off-topic and limited conversation to collaborators Jan 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
confirmed Issue confirmed to exist and the reason is known
Projects
None yet
Development

No branches or pull requests