请各位大神指导一下,我的openwrt系统启动以后打印出如下分区信息:
[ 0.760000] Creating 4 MTD partitions on "spi32766.0":
[ 0.770000] 0x000000000000-0x000000030000 : "u-boot"
[ 0.780000] 0x000000030000-0x000000040000 : "u-boot-env"
[ 0.800000] 0x000000040000-0x000000050000 : "factory"
[ 0.810000] 0x000000050000-0x000002000000 : "firmware"
[ 1.060000] 2 uimage-fw partitions found on MTD device firmware
[ 1.070000] 0x000000050000-0x00000016835d : "kernel"
[ 1.080000] 0x00000016835d-0x000002000000 : "rootfs"
[ 1.090000] mtd: device 5 (rootfs) set to be root filesystem
我怎么才能知道每一个分区中的具体内容在什么地方啊?比如说"factory"分区中的内容应该在哪查看呢?如果我要自定义一下内容加入"factory"分区,该怎么操作呢?
离线
我说的是源码中的位置
离线
我想要在"factory"分区内写入我自定义用途的id 我在openwrt做了如下操作:
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: 01fb0000 00010000 "firmware"
mtd4: 0011835d 00010000 "kernel"
mtd5: 01e97ca3 00010000 "rootfs"
mtd6: 01a00000 00010000 "rootfs_data"
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/# dd if=/dev/mtdblock2 of=/dev/factory
128+0 records in
128+0 records out
root@OpenWrt:/# hexdump -C /dev/factory
00000000 20 76 05 01 0c ef af c3 14 5c ff ff ff ff ff ff | v.......\......|
00000010 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000020 ff ff ff ff ff ff ff ff 0c ef af c3 14 5c 0c ef |.............\..|
00000030 af c3 14 5d 22 0c 00 00 ff ff 51 01 55 77 a8 aa |...]".....Q.Uw..|
00000040 8c 88 ff ff 0a 00 00 00 00 00 00 00 00 00 ff ff |................|
00000050 ff ff 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d |................|
00000060 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 80 ff |................|
00000070 ff ff 80 ff ff ff 00 00 ff ff ff ff ff ff ff ff |................|
00000080 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
*
000000d0 20 ff ff ff ff ff ff ff ff ff ff ff ff ff 08 08 | ...............|
000000e0 08 08 04 00 07 07 04 00 08 08 04 00 07 07 04 00 |................|
000000f0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
*
00010000
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/#
我是不是可以在00000080---000000d0或000000f0---00010000之间(*号部分)写入我的id呢?
离线
可以的, 但是flash写之前需要擦除, 如果用命令操作,步骤是这样的
1. 回读 /dev/mtdblock2 到文件 dd if=/dev/mtd2 of=f.bin
2. 修改文件f.bin, 加入id
3. 擦除/dev/mtdblock2 flash_eraseall /dev/mtd2
4. 写 /dev/mtdblock2 dd if=f.bin of=/dev/mtd2
5. 其实3,4步可以合并一起做 flashcp -v f.bin /dev/mtd2flash_eraseall, flashcp 都可以在busybox里面开启编译选项.
如果想自己整合, 那就去参考busybox的flash* 代码就好了。
哦哦!感谢指导!但是如果我想从新在 "factory"跟"firmware"增加一个分区呢?会有哪些步骤啊?难度大么?
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: 01fb0000 00010000 "firmware"
mtd4: 0011835d 00010000 "kernel"
mtd5: 01e97ca3 00010000 "rootfs"
mtd6: 01a00000 00010000 "rootfs_data"
离线
哦哦,谢谢啦
离线