yashsingh1/xdaforums huggingface dataset:
[HTC One SV] klembo1957:
OK I just tried UNMKBOOTIMG and I got the result you showed in the earlier picture. So, in other words, the error message has gone.

I just tried UNMKBOOTIMG -I BOOT.IMG and...............

"kernel written to 'kernel' (5282832 bytes)

ramdisk written to 'ramdisk.cpio.gz' (3269198 bytes)

And then I see the directions...... "To rebuild this boot image, you can use the command: etc.

Looks like it worked! Thank you!!! (although I am still a little miffed, I know I put all the files in the correct directories/partitions, and followed the directions to the letter. I hate it when I can't make things work without help)

But I am glad you were there to help. If there is anything else you can think of that I may need to know, please pass it along. It's been great talking to you. One other observation. I wish SOMEONE would fix terminal emulator so you can repeat the previous command, the same as when using ADB (you know, pressing the "up arrow" key, and the previous commands appear so you can retry or edit them. The terminal emulator screen is TOO SMALL to be retyping all the time. THEN you could truly do everything from your phone just like a PC.
[HTC One SV] :
Outstanding! Glad it is working. It was most likely user error on your part as much as you probably don't want to hear that lol. It happens though. Anyways, if you have any other problems down the road just come on by again and I will do my best to help you troubleshoot the problem. Take care and

-- Happy Hunting!!!
[HTC One SV] russellvone:
[MENTION=5095582]klembo1957[/MENTION]

get a keyboard with arrows, the stock keyboard for our device has one just enable it under settings....then you can use the "up" arrow like with adb.....lol
[HTC One SV] klembo1957:
Honestly, I realize I could get a different keyboard. BUT............

I read some other posts around the web talking about terminal emulator where people were talking about it, wishing that it would work like ADB. I automatically assumed that terminal emulator wouldn't let you use the arrows to redisplay the previous entry. OOPS

Thanks, I'm gonna go get another keyboard. You just saved me a LOT of time trying to type with my big fingers. Thanks

---------- Post added at 06:04 PM ---------- Previous post was at 06:01 PM ----------

You are right, I am tempted to try it again using the original method, just to prove to myself I followed the directions. ( Yes, I am stubborn that way)

I really don't know when to give up................................LOL
[HTC One SV] klembo1957:
I checked the stock LG keyboard and there are no arrows. Am I missing something?
[HTC One SV] russellvone:
sorry my friend... I meant stock HTC OneSV keyboard....has arrow option

but I personally use and love Swype keyboard it has arrows I'll post with pic.
[HTC One SV] klembo1957:
That's cool, I was wondering LOL

OK I'll try a SWIPE keyboard too. I got the hackers keyboard, but man are the characters small. Maybe swipe will be a little better. thank you
[HTC One SV] russellvone:
I think you'll enjoy.....

let me know!
[HTC One SV] klembo1957:
OK I had to try it. I went into my phone and deleted everything having to do with this. Then, I downloaded the files again, and after doing my "mount -o rw,remount /dev/block/mmcblk0p8" on my phone, extracted the files to /system/bin again. AND, this time everything works as advertized.

I guess I just didn't get a good download last time or something, because it all works just like you described in the posts. Didn't have to use the flashable zip. (told you I was stubborn, I had to prove to myself that I followed the directions correctly). LOL. SO now I move forward. Thank you again!!!
[HTC One SV] klembo1957:
I tried the swype board, but couldn't see or find the arrow keys (sure they are there, but couldn't get them to work). Downloaded the hackers keyboard, and arrow keys make terminal emulator behave just like command line in windows or adb. So far so good. Thanks to you and all here at xda.

Every time I delve into something, I become just a little less of a NOOB. Just a little. Can't wait to be able to drop the NOOB description!!!
[HTC One SV] MgudFrn:
When I do this I get this:

gunzip: Invalid magic

Help Needed Please!!
[HTC One SV] :
Before running that command, did you change directories to your ramdisk folder?
[HTC One SV] MgudFrn:
Ya, sure:

p -c ../ramdisk.cpio.gz | cpio -i <

gunzip: invalid magic

root@android:/sdcard/backups/ramdisk #
[HTC One SV] :
Send me this boot.img file.
[HTC One SV] :
Either your ramdisk is invalid or it is due to you trying to unpack the ramdisk contents from your sdcard. I would suggest doing that on either your system partition or data partition. My guide is based on instructions given within the data partition (/data/local/tmp). The sdcard is a vfat format which tends to cause issues to some file permissions which in turns causes issues when using binaries to read, write, and execute properly. This is not always the case, but it happens a lot. Try following my guide without using your internal or external sdcard and let me know if that works out for you. If it still fails, then I need you to send me that boot.img so I can investigate the problem a little deeper.
[HTC One SV] MgudFrn:
Having trouble uploading file here from phone.

And Ya I tried via SD card sorry :p while I try via /data/local/tmp/ it says thats not an android boot image.. Buh will try it again...

Thanks

EDIT: Oh no its showing same message again...
[HTC One SV] :
If it is saying that it is not an android boot image, then it is most likely due to a signature which is found before the android header. To confirm this, you will need to look at the boot.img via a hex editor. I have an example of this procedure at the beginning of my guide. The android header must be the first thing that is read from the unmkbootimg binary or else it will fail. You will have to remove that signature yourself by using a simple dd command (which I doubt you know how to apply), or by using a hex editor and deleting it, then saving it. Afterwards, you can proceed with unpacking, editing, and repacking your boot.img.
[HTC One SV] dreccon:
Hi, I'm trying to modify the boot.img of CM10 for the LG p920 but i get the response that this is not an android boot image. Opened the file with a hex editor but the ANDROID! header was nowhere to be found. Instead, at offset HEX20, I can see: CM-10.0.0-p920-Multiboot. Also, unpacking this boot.img with another tool on Windows, it had a page size of 72! Is this totally non-standard or what?

EDIT:

Here it is if you want to take a look.

Sent from the 3rd dimension!
[HTC One SV] :
Can you send me the boot.img?
[HTC One SV] dreccon:
Yep, I edited my post above but you beat me to it!

Sent from the 3rd dimension!
[HTC One SV] :
Hey man, well for one, it definitely is not a standard boot.img. So my binaries will not work for this.

I figured maybe it was an actual kernel.elf file, which basically just means to rename it to kernel.elf in order to unpack it. I tried using the kernel kitchen but with no success. Even tried renaming it to kernel.sin (just in case), but to no prevail. I want to say that it is a kernel.elf file and not a "boot.img". I believe it to be that, because of the small size of bytes prior to the cm heading, and also due to the multiple trails of ELF found throughout the file when viewing it via a hex editor. An ordinary aosp binary concept won't work for you. This thing takes a completely different procedure in order to be worked on bro. Wish I could point you in the right direction, but that image file I have very little experience with. I would presume that the kernel kitchen may be useful and it is possible I didn't give it the proper permissions when using it on my linux system (which could explain it failing me), or it simply requires a completely different guideline.
[HTC One SV] :
[MENTION=2863096]dreccon[/MENTION], if you do by any chance figure it out... It would be greatly appreciated if you sent me a pm with all the info on it.
[HTC One SV] dreccon:
All I can say is that I can unpack it using this tool but then I can't repack if because of the non-standard page size, so I have to use this dual-boot-tool.

Sent from the 3rd dimension!
[HTC One SV] :
Yea, makes sense. The dual-boot.... That allows the ability to run a "rom" via an sdcard rather than straight from the boot partition, right? I have read up on that here and there, but never actually owned anything that required it so haven't really messed around in that area yet. Would explain the size though lol.
[HTC One SV] dreccon:
That's right but the boot.img I sent you is the unmodified P920 CM10 one which is not intended for dual boot!

On my HTC Evo 3D, based on your work, I have managed to write a script that takes an original ROM.zip, unpacks it, modifies the updater-script so that it installs onto the SD card and also modifies a file in the RAM disk, then packs everything back to a dual.boot.img. This way, CM nightlies can be modified on the fly and flashed as secondary ROMs without using a PC. It actually works very well and I was hoping I could build the same automation for the LG P920. Dual boot works fine for the latter but it's a pain to create a working dual.boot.img for every CM nightly.

BTW, dual boot is not "required" for anything. It's just extremely useful if you are a flashaholic like me! You can always keep a ROM that works well for you (usually stock) on your internal partitions and at the same time try all kinds of beta ones that look interesting off the SD card. Switching between the two takes only half a second longer than a simple reboot!

Sent from the 3rd dimension!
[HTC One SV] :
Hmmm, well, that would be interesting since it would help to jump from one Rom to the next when running tests. I been having to wipe my device between each flash which is annoying when having to log back in to all of your accounts over, and over, and over, and over again lol.

Only problem, is that I do not own a decent sdcard at the moment. The current 8gig that I have is practically full with dev work and music. And I have no intentions on wiping any of them out haha.

Though, I could probably get my hands on another pretty easily, so I would definitely be interested on how to partition the sdcard properly and as well as creating a dual-boot, I guess you would call it.

No one has really ever done something like this with a K2 variant (HTC One SV) that I am aware of. So this could be something to bring over and later down the road very useful.
[HTC One SV] dreccon:
Well, I don't know the specifics of your device but you definitely need an unlocked bootloader and S-Off. Then you need to figure out the sizes of your system, data and cache partitions (you can use "Partition Table" from the Play Store). Create three additional partitions at the end of your SD card with the sizes you found. You can either use AParted on your phone or MiniTool and a card adapter on your PC . The partitions must be all primary and formatted to ext3 or ext4 depending on what your kernel supports. Then you have to unzip the ROM file you want to install, find the updater-script and edit all lines that contain mmcblk0px (where x is your system partition number) to mmcblk1p2 (your SD system partition). You also need to unpack the boot.img, find the fstab.nick in the ramdisk (nick is the nickname of your device) and edit the sysyem, data and cache mountpoints to /dev/block/mmcblk1p2, 3 and 4 accordingly. Pack and zip everything back and reboot to recovery (if you need to flash GApps, then you must also modify that zip first). Make a backup of your current ROM and flash your modified zip(s). When you reboot, your device should load your secondary ROM. To switch back to the primary you need to reflash your primary kernel (from the backup you took). Use dd if=path/backup.boot.img of=/dev/block/mmcblk0px (where x is your boot partition) and reboot. To boot back to your secondary ROM, just use the above command to flash the boot.img extracted from your modified ROM.zip.

This should theoretically work on any device with any ROM as primary and a Jellybean or above ROM as secondary. All I have done is to automate the editing of zips so that they can be directly flashed.

PS: Sorry for the long off-topic but it is directly related to your work.

Sent from the 3rd dimension!
[HTC One SV] MgudFrn:
I followed all the procedure but I get same error:

gunzip: invalid magic

I'm having trouble attaching files from phone so could you get my boot.img from here
[HTC One SV] :
I'm getting the same error also. Will look in to it. Meanwhile, are are you positive that this boot.img isn't corrupted?
[HTC One SV] :
No, its fine bro. I believe your instructions on this thing came out much more clearer and less confusing than from those I have read up on lol. I appreciate it. Will be planning to give this a go just as soon as I get another sdcard in my hand.

And of course I am S-Off ;) wouldn't have it any other way lol.
[HTC One SV] MgudFrn:
Yes, I pulled it out via Terminal Emulator. I dont think its currupted.
[HTC One SV] :
What device did this boot.img come from?
[HTC One SV] MgudFrn:
Karbonn A1 Star. (MT6575)
[HTC One SV] :
Well, that answers my question then lol. There is another version which works best for devices like yours. I will need to compile the source for ARM, but I haven't gotten around to do it. Was going to make the binary initially when I made these three, but I decided against because at that time I had felt there wouldn't be enough people out there who would really need it. Guess I should add that to my list. Well, until I do, my current binaries will not really work for you as of right now. Sorry for the inconvenience.
[HTC One SV] MgudFrn:
Okay!! I don't think there's any other method to unpack boot.img without pc ?? Should go with PC now :D

Anyways Thanks for helping till now.
[HTC One SV] :
[MENTION=5492579]MgudFrn[/MENTION]

Take a look here

Its open source regarding the dsixda kitchen. You will notice a lot of source files. Some pertain specifically to devices such as the one your boot.img came from. Those specific files, I left out when compiling my binaries. Unless I include those sources, my compiled binaries provided in the op will not work for you. If I get some free time down the road, I will try to include those source files so boot.imgs like the one you have, can be properly worked on without the need of a pc.
[HTC One SV] MgudFrn:
Okay Thank You :)
[HTC One SV] dreccon:
Hi again, I recently opened a new thread that explains Dual-Boot in more detail. I believe you'll find it interesting.

Sent from the 3rd dimension!
[HTC One SV] :
Hey bro, will be adding my binaries to my github hopefully soon. From there I will be conducting a LOT of changes. Will post link when I get it all staged on my repo 'which I still have to create'. Been busy in real life.
[HTC One SV] :
[MENTION=2863096]dreccon[/MENTION]

boot_manipulation github repo

Have created it, but still got to stage the source later on.
[HTC One SV] :
Link to source has been added to Op. Currently no Makefile at the moment.
[HTC One SV] :
Makefile added to source. Will be last post from here given my source. All updates can be seen from the repo via commits. See Op for source link.
[HTC One SV] :
Currently trying to make a Multi-Call binary. This will allow me to bring in more support across a vast variety of devices. Currently have the Main C file done up for this, but having issues trying to compile it on my device properly. Would work from a computer I'm sure, but won't be satisfied unless I get it to compile straight from my phone as well.

As for this 'Multi-Call' binary I am working on. Think of how Busybox works. It takes multiple C files or executables but places it under one binary. So instead of having two, three or more, you only have one and at which you just make use of its usage calls and it will them call on the needed executable to handle your request so your needs may be fulfilled with success. :)

Will probably create a Branch from the Master repo so I can push this to my github so people can follow along with it, and maybe assist if they can.

This little project has currently held me up from my other work's like porting TWRP themes for example.
[HTC One SV] :
I have created another branch off of the original repo found in the OP. Files have been pushed to that tree. I am stopping all projects until I successfully take all those .c and .h files and compile them in to one simple binary. I won't be pushing any commits to that tree. It is only there for those who wish to work on it also. The tree is merely a test subject to help show how the process is done so that I may take away from it more knowledge and thus continuing to improve the available sources seen in the OP attachment.

This is top priority for me right now.

If you want to help, have at it.

The current tools I am using on my device are CCTools and c4droid.
[HTC One SV] :
https://github.com/ModdingMyMind/boot_manipulation

The source has been updated to allow static compiling. Been meaning to update the repo for sometime. Finally did lol.

A reminder though that the binaries do not support DTB and all that other crazy stuff popping up with android on the newer version's. I can easily add support but since I do not need them I don't plan to for right now.
[HTC One SV] :
Fixed up the Makefile in my repo to compile sources using -O3 optimizations. Compiling with this flag will greatly increase the size on the finish build but it will also GREATLY increase the performance when using it on your android device.

The OP is not updated with these builds. The OP currently uses dynamic compiled binaries.

If you wish to compile them yourself then grab my repo and have at it.

[MENTION=5246389]aureljared[/MENTION], I am mentioning you for our last contact a while back. The source has a makefile now if this is important to you.
[HTC One SV] :
To some if any, this may be relevant. However, I managed to compile mkbootimg, unmkbootimg, and mkbootfs as one binary. Using -O3 optimizations the binary came out to a size of just over 400kb, but when stripped it was reduced down to just over 140kb. Nevertheless, I was successful getting it to work. Main.c gave me problems even though the file being implemented is a simple one. The idea is similar to busybox. Just like busybox is a multi call binary, so is the idea of combining the three into one.
[HTC One SV] :
I have managed to reduce it down to about 104kb all together, even after adding mkbootimg_mk65xx. :). Tested symlinking them too, and it works. Now I can finally combine what I want and not have binaries all over the place on my phone :P
[HTC One SV] Md.Shafikul.islam:
faceing problem :(

bro i have a problem with ramdisk.cpio.gz . :(

i cant extract it.please explain me how to extract it.
[HTC One SV] :
Is your device a MT65**?
[HTC One SV] :
I have to compile from source what it is that you need.
[HTC One SV] Md.Shafikul.islam:
Thanks bro.

but i dont understand. :(

i am new users.

can you please explain me and give me a batter solution?

thanks.
[HTC One SV] :
Your ramdisk isn't compressed as gz, but instead it is compressed as lz4. My instructions are based on boot.imgs which have a ramdisk compressed as gz. For you this will not work. A different method is required. In addition, it will require that you use a mkbootimg binary which is written for mt65** devices so that the final boot.img is built properly which I will need to build this for you from source.
[HTC One SV] Md.Shafikul.islam:
Hmm understood.

then please build the mkbootimg for me.. :)

please bro.....
[HTC One SV] :
Here you go. It's a multi call binary. It comes with mkbootimg, mkbootimg_mt65xx, unmkbootimg, and mkbootfs. To use the binary here is an example:

bm unmkbootimg -i boot.img

The concept is similiar to busybox ;). You can also symlink these to bm if you are too lazy to type bm everytime haha.

I don't have a device to test mkbootimg_mt65xx so please report back here and let me know.

You can review my commits from the two links below:

https://github.com/ModdingMyMind/boot_manipulation/commit/9f4fdb394a72bfd93598a95f2c57ee0a9add6988

https://github.com/ModdingMyMind/boot_manipulation/commit/38b0fb7b716879a4619c160e442705af2ded5d49
[HTC One SV] :
https://github.com/ModdingMyMind/boot_manipulation/commit/ff94bc2a9f1329246761a841262453593c4c26c4

Added lz4 to the source. Just run:

make multi

To build it.
[HTC One SV] Md.Shafikul.islam:
Thanks bro...

Thanks...bro...

but its still not working...

its showed:

code:

sh: cpio not found ..... :(

see my command.

code:

bm gunzip -c --/ramdisk.cpio.gz | cpio -i ....

What the problem :(
[HTC One SV] :
Try busybox cpio. If that doesn't work then you must install a busybox which has the cpio applet.
[HTC One SV] :
Also, bm gunzip is not an option. Don't type, bm gunzip. In addition, your ramdisk is not compressed as gz. So you need to decompress it via lz4.
[HTC One SV] :
The unmkbootimg.c source automatically names the ramdisk as .cpio.gz but you have an MT device. So your ramdisk is compressed differently.
[HTC One SV] :
Try this:

lz4 -d ../ramdisk.gz ../ramdisk.cpio

Then,

cpio -i -d -m --no-absolute-filenames 2>/dev/null < ../ramdisk.cpio
[HTC One SV] :
Added support for the following:

- dt support for bootimg.h mkbootimg.c and unmkbootimg.c

- Added dtbtool and dtc sources

- Added getline and getdelim sources to accommodate the usage of getline within dtbtool.c

- Modified main and usage in some source files to prevent confliction upon compiling

- Updated main.c and makefile to accommodate these changes for a successful multi call binary compilation

https://github.com/ModdingMyMind/boot_manipulation/commit/0ce22339a889e701a40c78a60d9e2958330b468d
[HTC One SV] :
The OP attachment is not updated with any of the above changes. You must build it from source if you wish to make use of them. I can assist if need be.
[HTC One SV] :
The resource is currently stable. It will remain stable from here on out.
[HTC One SV] :
https://github.com/ModdingMyMind/boot_manipulation/commit/9027f81e4bca2853c77475a658966e19b1216f4b
[HTC One SV] :
https://github.com/ModdingMyMind/boot_manipulation/commit/a9db78abdf006d6e35d9a7f9c8a47d8c50db9e3b

Fixed the kernel commandline from unmkbootimg.c. If any of you built the multi call binary recently, I recommend rebuilding. This fix was rather important even though it was a small fix.
[HTC One SV] robcodemax:
I have an Android phone IBall 4.7G Cobalt which does not have any recoveries available...can I use the boot.img file I got using the first command and make recovery out of it or do I have to complete the entire step and then make a recovery out of that
[HTC One SV] :
You won't be able to manipulate the boot.img in to thinking it is a recovery. If you need a recovery for your device your best bet is to build a recovery from source using a device tree that is wrapped around your device. If there is no device tree available then find a device that closely resembles your device as much as possible and modify the tree.

With that said, check inside your boot.img and see if the recovery is inside your boot. Devices without a recovery partition will have the recovery merged inside the boot.img.
[HTC One SV] robcodemax:
SOLVED
[HTC One SV] :
https://github.com/ModdingMyMind/mkbootimg_tools/tree/master/ARM
[HTC One SV] bigsupersquid:
I put a thanks for this in two places.

I really appreciate it. The lzma arm binary is especially nice since I didn't already have one and busybox only decompresses lzma.

I am going to test it on a dell streak 7 boot.img which needs the kernel replaced. I don't have one myself to test the resulting boot.img on but I have someone wanting a kernel with new config who can. The kernel should be fine, same source as original just with debugging turned on.

I haven't wanted to try a fourth time to recombine the boot.img with other tools, but this one is very promising.

That device has a nasty little boot.img format, which I can post a link to the "dd this padding and hexedit in the new offset values here" type instructions in an thread for it... if this won't just work out of the box.