长虹55D3P (海思平台)kernel分区解包ramdisk重新打包

一、背景

长虹电视部分海思平台并没有boot分区,使用的不是Android标准的boot.img。使用的是kernel分区,无法使用网上的boot解包工具解包打包。

二、kernel分区文件分析

WinHex打开kernel image,可以看到开头是常规的kernel image header。0x644d5241是kernel的Magic number,kernel text offset=0x80000,image size=0x1723000。注意到此处的image size是大于kernel文件大小的。对比了其他的纯内核image,header也是大于生成文件大小的。可能与对齐有关。

一般ramdisk是cpio.gz格式,文件头是0x1F8B08。搜索这个16进制数,此处可能就是ramdisk的起始地址。

三、分割image,解包

我是在Ubuntu下操作的,Windows也可以使用其他工具将从1F8B0800内容开始分割成两段。前面一部分就是kernel,后一部分就是ramdisk。

mkdir kernel_ramdisk
cd kernel_ramdisk
gzip -d -c ../kernel_ramdisk.cpio.gz | cpio -i -d -m

成功解压出ramdisk。

修改ramdisk...

重新打包ramdisk

./mkbootimg_tools/mkbootfs kernel_ramdisk/ | gzip -n -f > new_kernel_ramdisk

重新打包后发现新的ramdisk比原来的小了很多,原因是我们分隔出来的ramdisk尾部包含了很多垃圾数据,并不属于ramdisk的内容,当解压为cpio时,这些数据就已丢弃,重新打包也不会再包含这些数据。暂不清楚这些数据是否有实际的意义,只能看重新打包固件后能否开机来验证了。 

注:ramdisk解包打包可以借助原来的boot解包工具,里面包含了ramdisk解包打包的工具和指令。

四、重新打包kernel+ramdisk 

提取出kernel,18523632就是0x11AA5F0

dd if=78M_30M-kernel bs=1 count=18523632 of=kernel

 制作一个空文件,大小30M(大于kernel+ramdisk之和小于分区大小)

dd if=/dev/zero of=new_kernel bs=1M count=30

合并kernel和新的ramdisk

dd if=kernel of=new_kernel conv=notrunc
dd if=new_kernel_ramdisk.cpio.gz of=new_kernel bs=1 seek=18523632 conv=notrunc

五、刷机验证

待验证

如果无法开机,可能ramdisk后面的数据也是有用的,可以打包时仅替换ramdisk试试

dd if=new_kernel_ramdisk.cpio.gz of=78M_30M-kernel bs=1 seek=18523632 conv=notrunc

注意:18523632要根据你的固件包ramdisk位置做调整,每个包都不一样。recovery分区和kernel分区解包打包方法一样。

非常威猛的官方固件UPDATE.APP解包打包工具(转自XDA论坛) Huawei Update Extractor After messing around a bit with the perl tools available for extracting Huawei update.app files, i got the idea to create an own (windows) tool. Requirements .Net Framework 3.5 Install Extract the content of the zip to a folder somewhere on your system. Execute HuaweiUpdateExtractor.exe I'm planning to create an installer sometime. Usage Press the browse (...) button and select an update.app file. Select a device or unknown and press on the open button. You'll see the content of the update.app file in the listview. Select one or more files and right click. Choose Extract selected from the context menu. Choose the ouput folder and press ok. Or just right click on the list and select Extract all, choose the output folder again and press ok. Press close on the extract window. You can sort the list on sequence, filename and size. Just press on the desired column header. Command line: HuaweiUpdateExtractor extract input output [profile] HuaweiUpdateExtractor repack input output profile Profile The profiles.xml file is used to identify the files in the update.app file. Every file in the update.app has a sequence or type, which is also shown in the list. Those sequences or types are used to identify the file/device partition. Example: system.img recovery.img baseband.img version.txt splash.raw565 boot.img cust.img userdata.img signature crc system.img cache.img cust.img userdata.img modemimage.img boot.img recovery.img signature crc - Root tag of the xml file. - Identifies a device - attribute name: name of the device - attribute author: author of the device - File root tag - Identifies a file - attribute sequence: sequence of the file in update.app - attribute type: type of the file in the update.app - attribute partition: destination partition on the device - attribute signature: used to identify the signature file - attribute checksum: used to identify the checksum file - value: file name You can add or edit devices. If you want them to integrate in newer version, pm 'em to me. I'm gonna make some auto update for the device file somewhere in the future Roadmap - You tell me ... Credits ZeBadger (zebadger@hotmail.com) for figuring out the file headers S34Qu4K3 for the P6 partition layout ngamyarthar for adding ALOT of devices! Changelog
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Free飝Fly

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值