固件挂载

在linux的PC上挂载jffs2根文件系统映像
因为jffs2是构建于MTD设备上的文件系统,所以无法通过loop设备来挂载,但是可以通过mtdram设备来挂载。mtdram是在用RAM实现的MTD设备,可以通过mtdblock设备来访问。使用mtdram设备很简单,只要加载mtdram和mtdblock两个内核模块即可。这两个内核模块一般的linux内核发行版都有编译好的,直接用modprobe命令加载。
下面是具体步骤:
(1).加载mtdblock内核模块
modprobe mtdblock
(2).加载mtdram内核模块,将该设备的大小指定为jffs2根文件系统映像的大小,块擦除大小(即flash的块大小)指定为制作该jffs2根文件系统时“-e”参数指定的大小,缺省为64KB。下面两个参数的单位都是KB。
modprobe mtdram total_size=5120 erase_size=256

(3).这时将出现MTD设备/dev/mtdblock0,使用dd命令将jffs2根文件系统拷贝到/dev/mtdblock0设备中。
dd if=jffs2.img of=/dev/mtdblock0
(4).将保存了jffs2根文件系统的MTD设备挂载到指定的目录上。
mount -t jffs2 /dev/mtdblock0 /mnt/mtd

root@gpl-vm:/gplt/PX-4854/fw/rootfs# hexdump -C rootfs|more
00000000  73 68 73 71 8f 03 00 00  00 00 00 74 8f 0d 05 00  |shsq.......t....|
00000010  00 00 00 00 00 00 00 00  78 5a fe d4 03 00 00 00  |........xZ......|

So,  ‘shsq’ is one of those other variants,   according to Armijn Hemel ever suggested,   change ‘shsq’ to ‘hsqs’ (it is little endian).   Then try again.

root@gpl-vm:/gplt/PX-4854/fw/rootfs# unsquashfs rootfschanged
Parallel unsquashfs: Using 1 processor
gzip uncompress failed with error code -3
read_block: failed to read block @0x4997ff
read_fragment_table: failed to read fragment table block
FATAL ERROR aborting: failed to read fragment table

This is the second issue we encounter,   I guess it was caused by incompatible unsquashfs.   Let’s check the version of unsquashfs.

root@gpl-vm:/gplt/PX-4854/fw/rootfs# unsquashfs -v
unsquashfs version 4.2 (2011/02/28)


Finally,  try other version of unsquashfs,  there are lots of unsquashfs provide by BAT.  
root@gpl-vm:/gplt/PX-4854/fw/rootfs# bat-unsquashfs
bat-unsquashfs42           bat-unsquashfs-atheros2    bat-unsquashfs-broadcom    bat-unsquashfs-ddwrt       bat-unsquashfs-ralink      
bat-unsquashfs-atheros     bat-unsquashfs-atheros40   bat-unsquashfs-broadcom40  bat-unsquashfs-openwrt     bat-unsquashfs-realtek

after tried some of them,    bat-unsquashfs-broadcom40 extracted the rootfs successfully.


CPIO

 cpio -id --no-absolute-filenames < output~



http://forum.xda-developers.com/galaxy-s2/general/ref-unpacking-repacking-stock-rom-img-t1081239

[REF] Unpacking and repacking stock rom .img files

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值