如何从U-Boot在eMMC上复制4个分区的图像?

问题描述 投票:0回答:1

我有一个图像(对于熟悉Yocto框架的人来说,更确切地说是wic图像),其中包含一个分区表及其4个分区。它的大小不到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
u-boot
1个回答
0
投票

[我认为,当您写入包含一个或多个分区的映像时,也会同时写入分区表,该分区表预期通过u-boot处于一定偏移量或内存中(根据this post,它可能是0x60000000) 。因此,如果您在其他位置再次写入映像,则u-boot将引用您第一次写入操作中的分区表,而该操作本身仅涉及前4个分区。您的第二个分区表在磁盘上的其他位置,但是u-boot不在乎/不知道。

您可以尝试从第一次写入操作开始rebuild/repair the partition table。希望它将扫描整个磁盘并发现总共有8个分区,中间有一个奇怪的分区表将被忽略。

sudo testdisk

然后按照流程进行。

© www.soinside.com 2019 - 2024. All rights reserved.