Introduction

The Development kit can boot from an SD card or from the onboard QSPI. The Golden System Reference Design (GSRD) User Manuals 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:

gsrd-sdcard.png

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.

This release of the GSRD includes a tool that can be used to create a bootable SD card image from the items mentioned in the table above. The tool is named make_sdimage.py and is available at
16.1 http://releases.rocketboards.org/release/2016.10/gsrd/tools/make_sdimage.py
17.0 http://releases.rocketboards.org/release/2017.05/gsrd/tools/make_sdimage.py
17.1 http://releases.rocketboards.org/release/2017.10/gsrd/tools/make_sdimage.py

Note that the script requires argparse module, which is part of Python 2.7, but not included with previous versions. If you are using a Python version older than 2.7 you will need to obtain the argparse module separately.

For example, the following command was executed on a CentOS6.5 machine with Python 2.6.6 to install argparse:
$ wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
$ sudo rpm -i epel-release-6-8.noarch.rpm
$ rm epel-release-6-8.noarch.rpm
$ sudo yum install python-argparse

In order to obtain more information about the tool, please run it with the '-h' option:
$ sudo ~/make_sdimage.py -h
usage: make_sdimage.py [-h] [-P PART_ARGS] [-s SIZE] [-n IMAGE_NAME] [-f]

Creates an SD card image for Altera's SoCFPGA SoC's

optional arguments:
  -h, --help     show this help message and exit
  -P PART_ARGS   specifies a partition. May be used multiple times. file[,file
                 ,...],num=,format=,
                 size=[,type=ID]
  -s SIZE        specifies the size of the image. Units K|M|G can be used.
  -n IMAGE_NAME  specifies the name of the image.
  -f             deletes the image file if exists

Usage: PROG [-h] -P  [-P ...] -P 

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.bin Preloader image Generated and compiled with SoC EDS based on Quartus handoff information
ghrd_5astfd5k3.rbf Compressed FPGA configuration file From GHRD delivered with GSRD
ghrd_5astfd5k3.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-arria5.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-arria5.tar.gz Root filesystem as compressed tarball Compiled by Yocto with bitbake virtual/kernel

NOTE: Rename the ghrd_5astfd5k3.rbf to soc_system.rbf and ghrd_5astfd5k3.dtb to socfpga.dtb prior to proceeding with SD image creation

Creating SD Card Image Using Prebuilt Binaries

This section presents how to use the script to create the Arria V SD Card by using the prebuilt binaries. For Cyclone V the commands are very similar.

1. Download the Arria V binaries into the home folder and extract them, and cd to the binaries folder:
$ cd ~
$ mkdir linux-socfpga-gsrd-16.1-av-bin
# 16.1
$ wget http://releases.rocketboards.org/release/2016.10/gsrd/bin/linux-socfpga-gsrd-16.1-av-bin.tar.gz
# 17.0
$ wget http://releases.rocketboards.org/release/2017.05/gsrd/bin/linux-socfpga-gsrd-17.0-av-bin.tar.gz
$ tar -xvzf linux-socfpga-gsrd-*-av-bin.tar.gz -C linux-socfpga-gsrd-av-bin
# 17.1
$ wget http://releases.rocketboards.org/release/2017.10/gsrd/bin/linux-socfpga-gsrd-17.1-av-bin.tar.gz
$ tar -xvzf linux-socfpga-gsrd-*-av-bin.tar.gz -C linux-socfpga-gsrd-av-bin

2. Download the script and the webserver contents archive into the current folder:
$ cd ~
# 16.1
$ wget http://releases.rocketboards.org/release/2016.10/gsrd/tools/make_sdimage.py
# 17.0
$ wget http://releases.rocketboards.org/release/2017.05/gsrd/tools/make_sdimage.py
$ chmod +x ~/make_sdimage.py
# 17.1
$ wget http://releases.rocketboards.org/release/2017.10/gsrd/tools/make_sdimage.py
$ chmod +x ~/make_sdimage.py

3. Create the root filesystem to be put on the SD card image:
$ cd ~/linux-socfpga-gsrd-av-bin
$ mkdir rootfs
$ xz -d gsrd-console-image-arria5.tar.xz 
$ sudo tar xf gsrd-console-image-arria5.tar -C rootfs

4. Call the make_sdimage.py script:
$ cd ~/linux-socfpga-gsrd-av-bin
$ sudo ~/make_sdimage.py  \
-f \
-P preloader-mkpimage.bin,u-boot-arria5.img,num=3,format=raw,size=10M,type=A2 \
-P rootfs/*,num=2,format=ext3,size=1500M \
-P zImage,u-boot.scr,soc_system.rbf,socfpga.dtb,num=1,format=vfat,size=500M \
-s 2G \
-n sd_card_image_arria5.bin

This will create the file sd_card_image_arria5.bin.

Creating SD Card Image Using Rebuilt Binaries

This section presents how to build the SD card image for Arria V from the rebuilt binaries.

This is very similar with creating using Prebuilt binaries, except using the files from where they are built. The default locations are used:
Default File Location Comment
~/angstrom/build/tmp/deploy/images/zImage Built by Yocto
~/angstrom/build/tmp/deploy/images/u-boot-arria5.img
~/angstrom/build/tmp/deploy/images/gsrd-console-image-arria5.tar.xz
~/av_soc_devkit_ghrd/output_files/ghrd_5astfd5k3.rbf Part of GHRD
~/av_soc_devkit_ghrd/software/spl_bsp/preloader-mkpimage.bin
~/av_soc_devkit_ghrd/socfpga.dtb
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 /dev/sdx1 (FAT) on the host machine and update files accordingly:
$ sudo mkdir sdcard
$ sudo mount /dev/sdx1 sdcard/
$ sudo cp sdcard/
$ sudo umount sdcard
ghrd_5astfd5k3.rbf
socfpga.dtb
u-boot.scr
preloader-mkpimage.bin $ sudo dd if=preloader-mkpimage.bin of=/dev/sdx3 bs=64k seek=0
u-boot-arria5.img $ sudo dd if=u-boot-arria5.img of=/dev/sdx3 bs=64k seek=4
root filesystem Mount /dev/sdx2 (ext3 FS) on the host machine and updatefiles accordingly
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.

Give us your feedback

© 1999-2017 RocketBoards.org by the contributing authors. All material on this collaboration platform is the property of the contributing authors. Privacy.