原文连接:
关注订阅号实时查看 制作编程器固件(以7620为例) 说明 编程器固件依据flash大小而定,一般是8M和16M。 步骤 1、 确定分区 路由器上看mtd分区,命令cat /proc/mtd root@openwrt:/# cat /proc/mtd dev: size erasesize name mtd0: 00030000 00010000"u-boot" mtd1: 00010000 00010000"u-boot-env" mtd2: 00010000 00010000"Factory" mtd3: 00140000 00010000 "kernel" mtd4: 00e70000 00010000 "rootfs" mtd5: 00890000 00010000"rootfs_data" mtd6: 00fb0000 00010000"firmware" mtd7: 01000000 00010000"fullflash" 另外用logread命令可以看出来flash的大小和每个分区的起始结束点 [ 0.520000] deice id : ef 40 18 0 0 (40180000) [ 0.528000] W25Q128BV(ef 40180000) (16384 Kbytes)----这个大小就是flash大小 [ 0.536000] mtd .name = raspi, .size = 0x01000000 (0M) .erasesize =0x00000010 (0K) .numeraseregions = 65536 [ 0.564000] Squashfs filesystem found at offset 0x190000,adjustment mtdpartition. [ 0.580000] Creating 7 MTD partitions on "raspi": [ 0.588000] 0x000000000000-0x000000030000 : "u-boot" [ 0.600000] 0x000000030000-0x000000040000 : "u-boot-env" [ 0.612000] 0x000000040000-0x000000050000 : "Factory" [ 0.624000] 0x000000050000-0x000000190000 : "kernel" [ 0.636000] 0x000000190000-0x000001000000 : "rootfs" [ 0.648000] mtd: partition "rootfs" set to be root filesystem [ 0.660000] mtd: partition "rootfs_data" created automatically,ofs=770000, len=890000 [ 0.676000] 0x000000770000-0x000001000000 : "rootfs_data" [ 0.688000] 0x000000050000-0x000001000000 : "firmware" [ 0.700000] 0x000000000000-0x000001000000 : "fullflash" 从上面的信息可以看出每个分区所占用的flash空间范围。 对7620来说我们需要的分区就是上面红色字体的几个。 2、获取每个分区数据 获取uboot、uboot-env,Factory分区 root@openwrt:/# dd if=/dev/mtd0of=/tmp/uboot.bin 384+0 records in 384+0 records out root@openwrt:/# root@openwrt:/# dd if=/dev/mtd1of=/tmp/uboot-env.bin 128+0 records in 128+0 records out root@openwrt:/# dd if=/dev/mtd2of=/tmp/Factory.bin 128+0 records in 128+0 records out 获取firmware分区的方法 这个有两个方法,一个直接使用openwrt编译出来squashfs-factory.bin,注意是factory的固件,不是squashfs-sysupgrade.bin,这种方法需要给不满firmware分区长度的部分补0,让他的长度达到firmware分区的大小。 另一个就是先把factory或者sysupgrade的固件传到路由器上,mtd写进去,在用dd读出来,注意在读取之前不能重启,保证新写进去的固件是没有被启动过的 root@openwrt:~# mtd write/tmp/xxx-squashfs-sysupgrade.bin firmware 这样将固件写入到firmware分区,在用dd命令读取出来firmware数据 root@openwrt:~# dd if=/dev/mtd6 of=/tmp/firmware.bin 32128+0 records in 32128+0 records out root@openwrt:~# 所有分区的数据都得到了,下面该合并了。 3、 合并分区得到编程器固件 用winscp将路由器中的文件复制到电脑上(需要路由器固件支持ssh,scp) 合并用到的软件是winhex 我的方法是分别复制uboot-env.bin,factory.bin,firmware.bin的数据到uboot的下面粘贴,这样就ok了! 注意一定要看清楚每个分区的顺序
|