binary form. If you change –type dtb by –type dts you will obtain the device
tree source file (the output filename should be soc_system.dts).
3.8.3 Creating the u‐boot.scr script.
The FPGA can be configured (also known as 'programmed') in several ways: From an external configuration flash memory, With the Quartus Programmer tool, From HPS software (from the preloader, from u‐boot, or from Linux)The FPGA is configured from U‐boot with the help of a script. This scheme ensures that the Linux boot succeeds even if the FPGA image is not present on the SD card.
If any failure during FPGA programming in U‐Boot, it will return an error message with a value. This value will represent the stages where the programming failed. Here are the numbers and error stages.
Table 7: Error displayed by u-boot when configuring the FPGA.
Error No Description
-1 The FPGA is not able to enter reset phase after FPGA reset request being made at FPGA Manager
-2 The FPGA is not able to enter configuration phase after FPGA reset release request being made at FPGA Manager
-3 The FPGA is having config error after enable AXI configuration at FPGA Manager
-4 The FPGA is having timeout from entering config done phase after enable AXI configuration at FPGA Manager
-5 The FPGA is having timeout from getting dclkcnt done signal after enable the dclkcnt delay. -6 The FPGA is having timeout from entering init phase or user mode after disable AXI
configuration at FPGA Manager
-7 The FPGA is having timeout from getting dclkcnt done signal after enable the dclkcnt delay. This is happen after FPGA reaching init phase or user mode
-8 The FPGA is having timeout from getting into final stage which is user mode If the FPGA image is not present, Linux will still boot, but the FPGA will need to be configured using another method. These are the steps needed to create the script: 1. On host PC, create text file “boot.script” with the following contents: fatload mmc 0:1 $fpgadata soc_system.rbf;
fpga load 0 $fpgadata $filesize; setenv fdtimage soc_system.dtb; run bridge_enable_handoff; run mmcload;
run mmcboot;
2. Add the U‐boot header to the “boot.script” file to create the u‐boot.scr file. Execute this in a SoC EDS command shell:
$ ./software/spl_bsp/uboot-socfpga/tools/mkimage -A arm -O linux -T script - C none -a 0 -e 0 -n "My script" -d boot.script u-boot.scr
3.8.4 Creating the sdcard image
This section presents the layout of the SD card image used by the de1‐soc, together with the instructions on how to create this SD card image, and also how to update individual elements on the SD card. Moreover, it will be presented details on how to create the bootable SD card image. Fig. 43 presents the layout of the SD
card that is used by the de1‐soc. Partition 3 is a custom partition with type 0xA2. It is required by the boot ROM, which will identify it from the MBR and load the Preloader from the beginning of it.
Fig. 43: SD card organization
Table 8 summarizes the information that is stored on the SD card and how each file is generated: Table 8: Organization of the partitions in the SD card.
Location File System
File Name Description Source of File
Partition 1 FAT32 soc_system.dtb Device Tree Blob file Build with sopc2dts utility Partition 1 FAT32 soc_system.rbf Compressed FPGA
configuration file
Build with quartus, convert .sof to .rbf
Partition 1 FAT32 u-boot.scr U-boot script for configuring FPGA
Build with boot.script and mkimage utility
Partition 1 FAT32 zImage Compressed Linux kernel image file
Generated by Buildroot with make linux-build
Partition 2 EXT3 various Linux root filesystem Generated by Buildroot with make Partition 3 A2 raw preloader-
mkpimage.bin
Preloader image Generated with SoC EDS BSP Editor based on Quartus handoff information Partition 3 A2 raw u-boot.img U-boot image Generated by buildroot with make
uboot-build
The Altera Golden Software Reference Design (GSRD) includes a Python script that can be used to create a bootable SD card image from the items mentioned in the table above. The script is named make_sdimage.py and is available also at [4]. In order to obtain more information about the script and its use, 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
When building the files using the tool flows, use the Table 9 to help locate the files after the build completes. It can be helpful to copy all the required files to a sdcard directory along with the make_sdimage.py script and run the script from that sdcard directory. The names used in the table match those in the cyclonevbsp project and the example usage of the script shown below the table. Note that the file names listed in the table are links to the build output target files. You will need to follow the links to their target destination file and copy that file to the sdcard directory. The target file names include one or more of the following suffixes: machine name, version number, date/timestamp. The make_sdimage.py script does not support the use of links when specifying the filenames.
Table 9: List of files needed to build the SD card
Item Source File Location Copy to sdcard
directory as
Preloader image Quartus EDS ./cyclonevbsp/software/spl_bsp/preloader- mkpimage.bin* preloader- mkpimage.bin Compressed FPGA configuration file
./cyclonevbsp /output_files/soc_system.rbf soc_system.rbf
Device Tree Blob file ./cyclonevbsp /soc_system.dtb soc_system.dtb U-boot script for
configuring FPGA
./cyclonevbsp /u-boot.scr u-boot.scr
U-boot image Buildroot .<builroot>/output/images/ u-boot.img Compressed Linux
kernel image file
.<builroot>/output/images/ zImage
Linux root filesystem .<builroot>/output/images/ extract to rootfs.tar (see below)
10. How to extract the rootfs.tar. In the sdcard folder
$ mkdir rootfs $ cd rootfs
So far, some of these files have been created: soc_system.rbf, soc_system.dtb, preloader_mkpimage.bin and u‐boot.src. Later, in the following chapters, the method for creating the rest of the files will be described. So, for the time being just, download the prebuilt binaries (zImage, u‐boot.img and rootfs.tar) from this link [4]. 11. Assemble the rebuilt binaries according to the table above. 12. Call the make_sdimage.py script: $ sudo /usr/bin/python/make_sdimage.py \ -f \ -P preloader-mkpimage.bin,u-boot.img,num=3,format=raw,size=10M,type=A2 \ -P rootfs/*,num=2,format=ext3,size=1200M \ -P zImage,u-boot.scr,soc_system.rbf,soc_system.dtb,num=1,format=vfat,size=300M \ -s 1700M \ -n de1soc-sd-card.img
3.8.5 Copying the image to the SD Card (Linux Host)
Determine the device name by running the command below before and after plugging in the SD card reader into the host.
$ cat /proc/partitions
The device name can also be identified using a GUI utility on your Linux host such as gnome‐disks. Next, clone the image to the SD card
$ sudo dd if=de1soc-sd-card.img of=/dev/sdx bs=1M
Replace "sdx" with the device name of the SD card on your host system. After the clone command finishes, flush the file system buffers:
$ sudo sync