美文网首页
mtd 追加配置文件失败

mtd 追加配置文件失败

作者: 鱼大鱼 | 来源:发表于2018-12-24 19:36 被阅读0次
    Usage: mtd [<options> ...] <command> [<arguments> ...] <device>[:<device>...]
    
    The device is in the format of mtdX (eg: mtd4) or its label.
    mtd recognizes these commands:
            unlock                  unlock the device
            refresh                 refresh mtd partition
            erase                   erase all data on device
            verify <imagefile>|-    verify <imagefile> (use - for stdin) to device
            write <imagefile>|-     write <imagefile> (use - for stdin) to device
            jffs2write <file>       append <file> to the jffs2 partition on the device
            fixseama                fix the checksum in a seama header on first boot
    Following options are available:
            -q                      quiet mode (once: no [w] on writing,
                                               twice: no status messages)
            -n                      write without first erasing the blocks
            -r                      reboot after successful command
            -f                      force write without trx checks
            -e <device>             erase <device> before executing the command
            -d <name>               directory for jffs2write, defaults to "tmp"
            -j <name>               integrate <file> into jffs2 data when writing an image
            -s <number>             skip the first n bytes when appending data to the jffs2 partiton, defaults to "0"
            -p                      write beginning at partition offset
            -l <length>             the length of data that we want to dump
    
    Example: To write linux.trx to mtd4 labeled as linux and reboot afterwards
             mtd -r write linux.trx linux
    

    mtd工具可以使用-j 参数,使在更新的固件里带上某些文件,一般是配置文件,用法如下参考

    mtd -r -j /tmp/sysupgrade.tgz write /tmp/LW1102-2.0.18.7.bin "firmware" 
    

    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: 007b0000 00010000 "firmware"
    mtd4: 001171fe 00010000 "kernel"
    mtd5: 00698e02 00010000 "rootfs"
    mtd6: 000f0000 00010000 "rootfs_data"
    root@OpenWrt:~# cat /proc/partitions 
    major minor  #blocks  name
    
      31        0        192 mtdblock0
      31        1         64 mtdblock1
      31        2         64 mtdblock2
      31        3       7872 mtdblock3
      31        4       1116 mtdblock4
      31        5       6755 mtdblock5
      31        6        960 mtdblock6
    

    上述命令含义为,将/tmp/LW1102-2.0.18.7.bin 固件与/tmp/sysupgrade.tgz一起烧写进入 firmware分区中,之后重启。但是重启之后,mips设备上却没有该文件。目前准备尝试使用jffs2write 尝试看看是否可以将文件传入新固件中,从而获得之前的配置文件。

    相关文章

      网友评论

          本文标题:mtd 追加配置文件失败

          本文链接:https://www.haomeiwen.com/subject/khftlqtx.html