Overview
The following steps will guide you through the process of formatting a bootable SD card for the DE1-SoC.
Partition Micro SD Card
The DE1-SoC requires three different partitions on the SD card. Before you are allowed to modify the SD card, you will need to make sure that the SD card is not currently mounted. You can determine where the SD card is mounted by using the following command(s):
mount | grep "/dev/sd"
This command returns all the the partitions currently mounted in Linux that are associated with a mass storage device. You will want to leave the /dev/sda partitions alone as they are most likely the partitions used to store your PCs Linux distribution. The SD card’s partitions can be identified with a leading /dev/sdX. To verify that you are going to modify the correct partitions (sdb in this example), you can use the fdisk command and verify that the capacity of the drive matches your SD card.
sudo fdisk -l /dev/sdb
We will notice that the disk is already partitioned correctly, by the following steps will show you how to unmount and delete any existing partitions.
Based on the results from the mount command, you will unmount any of the partitions found on the SD card.
sudo umount /media/ece453/SOC sudo umount /media/ece453/rootfs
Using fdisk, you can delete existing partitions
sudo fdisk /dev/sdb Welcome to fdisk (util-linux 2.27.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): d Partition number (1-3, default 3): 1 Partition 1 has been deleted. Command (m for help): d Partition number (2,3, default 3): 2 Partition 2 has been deleted. Command (m for help): d Selected partition 3 Partition 3 has been deleted. Command (m for help): p Disk /dev/sdb: 7.4 GiB, 7902068736 bytes, 15433728 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: 0x6a2fd742 Command (m for help):
Once any existing partitions have been deleted, you will need to create 3 new partitions. Partition 1 will be used to hold the SoC specific files, Partition 2 will be used for the Linux filesystem, and partition 3 will be used to hold the SoC Preloader. The instructions below create the partitions that are out of order on the SD card, but it will simplify any future expansion of the Linux filesystem. Keeping the Linux filesystem partition small helps when trying to copy or archive the SD card, but if you require additional software packages, you may find that you need to add additional storage capacity to partition 2. By physically placing partition 2 after the other partitions, you can easily expand the filesystem using gparted.
ece453@ece453-Linux:~$ sudo fdisk /dev/sdb Welcome to fdisk (util-linux 2.27.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. 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): 3 First sector (2048-15433727, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-15433727, default 15433727): +10MB Created a new partition 3 of type 'Linux' and of size 10 MiB. 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 (1,2,4, default 1): 1 First sector (22528-15433727, default 22528): Last sector, +sectors or +size{K,M,G,T,P} (22528-15433727, default 15433727): +256MB Created a new partition 1 of type 'Linux' and of size 244 MiB. Command (m for help): n Partition type p primary (2 primary, 0 extended, 2 free) e extended (container for logical partitions) Select (default p): p Partition number (2,4, default 2): 2 First sector (522240-15433727, default 522240): Last sector, +sectors or +size{K,M,G,T,P} (522240-15433727, default 15433727): +1GB Created a new partition 2 of type 'Linux' and of size 954 MiB. Command (m for help): t Partition number (1-3, default 3): 1 Partition type (type L to list all types): b Changed type of partition 'Linux' to 'W95 FAT32'. Command (m for help): t Partition number (1-3, default 3): 3 Partition type (type L to list all types): a2 Changed type of partition 'Linux' to 'unknown'. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks. ece453@ece453-Linux:~$ sudo fdisk -l /dev/sdb Disk /dev/sdb: 7.4 GiB, 7902068736 bytes, 15433728 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: 0x6a2fd742 Device Boot Start End Sectors Size Id Type /dev/sdb1 22528 522239 499712 244M b W95 FAT32 /dev/sdb2 522240 2476031 1953792 954M 83 Linux /dev/sdb3 2048 22527 20480 10M a2 unknown Partition table entries are not in disk order. ece453@ece453-Linux:~$
The filesystem type for the SoC file partition should be set to FAT32. The filesystem type for the preloader partition should be set to A2. This is a custom filesystem type required by the Intel preloader. The filesystem type for the Linux filesystem can be left as Linux.
Format Partitions
Now that the SD card had been partitioned, we need to format the filesystem on each partition. We will also give each partition a label so we can more easily determine the purpose of each partition.
ece453@ece453-Linux:~$ sudo mkfs.ext4 /dev/sdb2 mke2fs 1.42.13 (17-May-2015) Creating filesystem with 244224 4k blocks and 61056 inodes Filesystem UUID: 73ecfd0b-cb75-4456-82aa-50ece528dc1d Superblock backups stored on blocks: 32768, 98304, 163840, 229376 Allocating group tables: done Writing inode tables: done Writing superblocks and filesystem accounting information: done ece453@ece453-Linux:~$ sudo mkfs.vfat /dev/sdb1 mkfs.fat 3.0.28 (2015-05-16) ece453@ece453-Linux:~$ sudo e2label /dev/sdb2 rootfs ece453@ece453-Linux:~$ sudo fatlabel /dev/sdb1 SOC
Pre-loader Installation
The preloader executable needs to be placed at a specific location within the preloader partition. The following command can be used to install the preloader.
sudo dd if=preloader-mkpimage.bin of=/dev/sdb3 bs=64k seek=0
SoC Boot File Installation
In order to boot the Intel SoC, you will need to install the following files into the SoC partition of the SD card.
- soc_system.rbf (SoC Image File used to program the programmable logic fabric) Link coming soon
- soc_system.dtb (Linux Device tree binary blob) Link coming soon
- u-boot.img (U-Boot boot loader) Link
- u-boot.scr (compiled U-Boot Script) Link
- zImage (Linux Kernel Image) Link
If you do not have images for any of these files, use the corresponding links to see how to generate each file.
ece453@ece453-Linux:~$ cd images/ ece453@ece453-Linux:~/images$ cp ece453.dtb /media/ece453/SOC/soc_system.dtb ece453@ece453-Linux:~/images$ cp soc_system.rbf /media/ece453/SOC/ ece453@ece453-Linux:~/images$ cp u-boot.img /media/ece453/SOC/ ece453@ece453-Linux:~/images$ cp u-boot.scr /media/ece453/SOC/ ece453@ece453-Linux:~/images$ cp zImage /media/ece453/SOC/ ece453@ece453-Linux:~/images$ ls /media/ece453/SOC/ soc_system.dtb soc_system.rbf u-boot.img u-boot.scr zImage ece453@ece453-Linux:~/images$
Ubuntu Filesystem Installation
After all of the SoC specific files have been copied to the SD card, you will need to transfer the Linux Filesystem files to the SD card. If you are using the Ubuntu based filesystem described here, then you can use the following commands.
ece453@ece453-Linux:~$ sudo rsync -av Ubuntu_filesystem/ /media/ece453/rootfs/ ece453@ece453-Linux:~$ sudo sync
Buildroot Filesystem Installation
If you are going to use the Buildroot based filesystem images described here, then you can use the following commands to install the filesystem.
ece453@ece453-Linux:~/images$ sudo cp rootfs.tar /media/ece453/rootfs/ ece453@ece453-Linux:~/images$ cd /media/ece453/rootfs/ ece453@ece453-Linux:/media/ece453/rootfs$ sudo tar -xf rootfs.tar ece453@ece453-Linux:/media/ece453/rootfs$ sudo rm rootfs.tar ece453@ece453-Linux:/media/ece453/rootfs$ ls bin dev etc lib lib32 linuxrc media mnt opt proc root run sbin sys tmp usr var ece453@ece453-Linux:/media/ece453/rootfs$ sync
(Link coming soon)