我有一个基于Olinixino iMX233设计的嵌入式设备。它具有一个Freescale iMX233微处理器,并可以从2GB插槽的microSD卡引导。

为此,我获得了类似的2GB微型SD卡,并在USB卡读取器中使用dd克隆了当前的SD卡:

dd if=/dev/sdc of=HeatmiserSDC.img


然后交换卡后:

dd if=HeatmiserSDC.img of=/dev/sdc


将新卡放入设备后,无法启动。现在尝试使用sg3_utils实用程序sg_dd,该实用程序的运行级别略低。这样产生的映像文件略有不同,但仍然无法启动。

我现在还在Thinkpad x220的直接SD卡接口(/ dev / mmcblk0)中使用了SD到micro SD适配器。这也无法启动。

当串行控制台无法启动时,它会生成一个错误代码0x8020a007,这在Google搜索过程中没有太大用处。

我尝试了多种卡,包括一些4GB卡。这似乎不是空间问题,有时一张2GB SD卡要比另一张小。该板似乎也正在使用SD协议,而不是SPI协议。 SPI协议有时在较新的卡上不是很可靠。

fsutil -l产生以下输出:在这里不见了?某些不是作为dd的一部分复制的数据?

#1 楼

经过一番搜索,看来iMX233的启动过程是相当不标准的。默认情况下,它会在SD卡的最后一个块中查找“引导控制块”(BCB)。

检查原始SD卡,使用fdisk -l查找最后一个块:

Disk /dev/mmcblk0: 1996 MB, 1996488704 bytes
4 heads, 16 sectors/track, 60928 cylinders, total 3899392 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
Disk identifier: 0x0f6c2d46

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            2048       32000       14976+  53  OnTrack DM6 Aux3
/dev/mmcblk0p2           32001      200000       84000   83  Linux
/dev/mmcblk0p3          200001      400000      100000   83  Linux
/dev/mmcblk0p4          400001     3899391     1749695+  83  Linux


有3899392个扇区。

使用dd检查SD卡的最后一个扇区:

root@kali:~# dd if=/dev/mmcblk0 bs=512 count=1 skip=3899391 2> /dev/null | hexdump -C
00000000  33 22 11 00 01 00 00 00  04 00 00 00 04 00 00 00  |3"..............|
00000010  04 00 00 00 04 08 00 00  50 00 00 00 50 00 00 00  |........P...P...|
00000020  50 00 00 00 50 00 00 00  ef be ad de 00 00 00 00  |P...P...........|
00000030  01 00 00 00 02 00 00 00  03 00 00 00 04 00 00 00  |................|
00000040  05 00 00 00 06 00 00 00  07 00 00 00 08 00 00 00  |................|
00000050  09 00 00 00 0d 0a 00 00  00 0b 00 00 00 0c 00 00  |................|
00000060  00 0d 00 00 00 0e 00 00  00 0f 00 00 00 10 00 00  |................|
00000070  00 11 00 00 00 12 00 00  00 13 00 00 00 14 00 00  |................|
00000080  00 15 00 00 00 16 00 00  00 17 00 00 00 18 00 00  |................|
00000090  00 19 00 00 00 1a 00 00  00 1b 00 00 00 1c 00 00  |................|
000000a0  00 1d 00 00 00 1e 00 00  00 1f 00 00 00 20 00 00  |............. ..|
000000b0  00 21 00 00 00 22 00 00  00 23 00 00 00 24 00 00  |.!..."...#...$..|
000000c0  00 25 00 00 00 26 00 00  00 27 00 00 00 28 00 00  |.%...&...'...(..|
000000d0  00 29 00 00 00 2a 00 00  00 2b 00 00 00 2c 00 00  |.)...*...+...,..|
000000e0  00 2d 00 00 00 2e 00 00  00 2f 00 00 00 30 00 00  |.-......./...0..|
000000f0  00 31 00 00 00 32 00 00  00 33 00 00 00 34 00 00  |.1...2...3...4..|
00000100  00 35 00 00 00 36 00 00  00 37 00 00 00 38 00 00  |.5...6...7...8..|
00000110  00 39 00 00 00 3a 00 00  00 3b 00 00 00 3c 00 00  |.9...:...;...<..|
00000120  00 3d 00 00 00 3e 00 00  00 3f 00 00 00 40 00 00  |.=...>...?...@..|
00000130  00 41 00 00 00 42 00 00  00 43 00 00 00 44 00 00  |.A...B...C...D..|
00000140  00 45 00 00 00 46 00 00  00 47 00 00 00 48 00 00  |.E...F...G...H..|
00000150  00 49 00 00 00 4a 00 00  00 4b 00 00 00 4c 00 00  |.I...J...K...L..|
00000160  00 4d 00 00 00 4e 00 00  00 4f 00 00 00 50 00 00  |.M...N...O...P..|
00000170  00 51 00 00 00 52 00 00  00 53 00 00 00 54 00 00  |.Q...R...S...T..|
00000180  00 55 00 00 00 56 00 00  00 57 00 00 00 58 00 00  |.U...V...W...X..|
00000190  00 59 00 00 00 5a 00 00  00 5b 00 00 00 5c 00 00  |.Y...Z...[...\..|
000001a0  00 5d 00 00 00 5e 00 00  00 5f 00 00 00 60 00 00  |.]...^..._...`..|
000001b0  00 61 00 00 00 62 00 00  00 63 00 00 00 64 00 00  |.a...b...c...d..|
000001c0  00 65 00 00 00 66 00 00  00 67 00 00 00 68 00 00  |.e...f...g...h..|
000001d0  00 69 00 00 00 6a 00 00  00 6b 00 00 00 6c 00 00  |.i...j...k...l..|
000001e0  00 6d 00 00 00 6e 00 00  00 6f 00 00 00 70 00 00  |.m...n...o...p..|
000001f0  00 71 00 00 00 72 00 00  00 73 00 00 00 74 00 00  |.q...r...s...t..|
00000200


一些飞思卡尔文档中提到了0x33221100的神奇数字,尽管我希望看到它具有相反的字节序。

因此,要成功克隆,请选择更大容量的SD卡,以确保不会覆盖任何内容(或调整分区大小)。

拍摄原始卡的图像:

root@kali:~# dd if=/dev/mmcblk0 of=wholeSD.img
3899392+0 records in
3899392+0 records out
1996488704 bytes (2.0 GB) copied, 98.3687 s, 20.3 MB/s


然后拍摄BCB的最后一个扇区的图像:

root@kali:~# dd if=/dev/mmcblk0 bs=512 count=1 skip=3899391 of=BCB.img
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.000220203 s, 2.3 MB/s


查找新的SD卡有多大:

Disk /dev/mmcblk0: 2002 MB, 2002780160 bytes
4 heads, 16 sectors/track, 61120 cylinders, total 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
Disk identifier: 0x0f6c2d46

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            2048       32000       14976+  53  OnTrack DM6 Aux3
/dev/mmcblk0p2           32001      200000       84000   83  Linux
/dev/mmcblk0p3          200001      400000      100000   83  Linux
/dev/mmcblk0p4          400001     3899391     1749695+  83  Linux


这是一个更大的3911680扇区。 :

root@kali:~# dd if=wholeSD.img of=/dev/mmcblk0
13899392+0 records in
3899392+0 records out
1996488704 bytes (2.0 GB) copied, 1545.45 s, 1.3 MB/s


,然后将BCB图像移动到卡的最后一个扇区:

root@kali:~# dd if=BCB.img bs=512 count=1 seek=3911679 of=/dev/mmcblk0
1+0 records in
1+0 records out
512 bytes (512 B) copied, 8.4684e-05 s, 6.0 MB/s


注意使用搜寻(输出端)而不是跳过(输入端)。

值得再次检查是否已写入最后一块。几个便宜的SD卡似乎无法在最后一个扇区工作,可能是因为它们错误地报告了大小。

现在您有了启动卡。

#2 楼

Micro SD卡具有可从卡中读取的卡识别寄存器(CID)。 CID除其他事项外,还包含产品序列号和生产日期,这在卡之间是不同的。
这篇博客文章是关于在运行Linux的iMX233上读取CID并将其用作复制保护机制的。

评论


你加油今晚将检查此。

– Cyber​​gibbons
2014年11月22日在11:14

我也找到了这个superuser.com/questions/597578/…,它暗示了类似的内容。我想是时候深入研究了。

– Cyber​​gibbons
2014年11月22日18:22