Cloning an SD card that came with the SABRE SD (Quad)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cloning an SD card that came with the SABRE SD (Quad)

2,142 Views
ioancalapod
Contributor II

Hi All

I am trying to clone the original SD card that came with the SABRE SD card (Android)

The idea is to copy it to ISO and then from the ISO to the new empty SD card.

In Ubuntu this what I used:

sudo dd if=/dev/sdb of=/media/sf_SharedP/sd_card_image_android.iso

then from ISO (7.9GB)

sudo dd if=/dev/sdb of=/media/sf_SharedP/sd_card_image_Silex_Lin.iso

The process is a lengthy one and the new card does not work... some how the data partition is not being recreated...

partitions on the SD are:

vender

data

cache

544 MB Volume

Please let me know if you have a better way of doing it so that I get a working clone.

Best Regards, Ioan

0 Kudos
11 Replies

1,991 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hi,

   It seems that using win32 Disk Imager can also clone a bootable SD card with image. 

Have a nice day!

B.R,

weidong

0 Kudos

2,057 Views
BiyongSUN
NXP Employee
NXP Employee

if you want to create a SDcard mirror and use on the same size of the sdcard, you have to choise to make it safe.

For example, if you use 8G card to create a 8G mirror, then dd to a 8G card, it may have problem. cause the end of the card may contain bad sectors.

If you use this mirror  dd to a 16G, it won't be a problem.

1. When you create a sdcard, leave 200M at the end of the sdcard,  then use the fdisk to show the lastest(end) cluster as the dd parameter.

2. use the linux host side "parted" application to resize the latest partition. 

0 Kudos

2,030 Views
mpilia
Contributor III

Hi @BiyongSUN,

I'm trying to create an SDcard mirror of the SD Card provided with the MCIMX6SX-SDB (Size=16GB).

I follow these steps:

1) Unmount the SD Card:

    sudo umount /dev/sdb1

    sudo umount /dev/sdb2

 

2) Check SD info:

    sudo fdisk -l /dev/sdb

the result is the follow:

Boot Device         Start             End       Sectors       Size     Id    Type

/dev/sdb1           20480     1044479     1024000     500M      c    W95 FAT32 (LBA)

/dev/sdb2       1228800   30375935   29147136    13,9G    83    Linux

 

3) Do the copy with the command:

sudo dd if=/dev/sdb of=imx6sx.img bs=1M count=14832 status="progress" conv=sync,noerror

 

Now, if I mount the imx6sx.img, I see these differences with respect to the SD Card:

|   10M Free Space  |       524M FAT  (Part.1)    |    94M Free Space  |        15GB   Unkwoun (Part.2)      |

|   10M Free Space  |       524M FAT  (Part.1)    |    94M Free Space  |        15GB   Ext3  (Part.2)             |

 

Then I try to copy the imx6sx.img to the new 32GB SD Card with the command:

sudo dd of=/dev/sdb if=imx6sx.img status="progress" conv=sync,noerror

 

After that I see that the content of the new SD Card is like the imx6sx.img one:

|   10M Free Space  |       524M FAT  (Part.1)    |    94M Free Space  |        15GB   Unkwoun (Part.2)      |

 

inserting that SD Card into the Sabre imx6 solo x the result is that it does not boot. No log come from the uart interface.

 

What can be the problem?

Why are content of SD Card and image file different?

Thanks

Massimo

0 Kudos

2,009 Views
BiyongSUN
NXP Employee
NXP Employee

sudo parted imx6sx.img unit s print

to check the mirror imx6sx.img.

 

 

0 Kudos

2,008 Views
BiyongSUN
NXP Employee
NXP Employee

for the details,

 

sudo kpartx -av imx6sx.img
sudo fdisk -l /dev/loop0
sudo kpartx -dv imx6sx.img

 

0 Kudos

2,001 Views
mpilia
Contributor III

Hi @BiyongSUN 

I did the copy again and tried the commands you suggested:

$ sudo parted /dev/sdc unit s print
Modello: Multiple Card Reader (scsi)
Disco /dev/sdc: 30375936s
Dimensione del settore (logica/fisica): 512B/512B
Tabella delle partizioni: msdos
Flag del disco: 

Numero  Inizio    Fine       Dimensione  Tipo     File system  Flag
 1      20480s    1044479s   1024000s    primary  fat16        lba
 2      1228800s  30375935s  29147136s   primary  ext3

$ sudo dd if=/dev/sdc of=imx6sx_original.img bs=1M status="progress" conv=sync,noerror
15548284928 bytes (16 GB, 14 GiB) copied, 604 s, 25,7 MB/s 
14832+0 record dentro
14832+0 record fuori
15552479232 bytes (16 GB, 14 GiB) copied, 606,714 s, 25,6 MB/s

$ sudo parted imx6sx_original.img unit s print
Modello:  (file)
Disco /home/up2020/imx6sx_original.img: 30375936s
Dimensione del settore (logica/fisica): 512B/512B
Tabella delle partizioni: msdos
Flag del disco: 

Numero  Inizio    Fine       Dimensione  Tipo     File system  Flag
 1      20480s    1044479s   1024000s    primary  fat16        lba
 2      1228800s  30375935s  29147136s   primary

$ sudo kpartx -av imx6sx_original.img
add map loop15p1 (253:0): 0 1024000 linear 7:15 20480
add map loop15p2 (253:1): 0 29147136 linear 7:15 1228800
$ sudo fdisk -l /dev/loop15
Disk /dev/loop15: 14,5 GiB, 15552479232 bytes, 30375936 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: 0xe2d15a53

Dispositivo   Avvio   Start     Fine  Settori  Size Id Tipo
/dev/loop15p1         20480  1044479  1024000  500M  c W95 FAT32 (LBA)
/dev/loop15p2       1228800 30375935 29147136 13,9G 83 Linux
$ sudo kpartx -dv imx6sx_original.img
del devmap : loop15p2
del devmap : loop15p1
loop deleted : /dev/loop15
$ sudo kpartx -av imx6sx_original.img
add map loop15p1 (253:0): 0 1024000 linear 7:15 20480
add map loop15p2 (253:1): 0 29147136 linear 7:15 1228800
$ sudo fdisk -l /dev/loop15
Disk /dev/loop15: 14,5 GiB, 15552479232 bytes, 30375936 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: 0xe2d15a53

Dispositivo   Avvio   Start     Fine  Settori  Size Id Tipo
/dev/loop15p1         20480  1044479  1024000  500M  c W95 FAT32 (LBA)
/dev/loop15p2       1228800 30375935 29147136 13,9G 83 Linux
$ sudo kpartx -dv imx6sx_original.img
del devmap : loop15p2
del devmap : loop15p1
loop deleted : /dev/loop15


$ sudo dd of=/dev/sdc if=imx6sx_original.img bs=1M status="progress" conv=sync,noerror
15538847744 bytes (16 GB, 14 GiB) copied, 886 s, 17,5 MB/s 
14832+0 record dentro
14832+0 record fuori
15552479232 bytes (16 GB, 14 GiB) copied, 1016,5 s, 15,3 MB/s

$ sudo parted /dev/sdc unit s print
Modello: Multiple Card Reader (scsi)
Disco /dev/sdc: 60367872s
Dimensione del settore (logica/fisica): 512B/512B
Tabella delle partizioni: msdos
Flag del disco: 

Numero  Inizio    Fine       Dimensione  Tipo     File system  Flag
 1      20480s    1044479s   1024000s    primary  fat16        lba
 2      1228800s  30375935s  29147136s   primary

 

As you can see, the outputs of the command parted, for the SD Card and its image, are different. 

Anyway, I tried to copy the image to a new SD Card (size=32G) and the outputs of the command parted are the same for the image and the new SD Card.

I insert it to the Sabre but still no boot at all. Does it need to be formatted in a particular way?

I think the content of the original SD Card and its image should be the same, isn't it?

0 Kudos

1,979 Views
BiyongSUN
NXP Employee
NXP Employee

$ sudo parted /dev/sdc unit s print
Modello: Multiple Card Reader (scsi)
Disco /dev/sdc: 30375936s
Dimensione del settore (logica/fisica): 512B/512B
Tabella delle partizioni: msdos
Flag del disco:

Numero Inizio Fine Dimensione Tipo File system Flag
1 20480s 1044479s 1024000s primary fat16 lba
2 1228800s 30375935s 29147136s primary ext3

 

From you information, the master sdcard, which is used by dump mirror, is not correctly created. 

It uses entire the space, even the last sector. when you create the master sdcard, you need to leave for example 1M gap between the end of the last  partition and the end of the card. 

The dump should stop at the end of the last partition. not the end of the scdard.

 

And you don't have to use a real sdcard to create mirror. 

Here is the example for 2.5 mrrior. It can burn to 4G card, 8G card, 16G card etc. 

to make it clear, why you don't have to use a real sdcard and how powerful is kpartx. 

you can try the image you have dumped imx6sx_original.img

sudo kpartx -av imx6sx_original.img
sudo mount /dev/loop15p1 /mnt/
ls /mnt/    /*you will see the dtb files*/

sudo umount /mnt

sudo kpartx -dv imx6sx_original.img

 

example:

truncate -s 2.5G 2_5G.sdcard

 

parted -s 2_5G.sdcard mklabel msdos

parted 2_5G.sdcard unit MiB mkpart primary fat32 8 128
parted 2_5G.sdcard unit MiB mkpart primary ext4 130 2400

parted 2_5G.sdcard unit MiB print

kpartx -av 2_5G.sdcard

mkfs.vfat /dev/mapper/loop0p1
mkfs.ext4 /dev/mapper/loop0p2

dd if=/dev/zero of=/dev/loop0 bs=1k seek=384 conv=fsync count=129

dd if=u-boot-imx6qsabresd_sd.imx of=/dev/loop0 bs=1k seek=1

mount /dev/mapper/loop0p1 /mnt/
cp zImage /mnt/
cp imx6q-sabresd.dtb /mnt/
umount /mnt

mount /dev/mapper/loop0p2 /mnt/

 

tar jfvx fsl-image-qt5-xwayland-imx6qdlsolo.tar.bz2 -C /mnt

umount /mnt

kpartx -d 2_5G.sdcard

0 Kudos

1,971 Views
mpilia
Contributor III

Hi @BiyongSUN  and thanks for your reply.

Just a couple of questions:

  1. How did you choose start (8 and 130) and end (130 and 2400) value of the following commands?
parted 2_5G.sdcard unit MiB mkpart primary fat32 8 128
parted 2_5G.sdcard unit MiB mkpart primary ext4 130 2400

    2. How did you choose seek and count values in the following command?

dd if=/dev/zero of=/dev/loop0 bs=1k seek=384 conv=fsync count=129

    3. How did you choose seek value in the following command?

dd if=u-boot-imx6qsabresd_sd.imx of=/dev/loop0 bs=1k seek=1

 

0 Kudos

1,933 Views
BiyongSUN
NXP Employee
NXP Employee

In generate, the kpartx is very powerful tool. 

once you use it. you use it add the mirror as virtual device. treat it as a real one. 

what you do on a real sdcard, do it the same way. 

Just the device is /dev/loopX

and the partitions are in the /dev/mapper/

0 Kudos

1,946 Views
BiyongSUN
NXP Employee
NXP Employee

#1 0M ~ 8M leave for the uboot and uboot environment. you can use 4M. no problem. it just an example. 

#2 just show how to destroy uboot environment. you don't have to do that. 

#3 the imx6 chip, bootloarder offset is at 1024.  please read the related reference manual and bsp release document.

0 Kudos

2,057 Views
ioancalapod
Contributor II

Hi All

I redid the cloning process on a different computer (Ubuntu in Virtualbox) and cloning worked!

I am  at a loss to understand why didn't work on the first one! (used the exact same commands!)

Best Regards, Ioan

0 Kudos