Sunteți pe pagina 1din 11

ALARIC Instant-DevKit

ARRIA 10 FPGA FMC IDK

1.6. Build flow


1.6.1. Build flow introduction

In this chapter we will see how to build the different software components that have been programmed in previous chapter. It
is important to mention that all this chapter concerns is applicable only on Linux.

As the Alaric devkit is based on the Arria 10 SoC also used on the Altera Arria 10 SoC Board, we use Altera tools customized
for our own needs to build these elements. All the Altera documentation regarding their SoC boards (based on Cyclone V,
Arria V and Arria 10) can be found on the rocketboards website at the following address:
http://rocketboards.org/foswiki/view/Documentation/WebHome.

The Altera build flow is summarized by the following picture:

Figure 2: Global build flow

What we can point out here among other things about this build system is:

- It uses Quartus output files as input files: handoff folder, SOF file and sopcinfo file.

ReFLEX CES Europe ReFLEX CES NorthAmerica / AsiaPac / Japan


Phone: +33(0) 169 870 255 Phone: +1 (408) 887 5981
Email : sales@reflexces.com Email : salesusa@reflexces.com
Web: www.reflexces.com Web: www.reflexces.com 20
Support: https://support.reflexces.com Rev 1.0 Support: https://support.reflexces.com
ALARIC Instant-DevKit
ARRIA 10 FPGA FMC IDK

- It uses several tools provide by SoC EDS: the bootloader generator (named bsp-editor), the Linux device tree
generator, the Linux device tree compiler (dtc).

- It uses git repository for Linux kernel source code.

1.6.2. U-Boot build

1.6.2.1. Altera devkit vs Alaric devkit build flow


The Altera U-Boot build flow is:

Figure 3: U-Boot build flow

We use this mechanism that we have customized regarding the source of the U-Boot source code. Indeed, the U-Boot Makefile
generated by the Bootloader Generator uses as U-Boot source code the archive provided by the SoC EDS installation and
located in <SoC_EDS_Root_Path>/altera/15.0/embedded/host_tools/altera/bootloaders/u-boot/uboot-socfpga.tar.gz. The
makefile extract the archive then compile the source code. This cannot be used in our case because it prevent any modification
of the source code to handle our Alaric devkit hardware. Consequently we change the source of the U-Boot source code to use
a git repository provided by Altera as it is for the Linux Kernel source. This way we can modify U-Boot source code to match
our hardware and compile it using a custom Makefile.

1.6.2.2. Handoff folder

The U-Boot build input is the handoff folder of the picture located on the USB key in <USB_Key>/HPS/U-
Boot/src/hps_isw_handoff. It contains the emif.xml file providing RAM timing to set in U-BOOT DDR configuration and
hps.xml that result of the HPS instanciation in QSYS. This later provides the I/O pin muxing and indicates especially which
I/O are shared between the FPGA and which I/O are dedicated to FPGA and HPS. There are 17 pins dedicated to HPS and
concerned only some specific devices. 48 pins are shared with FPGA and organized in 4 blocks of 12 pins. Each block can be
assigned to FPGA or HPS. The following figure describes this I/O configuration:

ReFLEX CES Europe ReFLEX CES NorthAmerica / AsiaPac / Japan


Phone: +33(0) 169 870 255 Phone: +1 (408) 887 5981
Email : sales@reflexces.com Email : salesusa@reflexces.com
Web: www.reflexces.com Web: www.reflexces.com 21
Support: https://support.reflexces.com Rev 1.0 Support: https://support.reflexces.com
ALARIC Instant-DevKit
ARRIA 10 FPGA FMC IDK

Figure 4: I/O configuration

ReFLEX CES Europe ReFLEX CES NorthAmerica / AsiaPac / Japan


Phone: +33(0) 169 870 255 Phone: +1 (408) 887 5981
Email : sales@reflexces.com Email : salesusa@reflexces.com
Web: www.reflexces.com Web: www.reflexces.com 22
Support: https://support.reflexces.com Rev 1.0 Support: https://support.reflexces.com
ALARIC Instant-DevKit
ARRIA 10 FPGA FMC IDK

1.6.2.3. Git repository


The U-Boot source code git repository is provided by Altera and can be found on rocketboards website at the following
address: https://github.com/altera-opensource/u-boot-socfpga. We use the head of the socfpga_v2014.10_arria10_bringup
branch that corresponds at development time to the commit 3f9fc625524d79e2746d50935026ff12a9bde5be.

1.6.2.4. Source code modifications


To adapt Altera U-Boot source code to our hardware platform, we modify the following sources files:

- arch/arm/cpu/armv7/socfpga_arria10/sdram.c: contains modification for malloc size and start address depending on
the RXC_CONFIG choosen in the configuration file socfpga_arria10.h. And modification to bypass code getting RBF
file from QSPI because we do not configure the FPGA from HPS boot and as shown in QSPI mapping, we do not
store RBF file in QSPI NOR flash.

- arch/arm/include/asm/arch-socfpga_arria10/sdram.h: contains DDR timing modifications.

- include/configs/socfpga_arria10.h : U-Boot configuration file for Alaric devkit. The main modifications are:

Add RXC_CONFIG_BOOT_XXX to choose boot device configuration


Use of EMAC1 controller.
Add NFS support
Use of UART0 controller

1.6.2.5. Bsp-editor
Bsp-editor is the name of the bootloader generator. From the handoff folder files it generates all files needed to build U-Boot
binary and its device tree: device tree source file, configuration file, Makefile and a useful initialization boot script for ARM
DS-5.

1.6.2.6. Build U-Boot and its device tree

Now that we have introduced all the build components, here is the procedure to build our U-Boot image:

1) Download U-Boot source files from git repository executing the following commands in a terminal:

git clone http://git.rocketboards.org/u-boot-socfpga.git uboot-src


cd uboot-src
git checkout -b my_dev_branch origin/socfpga_v2014.10_arria10_bringup

2) Open your profile file ~/.profile file and append the following variable definition:

export UBOOT_SRC_DIR="$HOME/uboot-src" where you need to replace $HOME/uboot-src by the real path of the
folder uboot-src.

Then apply the modification with the command source ~/.profile.

3) Launch the script located in <SoC_EDS_root_path>/altera/15.0/embedded/embedded_command_shell.sh.

4) Execute the command bsp-editor to launch the bootloader generator. In the tools windows, do the following actions:

Click on File | New HPS BSP . A new window named New BSP is displayed.
In New BSP window, in the hardware section, click on the button on the right to select the handoff folder.
Then in the software section, you can leave the Use default location checkbox checked to create a folder
called uboot at the handoff folder level in which files generated by bsp-editor will be stored. Or you can click
on the BSP target directory button to select your own folder to store these files. Do not modify the BSP
settings file name.

ReFLEX CES Europe ReFLEX CES NorthAmerica / AsiaPac / Japan


Phone: +33(0) 169 870 255 Phone: +1 (408) 887 5981
Email : sales@reflexces.com Email : salesusa@reflexces.com
Web: www.reflexces.com Web: www.reflexces.com 23
Support: https://support.reflexces.com Rev 1.0 Support: https://support.reflexces.com
ALARIC Instant-DevKit
ARRIA 10 FPGA FMC IDK

Then click on the OK button to validate your choice and again on the OK button asking for your
confirmation to overwrite BSP directory. Then this new window should be displayed:

ReFLEX CES Europe ReFLEX CES NorthAmerica / AsiaPac / Japan


Phone: +33(0) 169 870 255 Phone: +1 (408) 887 5981
Email : sales@reflexces.com Email : salesusa@reflexces.com
Web: www.reflexces.com Web: www.reflexces.com 24
Support: https://support.reflexces.com Rev 1.0 Support: https://support.reflexces.com
ALARIC Instant-DevKit
ARRIA 10 FPGA FMC IDK

In this window, click on the boot device list box and choose boot from QSPI

Then click on the Generate button at the bottom of the window

Then click on the Exit button at the bottom of the window

Now you should see in the BSP target directory 4 generated files:

config.mk: a configuration file

devicetree.dts: U-Boot device tree source file

Makefile: Makefile to build U-Boot

uboot.ds: script for ARM DS-5 that allows to copy U-Boot directly on on-chip RAM through JTAG. Very
useful during U-Boot development.

As explained before, this Makefile need to be changed to compile the source code in the uboot-src folder.

5) Replace the BSP target directory Makefile by the Makefile of the USB located in <USB_Key>/HPS/U-Boot/src.

6) In the terminal, from the BSP target directory, execute the commande make to build U-Boot.

ReFLEX CES Europe ReFLEX CES NorthAmerica / AsiaPac / Japan


Phone: +33(0) 169 870 255 Phone: +1 (408) 887 5981
Email : sales@reflexces.com Email : salesusa@reflexces.com
Web: www.reflexces.com Web: www.reflexces.com 25
Support: https://support.reflexces.com Rev 1.0 Support: https://support.reflexces.com
ALARIC Instant-DevKit
ARRIA 10 FPGA FMC IDK

- It creates a symbolic link uboot-socfpga that points to the uboot-src folder then compile source code to create the
uboot_w_dtb-mkpimage.bin file.

Note:
- The toolchain used to cross-compile U-Boot is part of SoC EDS installation. It is set in the Makefile.

- To clean the build, execute the make clean command.

- To clean only the source code tree, execute the make clean-uboot command.

- An automatic script will be soon available to help executing this procedure.

1.6.2.7. U-Boot restrictions

U-Boot binary should be loaded by BootROM in OCRAM. OCRAM size is only 256 KB. Here is the U-Boot mapping in
OCRAM with the configuration CONFIG_DESIGNWARE_ETH enabled:

0xFFE4 0000
PAGE TABLE 16 Ko

0xFFE3 C000
STACK 20 Ko

0xFFE3 7000

MALLOC 35 Ko

0xFFE2 E400

Board Info Structure 80 octets

0xFFE2 E3B0

Global Data Structure 160 octets

0xFFE2 E310

IRQ STACK 1 Ko

0xFFE2 DF10

FIQ STACK 1 Ko

0xFFE2 DB10

UBOOT CODE 182 Ko

0xFFE0 0000

ReFLEX CES Europe ReFLEX CES NorthAmerica / AsiaPac / Japan


Phone: +33(0) 169 870 255 Phone: +1 (408) 887 5981
Email : sales@reflexces.com Email : salesusa@reflexces.com
Web: www.reflexces.com Web: www.reflexces.com 26
Support: https://support.reflexces.com Rev 1.0 Support: https://support.reflexces.com
ALARIC Instant-DevKit
ARRIA 10 FPGA FMC IDK

The U-Boot mapping in OCRAM without the configuration CONFIG_DESIGNWARE_ETH is:

0xFFE4 0000
PAGE TABLE 16 Ko

0xFFE3 C000

STACK 20 Ko

0xFFE3 7000

MALLOC 16 Ko

0xFFE3 3000

Board Info Structure 80 octets

0xFFE3 2FB0

Global Data Structure 160 octets

0xFFE3 2F10

IRQ STACK 1 Ko

0xFFE3 DB10

FIQ STACK 1 Ko

0xFFE3 2710

UBOOT CODE 201 Ko

0xFFE0 0000

As we can see the size for the U-Boot code is limited. The important consequence is that we can not have all device supported
in a same binary. More precisely, it is not possible to have support for Ethernet (CONFIG_ DESIGNWARE_ETH), SD/MMC
(CONFIG_MMC) and QSPI device (CONFIG_CADENCE_QSPI) in the same time without removing all U-Boot commands.
That is why by default we add Ethernet and QSPI support in U-Boot to be able to load Kernel stored in QSPI or over network
but not SD/MMC.

1.6.3. Kernel build

1.6.3.1. Kernel image


As shown in the global build flow, the Linux kernel source code is retrieved from git repository. As for U-boot repository,
Linux repository can be found on rocketboards website at the following address: https://github.com/altera-opensource/linux-
socfpga. We use the head of the test_branch rel_socfpga-3.10-ltsi_arria10_bringup_gsrd_ies p branch that corresponds at
development time to the commit 512a3b04906cb51bb65850a91c5cbdfe00aae8bb.

To build the zImage file, we will have to copy our own configuration file at the right path then launch the build command.
Here is the procedure:

ReFLEX CES Europe ReFLEX CES NorthAmerica / AsiaPac / Japan


Phone: +33(0) 169 870 255 Phone: +1 (408) 887 5981
Email : sales@reflexces.com Email : salesusa@reflexces.com
Web: www.reflexces.com Web: www.reflexces.com 27
Support: https://support.reflexces.com Rev 1.0 Support: https://support.reflexces.com
ALARIC Instant-DevKit
ARRIA 10 FPGA FMC IDK

1) To build the kernel on our PC for the Alaric devkit, we could use the SoC EDS toolchain like for U-Boot build, but
we can also use an external toolchain, what could be useful in any case to be Altera tool independant. A Linaro
toolchain can be a good choice, they can be download at the following address: https://launchpad.net/linaro-toolchain-
binaries/trunk/. To install for example the 2012.11 version in your home directory, execute the following commands
in a terminal:

cd ~
wget https://launchpad.net/linaro-toolchain-binaries/trunk/2012.11/+download/gcc-linaro-arm-linux-gnueabihf-4.7-
2012.11-20121123_linux.tar.bz2
tar xjf gcc-linaro-arm-linux-gnueabihf-4.7-2012.11-20121123_linux.tar.bz2

To use it to compile Alaric devkit software, we need to export CROSS_COMPILE and ARCH variables in our profile
file to not have to set them as parameters for each make command. So open ~/.profile and append the following lines:

export CROSS_COMPILE="$HOME/gcc-linaro-arm-linux-gnueabihf-4.7-2012.11-20121123_linux/bin/arm-linux-
gnueabihf-"
export ARCH=arm

Then apply modifications with the command source ~/.profile.

2) Download kernel source files from git repository executing the following commands :

git clone https://github.com/altera-opensource/linux-socfpga.git linux-src


cd linux-src
git checkout -b test_branch rel_socfpga-3.10-ltsi_arria10_bringup_gsrd_ies

3) Open again your profile file ~/.profile and append the following variable definition:

export UBOOT_SRC_DIR="$HOME/uboot-src" where you need to replace $HOME/uboot-src by the real path of the
folder uboot-src.

Then apply the modification with the command source ~/.profile

4) Copy the socfpga_rxc_defconfig file located in <USB_Key>/HPS/Kernel/src in linux-src/arch/arm/configs.

5) Go to the uboot-src folder and launch the following commands:

make socfpga_rxc_defconfig
make zImage

The zImage is created in the arch/arm/boot folder.

Note: To clean everything, use the make mrproper command.

1.6.3.2. Kernel device tree


The following procedure allow to genenerate AlaricLinuxDT.dtb:

1) Open a terminal and launch the script located in


<SoC_EDS_root_path>/altera/15.0/embedded/embedded_command_shell.sh.

2) To generate first the device tree source AlaricLinuDT.dts, execute the following command:

sopc2dts --input hps.sopcinfo --output AlaricLinuxDT.dts --board hps_a10_common_board_info.xml --board


hps_a10_devkit_board_info.xml --board ghrd_10as066h2es_board_info.xml --bridge-removal all clocks

3) Then to generate the binary file, execute the following command:

ReFLEX CES Europe ReFLEX CES NorthAmerica / AsiaPac / Japan


Phone: +33(0) 169 870 255 Phone: +1 (408) 887 5981
Email : sales@reflexces.com Email : salesusa@reflexces.com
Web: www.reflexces.com Web: www.reflexces.com 28
Support: https://support.reflexces.com Rev 1.0 Support: https://support.reflexces.com
ALARIC Instant-DevKit
ARRIA 10 FPGA FMC IDK

dtc -I dts -O dtb -o AlaricLinuxDT.dtb AlaricLinuxDT.dts

1.6.4. Root file system

A Linux build system can be used to create the root file system, this is the Altera approach for their reference kit using Yocto
(building also the kernel). Reflex CES approach is quite different. As for Alaric devkit all drivers are statically linked to the
kernel, there is no kernel modules to install in <rootfs>/lib/modules/, so the root file system is completely hardware
independent. Consequently, we decide to download an existing root file system containing a packet manager and to customize
it dynamically to fit our applicative needs.

The original root file system is a Linaro-nano 14.04 release found at the address https://releases.linaro.org/14.04/ubuntu/saucy-
images/nano/linaro-saucy-nano-20140410-652.tar.gz.

Here is the step to obtain quite the same root file system as the one delivered:

1) Extract the original root file system tar.gz file on your PC.

2) Build the SD card image following next paragraph procedure.

3) Create micro SD card following procedure described in paragraph about SD card creation, starting from point 3).

4) Boot the Alaric devkit.

5) Connect to the board using serial connection

6) Customize it like this:

Fix the packet manager sources list (can be done offline with micro SD card mounted on the PC)

Install openssh-server and configure the server

Install nano editor

Edit /etc/network/interfaces for network configuration (can be done offline with mircro SD card mounted on
the PC)

Add our HPS script tests (can be done offline with mircro SD card mounted on the PC).

1.6.5. SD card image build

To generate the sd_card_image_a10.img zipped in sd_card_image_a10.zip located in <USB_KEY>/HPS/Rootfs, here is the


procedure:

1) Mount the micro SD card in your PC

2) Copy the following binaries located in <USB_KEY>/HPS/U-Boot/bin and <USB_KEY>/HPS/Kernel/bin in a same


folder of your PC:

uboot_w_dtb-mkpimage.bin

zImage

AlaricLinuxDT.dtb

ReFLEX CES Europe ReFLEX CES NorthAmerica / AsiaPac / Japan


Phone: +33(0) 169 870 255 Phone: +1 (408) 887 5981
Email : sales@reflexces.com Email : salesusa@reflexces.com
Web: www.reflexces.com Web: www.reflexces.com 29
Support: https://support.reflexces.com Rev 1.0 Support: https://support.reflexces.com
ALARIC Instant-DevKit
ARRIA 10 FPGA FMC IDK

3) Open a terminal and in this folder, create a symbolic link called rootfs pointing to the micro SD card root file system
path

4) Copy the 2 scripts <USB_KEY>/HPS/Rootfs/make_sdimage.py and createimage.sh in this folder.

5) Execute the script createimage.sh to generate the image file.

ReFLEX CES Europe ReFLEX CES NorthAmerica / AsiaPac / Japan


Phone: +33(0) 169 870 255 Phone: +1 (408) 887 5981
Email : sales@reflexces.com Email : salesusa@reflexces.com
Web: www.reflexces.com Web: www.reflexces.com 30
Support: https://support.reflexces.com Rev 1.0 Support: https://support.reflexces.com

S-ar putea să vă placă și