How To: Prepare SD Card for boot

From HIO Wiki
Jump to: navigation, search

SD Card Memory Map

SD Card Memory Map.PNG
A Hio Yocto Environment is divided into 3 parts:

  • Bootloader u-boot: a small program that put the operating system into the memory
  • Kernel UImage: the lowest level of software that interfaces with the hardware in computer. It is responsible for interfacing all the applications in "user mode" to physical hardware. It also allow processes to get information from each other using inter-process communication (IPC).[1]
  • Rootfs //rootfs/folder : a special instance of a very simple filesystem that exports Linux's disk caching mechanisms as a dynamically resizable RAM-based filesystem.

Create a bootable SD card

Steps to create your HIO Yocto SD card image:

1. Acquire SD Card ID

Plug a mini SD card into the computer, then display the device ID of SD card using command:

$ lsblk

Lsblk.PNG
Eg. Sample has an SD card name sdc with 2 partitions.

Skip Step 2 if the SD card is empty and has no partition.

2. Optional: Delete Partition

Caution: Partitioning the drive will erase all of its data content permanently.

Acquire the card name, for this tutorial, we will use /dev/sdc.

$ sudo fdisk /dev/sdc
p	display note of the start sector
d	delete
1	first partition
d	delete
2	second partition
p	display
w	write

Unplug and plug-in the SD Card to reset.

3. Create Partition

We have to create 2 Partitions. One is for the u-boot and kernel and one is for rootfs.

$ sudo fdisk /dev/sdc
p	display note of the start sector
n	create partition
p	primary selection
1	first partition		(for kernel)
first sector 	+100M 	        (for u-boot)
last sector	+200M
n	create partition
p	primary selection
2	second partition	(for rootfs)
first sector 	+400M 	
last sector	default		(use all the remaining space)
p	display
w	write

Unplug and plug-in the SD Card.

4. Format Partition

The card needs to be formatted to write into. Enter the following command into terminal.
Caution: Formatting will erase all data of the card.

Assume that the card name is sdc and the 2 partitions are sdc1 and sdc2

$ sudo mkfs.vfat /dev/sdc1
$ sudo mkfs.ext4 /dev/sdc2