Skip to content
This repository was archived by the owner on Jan 16, 2023. It is now read-only.

SD card

johFeldmann edited this page Sep 14, 2017 · 3 revisions

This section describes how to get all components onto an sd card.

Prerequisites

  • Linux system: For several steps a Linux system is needed. You can use the system from Root file system.
  • su(do): We will do fancy things, so you will need super user rights. The following steps will use sudo.
  • SD card: Of course you will need an SD Card with enough capacity. A high-speed card could make things faster but is not needed.

Prepare SD card

The following commands will use '/dev/sdX' to refer to the SD card device. Replace this with the actual device on your system. Executing the following commands on the wrong device may corrupt your data on other file systems. Also, all data on your SD card will be destroyed.

Find your SD card

Use the following command to find your connected SD card in your Linux system:

dmesg

Its name should be formated sd_X_. X depends on your system. This description will use X in all lines of code, please change this to the correct letter.

Delete the partition table

Explicitly delete the partition table using the folowing command:

sudo dd if=/dev/zero of=/dev/sdX bs=1024 count=1

Create new partitions

We will create two partitions on the SD card. One 100 MB sized boot partition. And a second partition for the file system.

sudo fdisk /dev/sdX

Now create the partitions:

Command (m for help): n
Partition type:
 p primary (0 primary, 0 extended, 4 free)
 e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-60637183, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-60637183, default 60637183): +100M

Command (m for help): n
Partition type:
 p primary (1 primary, 0 extended, 3 free)
 e extended
Select (default p): p
Partition number (1-4, default 2): 2
First sector (206848-60637183, default 411648):
Using default value 411648
Last sector, +sectors or +size{K,M,G} (206848-60637183, default 60637183):
Using default value 60637183

Now set the bootable flag and partition IDs

Command (m for help): a
Partition number (1-4): 1

Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): c
Changed system type of partition 1 to c (W95 FAT32 (LBA))

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 83

Check all changes and write to SD card.

Command (m for help): p

Disk /dev/sdb: 31.0 GB, 31046238208 bytes, 60637184 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 label type: dos
Disk identifier: 0x3d12e3e1

   Device  Boot     Start        End     Blocks   Id  System
/dev/sdb1   *        2048      206847      102400    c  W95 FAT32 (LBA)
/dev/sdb2          206848    60637183    30215168   83  Linux

Command (m for help): w
The partition table has been altered!

Make sure the kernel re-read the partition table! Create new file systems:

sudo mkfs.vfat -F 32 -n boot /dev/sdX1
sudo mkfs.ext4 -L root /dev/sdX2

Setup boot partition

The following files have to be copied to the boot partition:

  • uImage (median.demonstartor/kernel/uImage)
  • devicetree.dtb (median.demonstartor/device_tree/zynq-zynqberry.dtb)

Setup root partition

Extract the content of filesystem.tar.gz to the root partition

sudo tar -xvf filesystem.tar.gz -C <path-to-root>

Links

Clone this wiki locally