This article describes how to create a script file
"U-Boot Script" that can be used when using U-Boot with Altera® ( Intel® ) SoC FPGAs.
Introduction
The U-Boot script is a text file that describes the U-Boot commands as one command per line, with header information added. This script file, named u-boot.scr, can be stored in the primary partition (FAT) of the boot SD card to register a set of commands to be executed by U-Boot at boot time.
Point: This cannot be used in environments that do not use a FAT partition, such as QSPI boot.
The work procedure is described below.
Step 1: Write a script in a text file
Create a text file describing the U-Boot command. The file name can be anything.
The following contents are applied in the reference environment for SD card boot of Cyclone® V SoC / Arria® V SoC (e.g. u-boot.txt).
fatload mmc 0:1 $fpgadata soc_system.rbf; fpga load 0 $fpgadata $filesize; run bridge_enable_handoff; run mmcload;
run mmcboot;
Key point: The first two lines execute the FPGA configuration, the third line enables the HPS-FPGA bridge, and the third line instructs the later to load (mmcload) and boot (mmcboot) the software.
Note that the U-Boot script is not used in the Arria® 10 SoC reference environment. Please note that the above example is for the V series SoC. It is possible to use the U-Boot script by preparing u-boot.scr in the same way.
Step 2: Conversion to a script file (with mkimage header)
Complete the U-Boot script (u-boot.scr) by adding header information to u-boot.txt.
Start Embedded Command Shell, move to the directory where u-boot.txt is saved, and then execute the following command.
$ mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "My script" -d u-boot.txt u-boot.scr
Step 3: Store the script file on the SD card for boot
The work is complete when the created script file (u-boot.scr) is stored in the boot SD card.
This can be done by manipulating the file on a GUI window such as Windows Explorer.
If you are working on the Linux command line, refer to the following example.
# mkdir -p sdcard # mount /dev/mmcblk0p1 sdcard # cp u-boot.scr sdcard/ # umount sdcard
Summary
The advantage of the U-Boot script is that the boot behavior can be changed by simply replacing files without having to customize or rebuild the U-Boot source code. For example, by writing commands for memory access, it is possible to use them to rewrite the setting values of registers and data in RAM before launching the software at a later stage.
Understanding how to use the U-Boot command will broaden the scope of script usage, so we recommend that you refer to the list of U-boot commands (help command) and try executing the various commands.
The following article also provides examples of how to use the U-Boot command.
Reference: How to perform a simple Ethernet test with U-Boot