WSL (Windows Subsystem for Linux) is available as a mechanism to use Linux from Windows 10.
This article introduces the procedure of building Preloader/U-boot for Arria® 10 SoC FPGA Development Board and Cyclone® V SoC FPGA Development Board using WSL.
In this article, we will explain how to build the Preloader/U-boot on WSL.
Note:
The environment settings for using WSL are as follows:
Please refer to [Part 1: Environment Setup] for the environment setup for using WSL.
1. Clone the Git tree and build Preloader / U-Boot
Reference:
The information in this chapter is based on the following page on the RocketBoards.org portal site.
Compiling Linux
Refer to the following tabs on the linked page:
3. Host Setup for Angstrom
5. Building Kernel and U-Boot Separately From Git Trees
1-1. Host setup
Follow the steps below to set up the host PC.
(1)
Install the required packages with the following commands.
$ sudo apt-get install repo sed wget cvs subversion git coreutils unzip texi2html texinfo libsdl1.2-dev docbook-utils gawk python-pysqlite2 diffstat help2 man make gcc build-essential g++ desktop-file-utils chrpath libgl1-mesa-dev libglu1-mesa-dev mercurial autoconf automake groff libtool xterm lib 32z1
Note:
The command line explained on the RocketBoards.org page "Compiling Linux - 3. Host Setup for Angstrom" produces an error, so in the above command:
・phablet-tools has been changed to repo
・git-core has been changed to git
[Figure 1] Installation of Required Packages
(2)
If the host machine is running a 64-bit version OS, additional packages must be installed by the following command.
$ sudo apt-get install lib32ncurses5 lib32z1 lib32stdc++6
Note:
Because of errors in the command line described in the RocketBoards.org page "Compiling Linux - 3. Host Setup for Angstrom", the above command will install ia32-libs as The above command changes ia32-libs to lib32ncurses5 and lib32z1.
[Figure 2] Install additional packages if the host machine is a 64-bit OS
(3)
The following command should change /bin/sh to point to bash instead of dash.
$ sudo dpkg-reconfigure dash
* Here, select <no>
$ sudo ln -sf bash /bin/sh
[Figure 3] Change /bin/sh to point to bash instead of dash
1-2. Download and Configure the build toolchain
The following command will download and configure the toolchain (compiler) used to build U-boot.
$ wget https://releases.linaro.org/archive/15.06/components/toolchain/binaries/4.8/arm-linux-gnueabihf/gcc-linaro-4.8-2015.06-x86_64_arm- linux-gnueabihf.tar.xz
$ tar -Jxvf gcc-linaro-4.8-2015.06-x86_64_arm-linux-gnueabihf.tar.xz
$ export PATH=~/gcc-linaro-4.8-2015.06-x86_64_arm-linux-gnueabihf/bin/:$PATH
$ export CROSS_COMPILE=~/gcc-linaro-4.8-2015.06-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
Note:
An error occurred during make when using the command line explained on the RocketBoards.org page “Compiling Linux - 5. Building Kernel and U-Boot Separately From Git Trees”, so in the above command, the toolchain has been changed from gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux to gcc-linaro-4.8-2015.06-x86_64_arm-linux-gnueabihf.
[Figure 4] Downloading and setting up the tool chain
1-3. Example of building Arria® 10 SoC boot loader (U-boot)
(1)
If you have a proxy, such as an internal network, you need to set up the proxy with the following command before executing git clone.
$ git config --global http.proxy http://your.proxy.address:proxy.port
Note:
In the above proxy configuration, your.proxy.address is the proxy address and
proxy.port is the proxy port number.
(2)
Clone the U-boot git tree.
$ git clone http://github.com/altera-opensource/u-boot-socfpga
$ cd u-boot-socfpga
$ git checkout socfpga_v2014.10_arria10_bringup
Note:
The example command above uses the socfpga_v2014.10_arria10_bringup branch, which supports the Arria® 10 SoC.
[Figure 5] Clone the U-boot git tree
(3)
Check if dtc (device-tree-compiler) is installed. If not, an error will occur during make if dtc is not installed.
$ which dtc
$ dtc --version
$ sudo apt install device-tree-compiler
[Figure 6] Confirmation and installation of dtc (device-tree-compiler)
(4)
Build the U-Boot for the Arria® 10 SoC.
$ make mrproper
$ make socfpga_arria10_defconfig
$ make
[Figure 7] Build U-Boot for Arria® 10 SoC
1-4. Example of building Cyclone® V SoC boot loader (Preloader / U-Boot)
(1)
If you have a proxy on your company network, you need to configure the proxy settings with the following command before executing git clone.
$ git config --global http.proxy http://your.proxy.address:proxy.port
Note:
In the above proxy configuration, your.proxy.address is the proxy address and
proxy.port is the proxy port number.
(2)
Clone the U-boot git tree.
$ git clone http://github.com/altera-opensource/u-boot-socfpga $ cd u-boot-socfpga $ git checkout socfpga_v2013.01.01
Note:
The above example command uses socfpga_v2013.01.01 branch, which is compatible with Cyclone® V SoC / Arria® V SoC.
[Figure 8] Cloning the U-Boot git tree
(3)
Build Preloader and U-Boot for Cyclone® V SoC.
$ make mrproper
$ make socfpga_cyclone5_config
$ make
Note:
If you are compiling for Arria® V SoC, replace the second command above with
make socfpga_arria5_config.
[Figure 9] Build Preloader and U-Boot for Cyclone® V SoC
Note:
The Preloader / U-Boot generated by this step can only be used with the Cyclone® V SoC Development Kit / Arria® V SoC Development Kit. To generate a Preloader / U-Boot for other boards using the same procedure, the source tree must be modified to provide board-dependent settings.
The source tree is based on other versions, but Rocketboards.org also shows how to support custom boards.
Mainline u-Boot for SoCFPGA | Rocketboards.org
2. Add mkpimage header to the generated Preloader / U-Boot
2-1. Add mkpimage header to the Arria® 10 SoC U-Boot
The generated u-boot.bin (U-boot binary file) for Arria® 10 SoC cannot be used as is..
You must add the mkpimage header using the SoC FPGA Embedded Development Suite (SoC EDS) that you have pre-installed on Windows.
(1)
From the WSL terminal, create a Windows directory (in this example, C:\Arria10_boot) and copy the generated u-boot.bin.
$ mkdir /mnt/c/Arria10_boot
$ cd u-boot-socfpga
$ cp u-boot.bin /mnt/c/Arria10_boot
[Figure 10] Create a Windows directory and copy the generated u-boot.bin
(2)
Using Windows Explorer, copy the devicetree.dtb file in the SoC EDS directory below to the Windows directory you created (in this example, C:\Arria10_boot).
| C:\intelFPGA\<version>\embedded\examples\hardware\a10_soc_devkit_ghrd\software\bootloader |
[Figure 11] Copy the devicetree.dtb file to the Windows directory
Note:
The example above is written for the Arria® 10 SoC Development Kit. For the original design, use the devicetree.dtb converted from the devicetree.dts generated by BSP-Editor by executing the following command on the SoC EDS Command Shell.
$ dtc -I dts -O dtb -o devicetree.dtb devicetree.dts
(3)
Start the SoC EDS Command Shell.
[Figure 12] Launch SoC EDS Command Shell
(4)
Execute the following command from SoC EDS Command Shell to concatenate the devicetree.dtb file with u-boot.bin to create the u-boot_w_dtb.bin file.
$ cd "C:\Arria10_boot"
$ cat u-boot.bin devicetree.dtb > u-boot_w_dtb.bin
(5)
Execute the following command to add the mkpimage header to the u-boot_w_dtb.bin file and generate the uboot_w_dtb-mkpimage.bin file.
$ mkpimage --header-version 1 -o uboot_w_dtb-mkpimage.bin u-boot_w_dtb.bin u-boot_w_dtb.bin
[Figure 13] Generating the uboot_w_dtb-mkpimage.bin file with the mkpimage header
(6)
Write the uboot_w_dtb-mkpimage.bin file to the SD card.
$ alt-boot-disk-util.exe -B uboot_w_dtb-mkpimage.bin -a write -d <SD Card drive letter>
[Figure 14] Writing the uboot_w_dtb-mkpimage.bin file to the SD card
Reference:
Please refer to the following article for details on how to write to the SD card.
How to Create SD Card Image for SoC FPGA Boot
2-2. Add mkpimage header to Cyclone® V SoC Preloader
The generated Cyclone® V SoC spl/u-boot-spl.bin (Preloader binary file) cannot be used as is.
You must add the mkpimage header using the SoC FPGA Embedded Development Suite (SoC EDS) that you have pre-installed on Windows.
(1)
From the terminal at WSL, create a Windows directory (in this example, C:\CycloneV_boot) and copy the generated u-boot.img and spl/u-boot-spl.bin.
$ mkdir /mnt/c/CycloneV_boot
$ cd u-boot-socfpga
$ cp u-boot.img /mnt/c/CycloneV_boot
$ cp spl/u-boot-spl.bin /mnt/c/CycloneV_boot
[Figure 15] Copy u-boot.img and spl/u-boot-spl.bin generated by creating a Windows directory
(2)
Start the SoC EDS Command Shell.
[Figure 16] Launch the SoC EDS Command Shell
(3)
Execute the following command from SoC EDS Command Shell to add mkpimage header to u-boot-spl.bin file and generate preloader-mkpimage.bin file.
$ cd "C:\CycloneV_boot"
$ mkpimage --header-version 0 -o preloader-mkpimage.bin u-boot-spl.bin u-boot-spl.bin u-boot-spl.bin
(4)
Write the preloader-mkpimage.bin file and the u-boot.img file to the SD card.
$ alt-boot-disk-util.exe -p preloader-mkpimage.bin -b u-boot.img -a write -d <SD Card drive letter
[Figure 17] Adding the mkpimage header and writing to the SD card
Reference:
Please refer to the following article for details on how to write to the SD card.
How to Create an SD Card Image for SoC FPGA Boot
Summary
Until now, if you wanted to use Linux on Windows, you had to install a virtual machine environment such as VirtualBox and configure various settings, but WSL makes it very easy to use Linux.
Note that while the steps described in this article successfully built Preloader and U-Boot, as of tool version v19.2, the official steps for building U-Boot for Arria® 10 SoC FPGAs require working in a Linux OS environment.
The steps described in this article are unofficial, so use WSL at your own risk.