Introduction
The SoCFPGA Development kit can boot from an SD card or from the onboard QSPI. The GSRD uses the SD card booting, because it is more convenient for the user.
This page presents the layout of the SD card image used by the GSRD, together with the instructions on how to re-create the SD card image, and also how to update individual elements on the SD card.
Boot Flow
See
HPS Boot Flow.
SD Card Layout
The picture below presents the layout of the SD card that is used by the GSRD:

The following table summarizes the information that is stored on the SD card:
Location |
File Name |
Description |
---|
Partition 1 |
socfpga.dtb |
Device Tree Blob file |
^ |
soc_system.rbf |
FPGA configuration file |
^ |
u-boot.scr |
U-boot script for configuring FPGA |
^ |
zImage |
Compressed Linux kernel image file |
Partition 2 |
various |
Linux root filesystem |
Partition 3 |
n/a |
Preloader image |
^ |
n/a |
U-boot image |
The MBR (Master Boot Record) contains descriptions of the partitions on the card, including their type, location and length.
Partition 3 is a custom partition with type=0xa2. It is required by the BootROM, which will identify it from the MBR and load the Preloader from the beginning of it.
Note that since the MBR describes the partitions, the order of partitions and their locations is not actually relevant. You could have a different order and/or gaps between them and the boot will still be successful.
Creating SD Card Image Using Provided Script
This section presents details on how to create the GSRD bootable SD card image, similar with the SD card image that is provided as part of the precompiled binaries package.
The following items are required in order to be able to create the SD card image. They are all delivered as part of the precompiled binaries package but can also be rebuilt.
Item |
Description |
How to Build |
---|
preloader-mkpimage_cyclone5.bin |
Preloader image |
Generated and compiled with SoCEDS based on Quartus handoff information |
soc_system.rbf |
Compressed FPGA configuration file |
From GHRD delivered with GSRD |
socfpga.dtb |
Device Tree Blob |
From GHRD delivered with GSRD |
u-boot.scr |
U-boot script for configuring the FPGA |
Created with text editor and mkimage utility |
u-boot-socfpga_cyclone5.img |
U-boot image |
Compiled by Yocto with bitbake virtual/bootloader |
zImage |
Compressed Linux kernel image |
Compiled by Yocto with bitbake altera-gsrd-image |
altera-gsrd-image.tar.gz |
Root filesystem as compressed tarball |
Compiled by Yocto with bitbake virtual/kernel |
bup.tar.gz |
Web server files - delivered with the release |
Does not need to be rebuilt |
The Yocto source package provides a script that can be used to conveniently create the SD card image. Form more information about the Yocto source package see:
When using the default Yocto package installation path, the SD card creation script can be found at
/opt/altera-linux/bin/make_sdimage.sh
.
In order to obtain more information about the script usage, run it without any parameters or with "-h":
$ /opt/altera-linux/bin/make_sdimage.sh -h
usage: make_sdimage.sh [-h] [-k f1,f2] [[-p preloader |-rp preloader] -b bootloader] [-r rfs_dir [-m merge_dir]] [-o image] [-g size] [-t tool]
-k f1,f2,... comma separated list of files to be copied into FAT partition, i.e. OS files (zImage, dtb) or FPGA image (rbf)
-p preloader preloader file with mkpimage header (i.e preloader-mkpimage.bin). Mutually exclusive with -rp.
-rp preloader raw preloader file (i.e u-boot-spl.bin). Specify your preloader header tool with -t option. Mutually exclusive with -p.
-b bootloader bootloader file (i.e. u-boot.img)
-r rfs_dir location of the root file system files.
-o image name of generated image file. Default filename is image_blk_demo.bin
-m merge_dir copy files located in dir/ to rfs.
-g size[K/M/G] size of generated image, in unit KB, MB or GB (i.e 2000M). Default size is 2GB
-t tool tool to geneate preloader with header (i.e /mkpimage). Use this with -rp option.
-h this message
Creating SD Card Image Using Prebuilt Binaries
For example, in order to re-create the SD card image by using the precompiled binaries package, you can perform the following commands (make sure to have the
linux-socfpga-gsrd-13.1-cv-bin.tar.gz
and
bup.tar.gz
in the current folder, or change paths accordingly):
1. Create
rootfsfolder containing the root filesystem and the web server additional files:
$ tar xvzf linux-socfpga-gsrd-13.1-cv-bin.tar.gz
$ mkdir rootfs
$ cd rootfs
$ sudo tar xzf ../linux-socfpga-gsrd-13.1-cv-bin/altera-gsrd-image.tar.gz
$ sudo tar xzf ../bup.tar.gz
$ cd ..
2. Invoke script to create the SD card image:
$ sudo /opt/altera-linux/bin/make_sdimage.sh \
-k socfpga.dtb,u-boot.scr,zImage,soc_system.rbf \
-p linux-socfpga-gsrd-13.1-cv-bin/preloader-mkpimage_cyclone5.bin \
-b linux-socfpga-gsrd-13.1-cv-bin/u-boot-socfpga_cyclone5.img \
-r rootfs/ \
-o gsrd_sd_card_image.img \
-g 2G
Creating SD Card Image Using Rebuilt Binaries
This is very similar with creating using Prebuilt binaries, except using the files from where they are built. The default locations are:
Default File Location |
Comment |
---|
~/build/tmp/deploy/images/zImage |
Built by Yocto |
~/build/tmp/deploy/images/u-boot-socfpga_cyclone5.img |
^ |
~/build/tmp/deploy/images/altera-gsrd-image-socfpga_cyclone5.tar.gz |
^ |
~/cv_soc_devkit_ghrd/output_files/soc_system.rbf |
Part of GHRD |
~/cv_soc_devkit_ghrd/software/spl_bsp/preloader-mkpimage.bin |
^ |
~/cv_soc_devkit_ghrd/soc_system.dtb |
^ |
Note that the web server files from bup.tar.gz do not need to be rebuilt, they can be used as-is from the release package.
Creating SD Card Image Manually
You can also create the SD Card image manually, without using the provided script.
Refer to
/opt/altera-linux/bin/make_sdimage.sh script for the necessary commands to be executed.
Updating Individual Elements on the SD card
It is time consuming to write the whole SD image to the card each time a modification is made. Therefore it is often preferable to create the SD card and write it to the card once, then update different elements individually.
The following table presents how each item can be updated individually:
File |
Update Procedure |
---|
zImage |
Mount DOS SD card partition 1 and replace file with new one: $ sudo mkdir sdcard $ sudo mount /dev/sdx1 sdcard/ $ sudo cp <file_name> sdcard/ $ sudo umount sdcard |
soc_system.rbf |
^ |
soc_system.dtb |
^ |
u-boot.scr |
^ |
preloader-mkpimage.bin |
$ sudo dd if=preloader-mkpimage.bin of=/dev/sdx3 bs=64k seek=0 |
u-boot-socfpga_cyclone5.img |
$ sudo dd if=u-boot-socfpga_cyclone5.img of=/dev/sdx3 bs=64k seek=4 |
root filesystem |
$ sudo dd if=altera-gsrd-image-socfpga_cyclone5.ext3 of=/dev/sdx2 |
Replace in the above command "sdx" with the device name of the SD card on your host system. You can find out the device name by running
$ cat /proc/partitions
before and after plugging in the card reader into the host.