Clone eMMC GUI Development Environment to boot from SD card

tutorial

#1

Clone eMMC GUI Development Environment to boot from SD card
Targeting Linaro Release 17.09 (283) since Debian Baster is still in development till Q2, Q3 2019.
Debian Baster Linaro build 18.01 is already available here.
Using

  • Windows 10 Pro x64
  • SanDisk Ultra 32GB
  • Tripp-Lite USB 3.0 SD Card Reader (Model# U352-000-SD-R)
  • Linksys USB3GIG USB 3.0 Gigabit Ethernet Adapter

Prerequisites: Setup GUI Development Environment (eMMC Boot)

  1. Download Linaro Debian developer image
  2. Unzip
  3. Rename dragonboard410c_sdcard_developer_debian-283.img to db410c_sd_developer_debian-283.img
  4. Delete dragonboard410c_sdcard_developer_debian-283.zip
  5. Install Rufus to create a bootable SD Card
  6. Put the 32GB SD card into the SD card reader.
  7. run Rufus
  8. Set selections as shown in the image.
  9. Remove the SD card
  10. Put another 32GB SD card into the SD card reader.
  11. Burn the same image, since you need two of them. One to boot from and another to copy eMMC rootfs onto.
  12. Insert one of the Linaro Developer build SD cards into DB410c SD card slot (/dev/mmcblk1)
  13. Insert the other Linaro Developer build SD cards into USB 3.0 SD Card Reader (/dev/sda)
  14. Set DIP switches to 0010 (boot from SD card)
  15. Boot
  16. Login with linaro/linaro

Check devices
eMMC
sudo fdisk /dev/mmcblk0 -l

Disk /dev/mmcblk0: 7.3 GiB, 7818182656 bytes, 15269888 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: gpt
Disk identifier: CAF49198-31E6-4C89-B219-5721FD7CFA1D

Device Start End Sectors Size Type
/dev/mmcblk0p1 131072 131075 4 2K unknown
/dev/mmcblk0p2 131076 132099 1024 512K unknown
/dev/mmcblk0p3 132100 133123 1024 512K unknown
/dev/mmcblk0p4 133124 135171 2048 1M unknown
/dev/mmcblk0p5 135172 136195 1024 512K unknown
/dev/mmcblk0p6 262144 262175 32 16K unknown
/dev/mmcblk0p7 262176 264223 2048 1M unknown
/dev/mmcblk0p8 264224 395295 131072 64M unknown
/dev/mmcblk0p9 395296 397343 2048 1M unknown
/dev/mmcblk0p10 397344 15269854 14872511 7.1G Linux filesystem

USB 3.0 SD Card Reader
sudo fdisk /dev/sda -l

GPT PMBR size mismatch (8388607 != 62333951) will be corrected by w(rite).
Disk /dev/sda: 29.7 GiB, 31914983424 bytes, 62333952 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: gpt
Disk identifier: 290739B1-1135-4899-9BDF-64BCE761E942

Device Start End Sectors Size Type
/dev/sda1 131072 132095 1024 512K unknown
/dev/sda2 132096 133119 1024 512K unknown
/dev/sda3 133120 135167 2048 1M unknown
/dev/sda4 135168 136191 1024 512K unknown
/dev/sda5 262144 262175 32 16K unknown
/dev/sda6 262176 264223 2048 1M unknown
/dev/sda7 264224 395295 131072 64M unknown
/dev/sda8 395296 397343 2048 1M unknown
/dev/sda9 397344 8388574 7991231 3.8G Linux filesystem

Extend the rootfs partition to 100%
sudo parted /dev/sda resizepart 9
Warning: Partition /dev/sda9 is being used. Are you sure you want to continue?
Yes/No? Y
End? [4295MB]? 100%
Information: You may need to update /etc/fstab.

The extended rootfs partition

/dev/sda9 397344 62333918 61936575 29.5G Linux filesystem

Copy Linaro Debian GUI build (/dev/mmcblk0p10 eMMC rootfs partition) onto Linaro Debian developer build (/dev/sda9 USB 3.0 SD Card Reader rootfs partition).
sudo dd if=/dev/mmcblk0p10 of=/dev/sda9 bs=4096 status=progress

285069312 bytes (285 MB, 272 MiB) copied, 18.0868 s, 15.8 MB/s

The process will take while so relax, have another cup of coffee, go for a walk or take a nap :wink:.

7608070144 bytes (7.6 GB, 7.1 GiB) copied, 586 s, 13.0 MB/s
1859063+1 records in
1859063+1 records out
7614725632 bytes (7.6 GB, 7.1 GiB) copied, 586.62 s, 13.0 MB/s

Shutdown

  1. sudo shutdown -P now
  2. Move SD card from the USB 3.0 SD Card Reader into the DB SD Card Reader.
  3. Boot into eMMC
  4. Set DIP switches to 0000 (boot from eMMC)
  5. Boot

Check partition allocation
df /dev/mmcblk1p9 -H

Filesystem Size Used Avail Use% Mounted on
/dev/disk/by-partlabel/rootfs 7.5G 2.9G 4.3G 40% /

Extend rootfs to fill up partition

Unmount device
umount /dev/mmcblk1

Grow rootfs partition
sudo e2fsck -f /dev/mmcblk1p9

e2fsck 1.43.4 (31-Jan-2017)
Pass 1: Checking inodes, blocks, and sizes
Inodes that were part of a corrupted orphan linked list found. Fix? yes
Inode 26109 was part of the orphaned inode list. FIXED.
Inode 26148 was part of the orphaned inode list. FIXED.
Inode 26287 was part of the orphaned inode list. FIXED.
Inode 26989 was part of the orphaned inode list. FIXED.
Inode 27009 was part of the orphaned inode list. FIXED.
Inode 27015 was part of the orphaned inode list. FIXED.
Inode 27065 was part of the orphaned inode list. FIXED.
Inode 27078 was part of the orphaned inode list. FIXED.
Inode 27094 was part of the orphaned inode list. FIXED.
Inode 33749 was part of the orphaned inode list. FIXED.
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

rootfs: ***** FILE SYSTEM WAS MODIFIED *****
rootfs: 110540/456000 files (0.2% non-contiguous), 736691/1859063 blocks

sudo resize2fs /dev/mmcblk1p9

resize2fs 1.43.4 (31-Jan-2017)
Resizing the filesystem on /dev/mmcblk1p9 to 7742071 (4k) blocks.
The filesystem on /dev/mmcblk1p9 is now 7742071 (4k) blocks long.

sudo e2fsck -f /dev/mmcblk1p9

e2fsck 1.43.4 (31-Jan-2017)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
rootfs: 110540/1896000 files (0.2% non-contiguous), 827367/7742071 blocks

Read partition table
sudo partprobe /dev/mmcblk1

Reboot
sudo shutdown -r now

Check rootfs
df /dev/mmcblk1p9 -H

Filesystem Size Used Avail Use% Mounted on
/dev/disk/by-partlabel/rootfs 32G 2.9G 27G 10% /

rootfs is copied from eMMC, grow partition and ready to boot from SD

Shutdown

  1. sudo shutdown -P now
  2. Set DIP switches to 0010 (boot from SD)
  3. Boot

Now we have a Linaro Developer GUI booting from SD card
The SD card size could be 64GB, 128GB or larger
The DB820c will have a much faster SD card reader and can take advantage U3 fast SD cards.
Installed GParted and it reports that it’s all good.

Conclusion
With the DB820c we are entering into a new era where the distinction between PC and microcontroller is blurred.
It’s truly exciting to be a software developer today and watch how the “Software as a device” concept is becoming a reality with Azure IoT edge computing, opening the way for IoMT (Internet of Medical Things) devices.


#2

Thanks for the tutorial. We’ve had a quite a few questions about this specific topic recently!

BTW I think this topic will get a bit of feedback over time about things like duplicated MAC addresses and ssh keys. Cloning an system that is past the first-boot point will end up cloning some of its unique identifiers… and this is a good thing if you are cloning so you have more space for the rootfs. However if the SD card is used to boot a second DB410C then there could be collisions.

Debian Buster was released three weeks ago: Linaro Linux 18.01 releases (although we forgot to update the documentation until last week :wink: )


#4

Thank you very much Daniel. I have more to come :mage:

What I meant is that Debian Baster itself is still in development till Q2, Q3 2019.
Many components that I must rely on will not be available until it’s released.
I’ll start evaluating Buster in Q1 2019 :crossed_fingers:


#5

Ah… understood.

You might like to look at building the v4.14 kernel yourself at some point, especially if you suffer WiFi disconnection problems, the kernel from 18.01 has a number of bug fixes here (of course that may have knock on effects for fast changing code like the V4L2 codec integration so I’d only look at this if you have to).


#6

Awesome. I’ll keep using the latest.