customizing your build for specific hardware - ArrowElectronics/arrow-soc-workshops GitHub Wiki

So far, all you have done is quickly built an image suitable for emulation only. This section shows you how to customize your build for specific hardware by adding a hardware layer into the Yocto Project development environment. The meta-altera hardware layer that we will use natively supports the Arrow SoCKit and Terasic DE10-nano. It does not have native support for the DataStorm DAQ. If you only have access to a DataStorm DAQ then skip to the section Create a Custom Board Layer

In general, layers are repositories that contain related sets of instructions and configurations that tell the Yocto Project what to do. Isolating related metadata into functionally specific layers facilitates modular development and makes it easier to reuse the layer metadata.

Note: By convention, layer names start with the string "meta-".

Clone the hardware Layer

We will use "meta-altera" as the hardware layer. Use Git to make a local copy of the hardware layer on your machine. You can put the copy in the top level of the Poky repository created earlier. cd back to the poky directory and then add the meta-altera layer.

 $ cd ../
 $ git clone -b dunfell https://github.com/arrow-socfpga/meta-altera.git

The hardware layer now exists with other layers inside the Poky reference repository on your build host as meta-altera and contains all the metadata needed to support hardware from Altera, which is owned by Intel.

Change the Configuration to Build for a Specific Machine

The MACHINE variable in the build/conf/local.conf file specifies the machine for the build. The default MACHINE variable was set to qemu. For this example, set the MACHINE variable to "cyclone5".

  1. Open the build/conf/local.conf file in the default editor, gedit
  2. Navigate to the line MACHINE ??= "qemux86". Add a # to the beginning of the line to comment it out.
  3. Insert the following on the next line. MACHINE ?= "cyclone5"

Change the Configuration to Build for a Specific Linux Kernel

Continuing with the build/conf/local.conf file.

  1. Insert the following line to define the Linux Kernel provider. PREFERRED_PROVIDER_virtual/kernel ?= "linux-altera-ltsi"
  2. Insert the following line to define the Linux Kernel version. PREFERRED_VERSION_linux-altera-ltsi ?= "4.14.130%"

Change the Configuration to set the number of Processor Threads

If your build machine has at least 8GB of DRAM then it is advisable to specify the number of threads = 8, otherwise use 4. This specifies how many build processes can be managed in parallel and can shorten build times. If your machine has many processor cores and an extreme amount of DRAM (eg. 64GB) then a value of 32 is reasonable.

Continuing with the build/conf/local.conf file.

  1. Insert the following line to define the number of build threads. BB_NUMBER_THREADS = "8"
  2. Save the file

Modify the Kernel repository location

Modify the linux include file to utilize the arrow-socfpga linux repository

  1. Open the meta-altera/recipes-kernel/linux/linux-altera.inc file in the default editor, gedit
  2. Modify line 3. KERNEL_REPO ?= "git://github.com/arrow-socfpga/linux-socfpga.git"

Add Your Layer to the Layer Configuration File

Before you can use a layer during a build, you must add it to your bblayers.conf file, which is found in the Build Directory's conf directory.

Use the bitbake-layers add-layer command to add the layer to the configuration file:

 $ cd build
 $ bitbake-layers add-layer ../meta-altera

Modify the configuration to target a Development kit.

The following section is optional if you have the SoCKit or DE10-nano development kit. It will take a few hours to build. Alternatively, you can read through the remainder of this text without building or skip directly to Create a Custom Board Layer

The cyclone5 configuration file supports builds for a number of different Cyclone V SoC Development kits including the Arrow SoCKit and Terasic DE10-nano. The build defaults to the Intel Cyclone V SoC Development kit. Modify this file to target the SoCKit or DE10-nano.

  1. Open the meta-altera/conf/machine/cyclone5.conf file in the default editor, gedit

  2. Line 7 by default builds uboot for the Intel Cyclone V SoC Development kit. Modify this line to select the sockit defconfig or de10-nano defconfig for the uboot build.

     UBOOT_CONFIG ??= "sockit"
    
                or
    
     UBOOT_CONFIG ??= "de10-nano-soc"
    
  3. Line 28 by default builds a Linux devicetree for the Intel Cyclone V SoC Development kit. Modify this line to select the SoCKit or DE10-nano.

     UBOOT_EXTLINUX_FDT_default ?= "../socfpga_cyclone5_sockit.dtb" 
    
                                or
    
     UBOOT_EXTLINUX_FDT_default ?= "../socfpga_cyclone5_de0_nano_soc.dtb"
    

Note: The de10-nano devicetree does not exist in standard Linux distribution. However, the de0 devicetree will work.

  1. Save the file

Rebuild

Repeat the build. This will incrementally build portions of code specific to the cyclone5 MACHINE and the Linux version selected. This build will also take a significant amount of time since it has to rebuild targetting an ARM processor and not an x86 architecture as was done previously.

    $ bitbake core-image-minimal

Copy the Linux image to a micro SD card.

Yocto builds a complete SD card image, including formatting for binary, FAT, and Linux partitions.

Insert a micro SD card (at least 4GB) into a USB adaptor. Determine the device associated with the SD card on the host. Run the command below before and after inserting the SD card adaptor into a USB slot. The new drive letter will show up as /dev/sdX/ where 'X' represents the actual letter (a,b,c,d etc).

    $cat /proc/partitions

Use the dd utility to write the yocto image to the SD card.

Exercise caution: dd targeted at an incorrect drive letter can brick your computer!

    $ sudo dd if=tmp/deploy/images/cyclone5/core-image-minimal-cyclone5.wic of=/dev/sdX bs=1M seek=0
    $ sudo sync

Eject the mounted drive before removing the SD card media.

Connect to the target terminal

Using the SoCKit board

  • Set the jumpers to the positions shown in the image below.
  • A wired Mini-USB serial port connection between the host PC and the embedded target is required. (1)
  • Plugin the SoCKit DC power supply. Press the Red power button. (2)
  • Launch a Linux terminal (like Minicom,Tera Term VT or Putty) and connect using serial port
  • Select 115200 baud
  • Select the appropriate target COM port

Using the DE10-Nano board

  • Set the jumpers to the positions shown in the diagram.
  • A wired Mini-USB serial port connection between the host PC and the embedded target is required. (1)
  • Plugin the DE10-Nano DC power supply. (2)
  • Launch a Linux terminal (like Minicom,Tera Term VT or Putty) and connect using serial port
  • Select 115200 baud
  • Select the appropriate target COM port

Boot the Linux image on either board

  • Plugin the SD card. (3)
  • Press the Warm Reset button to begin the boot. (4)

This order of operation is useful if the reader wishes to see the complete boot from Power On, including the bootloader. The boot will halt at the Linux login. Use root as the login.

Note that this is a very limited build purely created to familiarize the reader with the process required to create and run a bootable image on actual hardware. It does not support access to peripherals created in the FPGA since the FPGA is not configured and the Linux devicetree only references hardware located in the HPS section of the Cyclone V SoC FPGA. In the next section, the reader will learn what constitutes a custom board BSP and how to create the individual items required.

Next - Create a Custom Board Layer

Return to - Getting Started

Return to - Building a Custom Linux BSP for SoC FPGA Systems Using the Yocto Project

⚠️ **GitHub.com Fallback** ⚠️