Introduction

This page presents the instructions on how to rebuild Linux by using the Yocto Source Package.

The Yocto Source package is an installer file provided by Altera that contains the Yocto build system, Yocto recipes and also the necessary dependencies to compile the Altera Linux bootloader, kernel and root filesystem.

For more details about Yocto see GSRD v13.1 - Yocto User Manual.

Host Setup

The Altera Linux Yocto Source package was tested to build correctly with CentOS 6.3 and Ubuntu 12.04. It may also work with other distributions. For a list of distributions against which Yocto project was tested see https://wiki.yoctoproject.org/wiki/Distribution_Support. This section presents the packages that need to be installed on the host PC to allow the Yocto Source Package to be built. Since each machine may have been installed in a different way, the packages listed here are not an exhaustive list. Add packages as necessary if you encounter issues.

CentOS 6.3

These are the required packages that need to be installed:
$ sudo yum update
$ sudo yum groupinstall "Development Tools"
$ sudo yum install texi2html texinfo glibc-devel chrpath

If the host machine runs the 64bit version of the OS, then the following additional packages need to be installed:
$ sudo yum install glibc.i686 libgcc.i686 libstdc++.i686 glibc-devel.i686 ncurses-libs.i686 zlib.i686 

Ubuntu 12.04

These are the required packages that need to be installed:
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install sed wget cvs subversion git-core coreutils unzip texi2html  texinfo libsdl1.2-dev docbook-utils gawk python-pysqlite2 diffstat help2man  make gcc build-essential g++ desktop-file-utils chrpath libgl1-mesa-dev  libglu1-mesa-dev mercurial autoconf automake groff libtool xterm

If the host machine runs the 64bit version of the OS, then the following additional packages need to be installed:
$ sudo apt-get install ia32-libs

SoC EDS

The Altera SoC EDS needs to also be installed.

SoC EDS provides the following:
  • Preloader Generator
  • Device Tree Generator

The SoC EDS can be obtained from https://www.altera.com/download/software/soc-eds.

Obtaining Yocto Source Package

The Altera Yocto Source Package can be downloaded from https://releases.rocketboards.org/2013.11/gsrd.
$ wget https://releases.rocketboards.org/2013.11/gsrd/src/linux-socfpga-gsrd-13.1-src.bsx

Setting Up Yocto

First step is to make sure the source package can be executed. Run the following command to achieve this:
$ chmod +x linux-socfpga-gsrd-13.1-src.bsx

The Yocto Source Package may be installed in a publicly accessible location, as this step can be shared by all the users on the system (or on the filesystem if your company uses a network share). The default location is /opt/altera-linux. If you wish to use this location, you will likely need root access in order to access this directory. This is why the command shown below is ran using sudo.
$ sudo ./linux-socfpga-gsrd-13.1-src.bsx

The next step is to install a local set of Yocto recipes. This could be done in a shared location, but if someone wants or needs to modify them they should have their own version. The default install location for this is within your home directory:
$ /opt/altera-linux/bin/install_altera_socfpga_src.sh ~/yocto

Last step is to create a build directory. By keeping this separate from your yocto source you can erase your entire build without fear of deleting your yocto sources. Also, you can have several build directories, each with its own configuration, all based on the same yocto source. The script serves 2 purposes. First, it creates the new build directory using Altera’s default configuration. Secondly, it sets some shell variables that are required for building.
$ source ~/yocto/altera-init ~/yocto/build

Note: If you start a new shell you will need to run the above command to set the shell variables again.

Building U-Boot/Kernel/Rootfs

In order to build u-boot from within the build directory you need to execute this command:
$ bitbake virtual/bootloader

or the equivalent:
$ bitbake u-boot

In order to build linux from within the build directory:
$ bitbake virtual/kernel

In order to build the GSRD root filesystem:
$ bitbake altera-gsrd-image

In order to build a minimal root filesystem, to be used, for example, when booting from QSPI:
$ bitbake altera-image-minimal

The first time you build the Yocto Source Package it may take up to several hours depending on your host machine.

Once finished, all images should be generated in ~/build/tmp/deploy/images. Some of the most important files created are:
File Description
u-boot-socfpga_cyclone5 U-Boot ELF file
u-boot-socfpga_cyclone5.bin U-Boot binary file
u-boot-socfpga_cyclone5.img U-Boot image
vmlinux Kernel ELF file
zImage Compressed kernel image
altera-gsrd-image-socfpga_cyclone5.cpio Root Filesystem in cpio archive format
altera-gsrd-image-socfpga_cyclone5.ext3 Root Filesystem as ext3 image
altera-image-socfpga_cyclone5.jffs2 Root Filesystem as jffs2 image
altera-gsrd-image-socfpga_cyclone5.tar.gz Root Filesystem in tar gzip archive format
The above files are actually links to the actual build resulted files. Each build file has a timestamp attached to its name and each time it it rebuilt, Yocto updates the link to point to the latest file.

Targetting Arria V

By default, the Yocto source package is set up to build the Cyclone V versions of files. Some of the created files, as described above, will have the _cyclone5 suffix.

The files built for the Cyclone V boards will also work for the Arria V boards, with the only caveat that the U-Boot banner and prompt messages will display the incorrect board name.

Note Please update the file in your /meta-altera/conf/machine/socfpga_arria5.conf, replacing
KERNEL_IMAGETYPE = "uImage"

to

KERNEL_IMAGETYPE = "zImage"

before starting the build.

There are two options for configuring Yocto to build the Arria V versions:

Option #1. Modify the file /opt/altera-linux/meta-altera/conf/local.conf.sampleto replace
MACHINE ??= "socfpga_cyclone5"

with
MACHINE ??= "socfpga_arria5"

before (re)running the source ~/yocto/altera-init ~/yocto/build.

Option #2. Modify the file ~/yocto/build/conf/local.confto replace
MACHINE ??= "socfpga_cyclone5"

with
MACHINE ??= "socfpga_arria5"

after running the source ~/yocto/altera-init ~/yocto/build.

Note that the above assume you have used the default paths for setting up the Yocto source package. Update accordingly if you are using different paths.

Some of the most important generated files are:

File Description
u-boot-socfpga_arria5 U-Boot ELF file
u-boot-socfpga_arria5.bin U-Boot binary file
u-boot-socfpga_arria5.img U-Boot image
vmlinux Kernel ELF file
zImage Compressed kernel image
altera-gsrd-image-socfpga_arria5.cpio Root Filesystem in cpio archive format
altera-gsrd-image-socfpga_arria5.ext3 Root Filesystem as ext3 image
altera-image-socfpga_arria5.jffs2 Root Filesystem as jffs2 image
altera-gsrd-image-socfpga_arria5.tar.gz Root Filesystem in tar gzip archive format

Build Toolchain

The Yocto Source Package installer also includes the Linaro toolchain. This is installed by default in /opt/altera-linux/linaro/.

See the following settings in ~/yocto/build/conf/site.conf:
TCLIBC = "external-linaro-toolchain"
TCMODE = "external-linaro"
EXTERNAL_TOOLCHAIN = "/opt/altera-linux/linaro/gcc-linaro-arm-linux-gnueabihf-4.7-2012.11-20121123_linux"

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

Privacy Policy - Terms Of Use

This website is using cookies. More info. That's Fine