0

我有一个包含分区表及其 4 个分区的图像(更具体地说是为熟悉 Yocto 框架的人提供的 wic 图像)。它的大小略小于 1GB。

为了将此图像写入 eMMC:

  • 我首先通过 TFTP 将它加载到 RAM
=> tftp 0x600000000 <image>.wic
  • 然后我将图像从 RAM 写入 eMMC
=> mmc write 0x600000000 0x0 0x1FFFFF
  • 图像写入正确,我可以列出 4 个分区。到目前为止,一切都很好。
=> mmc part

Partition Map for MMC device 1  --   Partition Type: EFI

Part    Start LBA       End LBA         Name
        Attributes
        Type GUID
        Partition GUID
  1     0x00000800      0x0000681f      "boot"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   cd5df8ce-ded3-4cf4-b364-33d7a4b24953
  2     0x00006820      0x000139e7      "first"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   3acc4557-2273-462a-a2bd-d130b3a5745d
  3     0x00014000      0x000fefff      "second"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   efe25a87-e0ba-401e-8bf6-e81ae29cbc35
  4     0x000ff000      0x001e9fff      "third"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   150f9151-7710-42f4-b819-3b3bd506a2bf

现在我想复制 eMMC 中的图像,这样我就得到了 8 个分区,如下所示:

Part    Start LBA       End LBA         Name
        Attributes
        Type GUID
        Partition GUID
  1     0x00000800      0x0000681f      "boot"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   cd5df8ce-ded3-4cf4-b364-33d7a4b24953
  2     0x00006820      0x000139e7      "first"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   3acc4557-2273-462a-a2bd-d130b3a5745d
  3     0x00014000      0x000fefff      "second"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   efe25a87-e0ba-401e-8bf6-e81ae29cbc35
  4     0x000ff000      0x001e9fff      "third"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   150f9151-7710-42f4-b819-3b3bd506a2bf
  5     0x00000800      0x0000681f      "boot"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   cd5df8ce-ded3-4cf4-b364-33d7a4b24953
  6     0x00006820      0x000139e7      "first"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   3acc4557-2273-462a-a2bd-d130b3a5745d
  7     0x00014000      0x000fefff      "second"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   efe25a87-e0ba-401e-8bf6-e81ae29cbc35
  8     0x000ff000      0x001e9fff      "third"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   150f9151-7710-42f4-b819-3b3bd506a2bf

所以我用偏移量再次将相同的图像写入 eMMC(不覆盖现有的图像)

=> mmc write 0x600000000 0x200000 0x3FFFFF

MMC write: dev # 1, block # 2097152, count 4194303 ... 4194303 blocks written: OK

但是,我没有得到我期望的 8 个分区,而只有 4 个分区:

=> mmc rescan
=> mmc part

Partition Map for MMC device 1  --   Partition Type: EFI

Part    Start LBA       End LBA         Name
        Attributes
        Type GUID
        Partition GUID
  1     0x00000800      0x0000681f      "boot"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   cd5df8ce-ded3-4cf4-b364-33d7a4b24953
  2     0x00006820      0x000139e7      "first"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   3acc4557-2273-462a-a2bd-d130b3a5745d
  3     0x00014000      0x000fefff      "second"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   efe25a87-e0ba-401e-8bf6-e81ae29cbc35
  4     0x000ff000      0x001e9fff      "third"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   150f9151-7710-42f4-b819-3b3bd506a2bf
4

1 回答 1

1

当您编写包含一个或多个分区的映像时,您还编写了分区表,该分区表预计会在某个偏移量或您的内存中通过 u-boot(根据这篇文章,它必须是 0x60000000)。因此,如果您在其他地方再次写入映像,u-boot 仍将引用您第一次写入操作的分区表,该表本身包含您前 4 个分区的内存地址。您的第二个分区表在磁盘上的其他位置,但 u-boot 不知道。

您可以尝试使用testdisk命令行实用程序修复分区表。它将扫描整个磁盘并希望它会发现总共有 8 个分区,并在 0x60000000 处创建一个新的分区表来引用所有这些分区。

于 2020-01-30T15:05:29.253 回答