EMB-2230: MicroSD Image

From Estone Technology Wiki
Jump to: navigation, search

Create MicroSD Image

Preparing MicroSD Card

Requirements:

  • Host Machine: (Linux Ubuntu)
  • MicroSD Card: (Minimum 8GB)
  • card reader
  • U-boot/Kernel Files: (imx6dl-hio.dtb, zImage, u-boot.img, SPL)
  • rootfs: (*.rootfs.tar.bz2)

Prepare MicroSD with fdisk

1. Plug MicroSD to the host machine (Linux Ubuntu)
2. Open Terminal by pressing Ctrl+Alt+T keys in your keyboard simultaneously
3. In the terminal type in lsblk command to see what letter your MicroSD card was given
(Example: /dev/sda, /dev/sdb, /dev/sdc, etc..)

$ lsblk                                           

Lsblk-1.png


4. Locate the MicroSD card in the HDD menu Note: MicroSD letter (/dev/sd<x>) is dependent on the amount of HDD's that are connected to the host machine
Example: As shown in the image, MicroSD is located at /dev/sdc
Lsblk-hdd.png


5. Once MicroSD is located run the fdisk command to start MicroSD Filesystem preparation

$ sudo fdisk /dev/sd<x> 

Fdisk-start.png


  • Here is a list of all available options:

Command (m for help): m 
Help:
 DOS (MBR)
  a   toggle a bootable flag
  b   edit nested BSD disklabel
  c   toggle the dos compatibility flag
 Generic
  d   delete a partition
  F   list free unpartitioned space
  l   list known partition types
  n   add a new partition
  p   print the partition table
  t   change a partition type
  v   verify the partition table
  i   print information about a partition
 Misc
  m   print this menu
  u   change display/entry units
  x   extra functionality (experts only)
 Script
  I   load disk layout from sfdisk script file
  O   dump disk layout to sfdisk script file
 Save & Exit
  w   write table to disk and exit
  q   quit without saving changes
 Create a new label
  g   create a new empty GPT partition table
  G   create a new empty SGI (IRIX) partition table
  o   create a new empty DOS partition table
  s   create a new empty Sun partition table


6. We will now create the first partition for the MicroSD

Command (m for help): n 
Partition type
  p   primary (0 primary, 0 extended, 4 free)
  e   extended (container for logical partitions)
Select (default p): p 
Partition number (1-4, default 1): 1 
First sector (2048-124735487, default 2048): 'Enter' 
Last sector, +sectors or +size{K,M,G,T,P} (10240-124735487, default 124735487): +100M 
Command (m for help): t 
Selected partition 1
Hex code (type L to list codes): c 
Changed system type of partition 1 to c (W95 FAT32 (LBA))
Created a new partition 1 of type 'c W95 FAT32 (LBA)' and of size 100 MiB.


7. Now we will create the MicroSD second partition

Command (m for help): n 
Partition type
  p   primary (1 primary, 0 extended, 3 free)
  e   extended (container for logical partitions)
Select (default p): p 
Partition number (2-4, default 2): 2 
First sector (2048-124735487, default 2048): 'Enter' 
Last sector, +sectors or +size{K,M,G,T,P} (215040-124735487, default 124735487): Press 'Enter' key 
Created a new partition 2 of type 'Linux' and of size 59.4 GiB.


8. Once the 2nd partition is created you need to write changes to the MicroSD card

Command (m for help):  w 
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

9. Now we will add partition filesystem type to the 2 partitions that were created

For 1st Partition:

$ sudo mkfs.vfat /dev/sd<x>1
$ sudo mount /dev/sd<x>1 /mnt
$ sudo cp imx6dl-hio.dtb zImage u-boot.img /mnt
$ sync
$ sudo umount /dev/sd<x>1

For 2nd Partition:

$ sudo mkfs.ext4 /dev/sd<x>2
$ sudo mount /dev/sd<x>2 /mnt
$ cd /mnt/
$ sudo tar -xvf *.rootfs.tar.bz2
$ sync
$ sudo umount /dev/sd<x>2
$ sudo dd if=SPL of=/dev/sd<x> bs=1k seek=1

Note: The *.rootfs.tar.bz2 is the rootfs file that was created in Yocto

Boot from SD card

Set the boot switch to "2"

Emb2230-sw2.png


Insert the Create MicroSD Image into the SD card slot

Ppc-4210-sd.png

Insert the power on it will from sd run now