[Fastboot] Invalid sparse file format at header magic. How to fix?

Search This thread
Okay, so I own a Red Magic 6 and it's currently bricked. There is no unbrick tool for this device yet and there isn't going to be one for a while.

My bootloader is unlocked. I have tried reflashing the files using fastboot. However when I go to flash the system, it prints out:


Invalid sparse file format at header magic
Sending sparse 'system' 1/4 (786352 KB) OKAY [ 18.114s]
Writing 'system' FAILED (remote: 'Partition not found')
fastboot: error: Command failed


(Phone came with a/b partition just a heads up and it runs on Stock android 11)


I have searched EVERYWHERE, from forums, to tools, to python scripts.... EVERYTHING. No solution.

Yes, my fastboot is on the lastest version and yes I tried the --force command on fastboot. Still no luck.


I have researched everything about sparse images but am still having problems. I tried converting the image to a RAW ext4 img but it fails.

Is there any workaround for this?
 

KenzoUme

Member
Dec 6, 2020
11
2
Okay, so I own a Red Magic 6 and it's currently bricked. There is no unbrick tool for this device yet and there isn't going to be one for a while.

My bootloader is unlocked. I have tried reflashing the files using fastboot. However when I go to flash the system, it prints out:


Invalid sparse file format at header magic
Sending sparse 'system' 1/4 (786352 KB) OKAY [ 18.114s]
Writing 'system' FAILED (remote: 'Partition not found')
fastboot: error: Command failed


(Phone came with a/b partition just a heads up and it runs on Stock android 11)


I have searched EVERYWHERE, from forums, to tools, to python scripts.... EVERYTHING. No solution.

Yes, my fastboot is on the lastest version and yes I tried the --force command on fastboot. Still no luck.


I have researched everything about sparse images but am still having problems. I tried converting the image to a RAW ext4 img but it fails.

Is there any workaround for this?
I am looking for the same thing. Can't find the answer. Have you found a solution?
 

SkylineDriver

Senior Member
Nov 27, 2017
76
19
Wilmington, NC Metro :(
Out of curiosity, was there ever a resolution to this issue?

Have RM6SP, was rooted- all good. Battery ran empty and shut off. When I rebooted it just boots directly to fastboot. Recovery is useless (wiped user data but no cache to erase(?)).

Extracted payload.bin, tried flashing boot.img, rebooted, only goes to fastboot. Tried flashing everything from payload.bin- some flashed, others had errors. Just endless loading to fastboot.

Curious if anyone has actually SUCCESSFULLY unbricked these devices?
 

DavidxxxD

Senior Member
Look like your partition table my be corrupted... I don't own this device myself but have a fairly good understanding of android partitions and am happy to help.
Please show the output of
Code:
fastboot getvar ptable
and the errors you get when trying to flash
 

SkylineDriver

Senior Member
Nov 27, 2017
76
19
Wilmington, NC Metro :(
Hello DavidxxxD and thank you for replying.

Execution of "getvar ptable" results in "FAILED (remote: 'Unknown variable')

I then executed "getvar all" and attached the result. Same whether on fastboot or fastbootd.

As for your other question, when I try to flash product, system, and vendor I get the above "Invalid Sparse File Format at Header Magic" error.

Thank you for any suggestions and your time. This is not my daily driver so there is no urgent, pressing need (I'll never get rid of my trusty S7edge, lol).

EDIT: thanks to the unbrick tool in the 6S Pro forum, I have successfully unbricked this phone. Up and running and on way to getting re-rooted.

Thanks to everyone who offered help!
 

Attachments

  • NS669J Getvar all.txt
    11.4 KB · Views: 21
Last edited:

DavidxxxD

Senior Member
Glad to hear you already got it unbricked!
For the sake of it being an intresting case, here is the more complicated way I put together and what I could find out from looking at the attatchment and a payload file for your device:

Good news - Your device is not too badly bricked.

Like some other new devices, this phone does not use a cache partition. That is why the recovery has no option to wipe cache.

The "invalid sparse header" message gets triggered when using fastboot to send a filesystem image that is not in the expected android sparse format. This can safely be ignored as the images for your device are uncompressed and the program doesn't know what they're suppsed to look like.

The NX669J uses a dynamic partition and the one on yours appears messed up in a way where I have no idea how it got to this point - all partitions for the A-slot are missing and instead there is a "system" (not system_a) and "system_b-cow" (!?) - This is probably why the bootloader is freaking out.

Usually, something like this can be fixed by just reflashing the super partition. However the update payload does not seem to contain one, so - unless you have a super.img from somewhere else - you would have to manually fix the current layout.

- Put the device is fastbootd mode
Code:
fastboot reboot-fastboot
Note: To verify, you can run
Code:
fastboot getvar is-userspace

- Firstly, remove the strange partition entries
Code:
fastboot delete-logical-partition system
fastboot delete-logical-partition system_b-cow

- Next, re-create the missing entries
Code:
fastboot create-logical-partition system_a 1000
fastboot create-logical-partition system_ext_a 1000
fastboot create-logical-partition product_a 1000
fastboot create-logical-partition vendor_a 1000
fastboot create-logical-partition odm_a 1000
Note: 1000 will set the partition size to a kilobyte. This doesn't matter as flashing will automatically resize them.

- After that, you should be able to flash to the newly created partitions
Code:
fastboot flash system_a system.img
fastboot flash system_ext_a system_ext.img
fastboot flash product_a product.img
fastboot flash vendor_a vendor.img
fastboot flash odm_a odm.img
Note: If you get an error saying "not enough space to resize partition", try
Code:
fastboot erase system_b
fastboot resize-logical-partition system_b 1000

- Finally, set the active slot to A and reboot
Code:
fastboot set_active a
fastboot reboot
Note: If it doesn't boot or the system starts crashing, you may have to flash the other firmware images as well or try using slot B.

In case this doesn't work, you can ask someone with a rooted NX669J to dump their super partition and send it to you. If you do, make sure to check it first using lpdump. Flashing a corrupted image is going to make it worse 100% guaranteed.

I hope this gives you a better idea of what was wrong and how to deal with similar issues in the future. Of course, a low-level unbrick tool works fine too - but where's the fun in that?

P. S: I'm actually typing this on a flat S7 - still an amazing device, 6 years after release : )
 
Last edited:

SkylineDriver

Senior Member
Nov 27, 2017
76
19
Wilmington, NC Metro :(
Thank you, DavidxxxD, for taking the time out and providing a detailed reply. Hopefully this info might come in useful to someone one day.

I have no idea why a dead battery would "zonk" the phone, but it did. I wonder if it might have been something with magisk...?
¯\_(ツ)_/¯

Sadly, these phones are not popular and support from Nubia is painful, at best. Thanks to folks like you there is still help for those in need.

Again, many thanks for your time and help!
 

cksy1112

New member
Oct 14, 2014
3
0
Glad to hear you already got it unbricked!
For the sake of it being an intresting case, here is the more complicated way I put together and what I could find out from looking at the attatchment and a payload file for your device:

Good news - Your device is not too badly bricked.

Like some other new devices, this phone does not use a cache partition. That is why the recovery has no option to wipe cache.

The "invalid sparse header" message gets triggered when using fastboot to send a filesystem image that is not in the expected android sparse format. This can safely be ignored as the images for your device are uncompressed and the program doesn't know what they're suppsed to look like.

The NX669J uses a dynamic partition and the one on yours appears messed up in a way where I have no idea how it got to this point - all partitions for the A-slot are missing and instead there is a "system" (not system_a) and "system_b-cow" (!?) - This is probably why the bootloader is freaking out.

Usually, something like this can be fixed by just reflashing the super partition. However the update payload does not seem to contain one, so - unless you have a super.img from somewhere else - you would have to manually fix the current layout.

- Put the device is fastbootd mode
Code:
fastboot reboot-fastboot
Note: To verify, you can run
Code:
fastboot getvar is-userspace

- Firstly, remove the strange partition entries
Code:
fastboot delete-logical-partition system
fastboot delete-logical-partition system_b-cow

- Next, re-create the missing entries
Code:
fastboot create-logical-partition system_a 1000
fastboot create-logical-partition system_ext_a 1000
fastboot create-logical-partition product_a 1000
fastboot create-logical-partition vendor_a 1000
fastboot create-logical-partition odm_a 1000
Note: 1000 will set the partition size to a kilobyte. This doesn't matter as flashing will automatically resize them.

- After that, you should be able to flash to the newly created partitions
Code:
fastboot flash system_a system.img
fastboot flash system_ext_a system_ext.img
fastboot flash product_a product.img
fastboot flash vendor_a vendor.img
fastboot flash odm_a odm.img
Note: If you get an error saying "not enough space to resize partition", try
Code:
fastboot erase system_b
fastboot resize-logical-partition system_b 1000

- Finally, set the active slot to A and reboot
Code:
fastboot set_active a
fastboot reboot
Note: If it doesn't boot or the system starts crashing, you may have to flash the other firmware images as well or try using slot B.

In case this doesn't work, you can ask someone with a rooted NX669J to dump their super partition and send it to you. If you do, make sure to check it first using lpdump. Flashing a corrupted image is going to make it worse 100% guaranteed.

I hope this gives you a better idea of what was wrong and how to deal with similar issues in the future. Of course, a low-level unbrick tool works fine too - but where's the fun in that?

P. S: I'm actually typing this on a flat S7 - still an amazing device, 6 years after release : )

Hi DavidxxxD,

I had a quite a similar problem here, sometimes ago while trying to install TWRP and Magisk onto my nubia Z20 NX627J, unfortunately did not succeed and got myself a bricked phone. Now phone can only go into fastboot mode.

Had been trying to flash everything from scratch via fastbboot, did not get any error messages with flashing all the img, bin except while flashing system. img, it returned with a " Invalid sparse file format at header magic" but went on with the process without issue. However, the phone still enable to boot up normally.

Is it possible that that the rom I have is not the original stock rom?

So while searching for an answer, was happy to found this thread at XDA forum. After going through the thread on your reply to SkylineDriver, i was hoping you can help and enlighten me if I had miss anything.

Attached is the getvar file from my bricked phone after flashing, another file is the fastboot command I followed, except the flash system command, i just did a "fastboot flash system system.img" without the "-S 100M' because I didn't know what "-S 100M" means".

Thanks in advance
 

Attachments

  • fastboot command.txt
    686 bytes · Views: 4
  • nubia z20 NX627J getvar.txt
    8 KB · Views: 1

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    Glad to hear you already got it unbricked!
    For the sake of it being an intresting case, here is the more complicated way I put together and what I could find out from looking at the attatchment and a payload file for your device:

    Good news - Your device is not too badly bricked.

    Like some other new devices, this phone does not use a cache partition. That is why the recovery has no option to wipe cache.

    The "invalid sparse header" message gets triggered when using fastboot to send a filesystem image that is not in the expected android sparse format. This can safely be ignored as the images for your device are uncompressed and the program doesn't know what they're suppsed to look like.

    The NX669J uses a dynamic partition and the one on yours appears messed up in a way where I have no idea how it got to this point - all partitions for the A-slot are missing and instead there is a "system" (not system_a) and "system_b-cow" (!?) - This is probably why the bootloader is freaking out.

    Usually, something like this can be fixed by just reflashing the super partition. However the update payload does not seem to contain one, so - unless you have a super.img from somewhere else - you would have to manually fix the current layout.

    - Put the device is fastbootd mode
    Code:
    fastboot reboot-fastboot
    Note: To verify, you can run
    Code:
    fastboot getvar is-userspace

    - Firstly, remove the strange partition entries
    Code:
    fastboot delete-logical-partition system
    fastboot delete-logical-partition system_b-cow

    - Next, re-create the missing entries
    Code:
    fastboot create-logical-partition system_a 1000
    fastboot create-logical-partition system_ext_a 1000
    fastboot create-logical-partition product_a 1000
    fastboot create-logical-partition vendor_a 1000
    fastboot create-logical-partition odm_a 1000
    Note: 1000 will set the partition size to a kilobyte. This doesn't matter as flashing will automatically resize them.

    - After that, you should be able to flash to the newly created partitions
    Code:
    fastboot flash system_a system.img
    fastboot flash system_ext_a system_ext.img
    fastboot flash product_a product.img
    fastboot flash vendor_a vendor.img
    fastboot flash odm_a odm.img
    Note: If you get an error saying "not enough space to resize partition", try
    Code:
    fastboot erase system_b
    fastboot resize-logical-partition system_b 1000

    - Finally, set the active slot to A and reboot
    Code:
    fastboot set_active a
    fastboot reboot
    Note: If it doesn't boot or the system starts crashing, you may have to flash the other firmware images as well or try using slot B.

    In case this doesn't work, you can ask someone with a rooted NX669J to dump their super partition and send it to you. If you do, make sure to check it first using lpdump. Flashing a corrupted image is going to make it worse 100% guaranteed.

    I hope this gives you a better idea of what was wrong and how to deal with similar issues in the future. Of course, a low-level unbrick tool works fine too - but where's the fun in that?

    P. S: I'm actually typing this on a flat S7 - still an amazing device, 6 years after release : )