How to use *.zip to change the boot/ devtree/ recovery

dlhxr

Senior Member
May 26, 2011
516
500
93
New York City
I have written a updater-script to do this, but I am not sure whether it works. Can anybody give me some suggestion?
Code:
ui_print("Changing Moto Rom");
ui_print("Updating boot");
show_progress(0.330000,2);
assert(package_extract_file("boot.img", "/tmp/boot.img"),
       write_raw_image("/tmp/boot.img", "/dev/block/mmcblk1p15"),
       delete("/tmp/boot.img"));

ui_print("Updating devtree");
show_progress(0.330000,2);
assert(package_extract_file("devtree.img", "/tmp/devtree.img"),
       write_raw_image("/tmp/devtree.img", "/dev/block/mmcblk1p12"),
       delete("/tmp/devtree.img"));

ui_print("Updating stock recovery");
show_progress(0.340000,2);
assert(package_extract_file("recovery.img", "/tmp/recovery.img"),
       write_raw_image("/tmp/recovery.img", "/dev/block/mmcblk1p16"),
       delete("/tmp/recovery.img"));
ui_print("Changed");
And are the three img files generated only by change names of CG35.smg/ CG61.smg/ CG47.smg?

After we extract the smg files from a sbf file, we have many CG??.smg.
CG35.smg refers to the partition of boot.
CG61.smg refers to the partition of devtree.
CG47.smg refers to the partition of recovery.
Now I have two problems.
1. Does the boot&devtree&recovery in zip file have the same format as CG35&CG61&CG47? Such as the yaffs or ext?
2. Shall we use the code above to replace the partitions successfully considering the not-open bootloader and the secure signature?
 
Last edited:
  • Like
Reactions: iaio72

Febernacke

Senior Member
Nov 22, 2010
63
8
0
CG35.smg and CG47.smg are different. CG47 is Recovery and contains recovery software does not boot system, CG35 is boot and does not have ny recovery stuff only boots the system.

But I don't know anything about devtree and devtree_backup. but the name indicate that devtree_backup is a exact copy of devtree.


EDIT: CG35 and CG47 have different SHA1 hash and different signatures when extracted from the same (original) SBF file. if CG47 would have been a copy of CG35 the SHA1 hash would have been the same.
 
Last edited:

dlhxr

Senior Member
May 26, 2011
516
500
93
New York City
CG35.smg and CG47.smg are different. CG47 is Recovery and contains recovery software does not boot system, CG35 is boot and does not have ny recovery stuff only boots the system.

But I don't know anything about devtree and devtree_backup. but the name indicate that devtree_backup is a exact copy of devtree.


EDIT: CG35 and CG47 have different SHA1 hash and different signatures when extracted from the same (original) SBF file. if CG47 would have been a copy of CG35 the SHA1 hash would have been the same.
I am afraid you misunderstood me. I know that CG35 and CG47 are different.
After we extract the smg files from a sbf file, we have many CG??.smg.
CG35.smg refers to the partition of boot.
CG61.smg refers to the partition of devtree.
CG47.smg refers to the partition of recovery.
Now I have two problems.
1. Does the boot&devtree&recovery in zip file have the same format as CG35&CG61&CG47? Such as the yaffs or ext?
2. Shall we use the code above to replace the partitions successfully considering the not-open bootloader and the secure signature?
 

nullness

Senior Member
Jan 14, 2009
69
17
0
Just a warning guys, those CGXX.smg files are not the same as the .img files. SBF files pad the partitions with nulls so they reach multiples of 1024 bytes. The image files themselves can be extracted from the .smg files by removing the extra padding nulls from the end. Hex editors are your friend.