芯路恒电子技术论坛

 找回密码
 立即注册
热搜: 合集
查看: 5657|回复: 0

【SOC FPGA】在Ubuntu下修改img文件中的内容

[复制链接]
  • TA的每日心情
    慵懒
    2021-2-24 10:16
  • 423

    主题

    782

    帖子

    1万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    积分
    15854
    QQ
    发表于 2020-12-4 18:37:20 | 显示全部楼层 |阅读模式
    1、将img文件拷贝到Ubuntu下,例如img文件名为  AC540-SoC-Console.img,拷贝的路径为 /home/fpgaer/tools/
    2、使用fdisk命令查看img文件的分区  fdisk  AC540-SoC-Console.img
    3、输入p来查看分区信息:

    root@ubuntu:/home/fpgaer/tools# fdisk  AC540-SoC-Console.img
    Welcome to fdisk (util-linux 2.27.1).
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.


    Command (m for help): p
    Disk AC540-SoC-Console.img: 1.9 GiB, 2002780160 bytes, 3911680 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0xd68e23ba

    Device                 Boot   Start     End Sectors   Size Id Type
    AC540-SoC-Console.img1      2121728 3799447 1677720 819.2M  b W95 FAT32
    AC540-SoC-Console.img2        14336 2111487 2097152     1G 83 Linux
    AC540-SoC-Console.img3         2048    4095    2048     1M a2 unknown

    Partition table entries are not in disk order.

    Command (m for help):


    假如修改第一分区,也就是FAT32分区中的内容,则需要先挂载该分区,挂载的offset是其起始地址,用start块*512就是2121728*512=1086324736

    3、挂载FAT32分区。
    mount -o loop,offset=1086324736 AC540-SoC-Console.img      /mnt/


    4、在mnt下去修改里面的内容,

    使用fdisk  AC540-SoC-Console.img 再次管理该文件,
    输入w来讲刚刚的修改写入该img文件。


    完成




    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|小黑屋|Archiver|芯路恒电子技术论坛 |鄂ICP备2021003648号

    GMT+8, 2024-4-24 00:19 , Processed in 0.106130 second(s), 32 queries .

    Powered by Discuz! X3.4

    © 2001-2017 Comsenz Inc. Template By 【未来科技】【 www.wekei.cn 】

    快速回复 返回顶部 返回列表