Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Custom_table_size_100

It is possible to customize existing meta layers by creating an own meta layer with bitbake append files. In this description the meta layer meta-altera for Intel FPGA devices is used as reference.

For more informations about the OS used and the sources and versions of yocto project or meta-altera layer, see Yocto KICKstart#Used source files.

Initialize the environment

Scroll Ignore
scroll-pdftrue
scroll-officetrue
scroll-chmtrue
scroll-docbooktrue
scroll-eclipsehelptrue
scroll-epubtrue
scroll-htmltrue

Before starting to create a custom meta layer, navigate to the yocto poky directory and initialize the environment with the following commands:

Code Block
languagebash
themeMidnight
linenumberstrue
cd path/to/yocto/poky
source oe-init-build-env


Download required sources

Scroll Ignore
scroll-pdftrue
scroll-officetrue
scroll-chmtrue
scroll-docbooktrue
scroll-eclipsehelptrue
scroll-epubtrue
scroll-htmltrue

Since the created meta-custom layer should depend on meta-altera, these sources files must be downloaded and added to the yocto project.

  1. Navigate to yocto poky directory and download meta-altera layer:

    Code Block
    languagebash
    themeMidnight
    linenumberstrue
    cd path/to/yocto/poky
    git clone -b dunfell https://github.com/kraj/meta-altera.git


  2. Add meta-altera to yocto project with:

    Code Block
    languagebash
    themeMidnight
    linenumberstrue
    cd path/to/yocto/poky/build
    bitbake-layers add-layer ./meta-altera


Create

custom meta

BSP layer

Scroll Ignore
scroll-pdftrue
scroll-officetrue
scroll-chmtrue
scroll-docbooktrue
scroll-eclipsehelptrue
scroll-epubtrue
scroll-htmltrue

In this example, the created layer is named meta-custom. If you want to use a different name, just replace "custom".

  1. Create own layer "meta-custom" with:

    Code Block
    languagebash
    themeMidnight
    linenumberstrue
    bitbake-layers create-layer path/to/yocto/poky/meta-custom


  2. The created layer contains a sample recipes folder, that can be removed:

    Code Block
    languagebash
    themeMidnight
    linenumberstrue
    rm -rf path/to/yocto/poky/meta-custom/recipes-example


  3. Make meta-custom dependent on meta-altera:

    Code Block
    languagebash
    themeMidnight
    linenumberstrue
    sed -i '/LAYERDEPENDS_meta-custom/s/core/meta-altera/g' path/to/yocto/poky/meta-custom/conf/layer.conf 


  4. Add the meta-custom layer to the yocto project with:

    Code Block
    languagebash
    themeMidnight
    linenumberstrue
    bitbake-layers add-layer path/to/yocto/poky/meta-custom
Add required parameters to local.conf

Configure BSP Machine

Scroll Ignore
scroll-pdftrue
scroll-officetrue
scroll-chmtrue
scroll-docbooktrue
scroll-eclipsehelptrue
scroll-epubtrue
scroll-htmltrue
First the variable "MACHINE" must be redefined in the local.conf file. Several machines are defined

In the machine configuration file, you can store general settings for the custom BSP layer, such as the version of u-boot or the linux kernel. Here, we will use the cyclone5 machine configuration file from the meta-altera layer as a template. For other machine configurations in the meta-altera layer

(

, see meta-altera/conf/machine.

  1. Download the cyclone5 machine configuration file to the meta-custom layer and rename it

  2. for more information). In this example, the machine 'cyclone5' is used.
    Remove the default value and add 'cyclone5'
  3. :

    Code Block
    languagebash
    themeMidnight
    linenumberstrue
  4. sed
  5. mkdir -
  6. i
  7. p 
  8. '
  9. path/to/
  10. ^MACHINE
  11. yocto/
  12. s
  13. poky/
  14. MACHINE
  15. meta-custom/
  16. #MACHINE/g'
  17. conf/machine
    cd path/to/yocto/poky/
  18. build
  19. meta-custom/conf/
  20. local.conf
  21. machine
    
  22. echo -e '\nMACHINE = "cyclone5"' >> path/to/yocto/poky/build/conf/local.confFor the linux kernel in the meta-altera layer it's required to define a the preferred provider and version in local.conf (see meta-altera/recipes-kernel/linux for other linux kernel versions)
  23. wget https://github.com/kraj/meta-altera/raw/dunfell/conf/machine/cyclone5.conf
    mv cyclone5.conf custom.conf


  24. Make the following changes to the content of custom.conf:
    1. Change the name in line 2 from 'cyclone5' to 'custom' and customize the variables UBOOT_EXTLINUX_DEFAULT_LABEL and UBOOT_EXTLINUX_MENU_DESCRIPTION_default:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
  25. echo
    1. sed -
  26. e
    1. i '
  27. \nPREFERRED_PROVIDER_virtual/kernel = "linux-altera-lts"' >>
    1. /^#@NAME:/s/.*/#@NAME: custom/g' path/to/yocto/poky/
  28. build
    1. meta-custom/conf/
  29. local
    1. machine/custom.conf
      
  30. echo
    1. sed -
  31. e
    1. i '
  32. PREFERRED_VERSION_linux-altera-lts = "5.4%"' >>
    1. /^UBOOT_EXTLINUX_DEFAULT_LABEL/s/".*"/"Cyclone5 custom SDMMC"/g' path/to/yocto/poky/
  33. build
    1. meta-custom/conf/
  34. local
    1. machine/custom.conf
      
  35. Set the preferred u-boot version for meta-altera in local.conf (see meta-altera/recipes-bsp/u-boot for other u-boot versions):

    Code Block
    languagebash
    themeMidnight
    linenumberstrue
    echo -e '\nPREFERRED_VERSION_u-boot-socfpga = "v2021.04%"' >>
    1. sed -i '/^UBOOT_EXTLINUX_MENU_DESCRIPTION_default/s/".*"/"Cyclone5 custom SDMMC"/g' path/to/yocto/poky/meta-custom/conf/machine/custom.conf


    2. The KMACHINE variable defines the MACHINE name, which is referenced in the build/conf/local.conf

Create workspace

Scroll Ignore
scroll-pdftrue
scroll-officetrue
scroll-chmtrue
scroll-docbooktrue
scroll-eclipsehelptrue
scroll-epubtrue
scroll-htmltrue

The following command creates the workspace directory and adds it to bblayers.conf:

Code Blocklanguage
    1. file. Redefine KMACHINE with your own MACHINE name:

      Code Block
      language
    1. bash
      themeMidnight
      linenumberstrue
devtool
    1. sed 
create-workspace

Configure u-boot

Scroll Ignore
scroll-pdftrue
scroll-officetrue
scroll-chmtrue
scroll-docbooktrue
scroll-eclipsehelptrue
scroll-epubtrue
scroll-htmltrue
    1. -i '/^KMACHINE/s/".*"/"custom"/g' path/to/yocto/poky/meta-custom/conf/machine/custom.conf


    2. For the linux kernel in the meta-altera layer it's required to define a the preferred provider and version in custom.conf (see Yocto KICKstart#Used source files for more information about the version used). Add the provider and version for linux kernel:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      echo -e '\nPREFERRED_PROVIDER_virtual/kernel = "linux-altera-lts"' >> path/to/yocto/poky/meta-custom/conf/machine/custom.conf 
      echo -e 'PREFERRED_VERSION_linux-altera-lts = "5.4%"' >> path/to/yocto/poky/meta-custom/conf/machine/custom.conf


    3. Set the preferred u-boot version for meta-altera in custom.conf (see Yocto KICKstart#Used source files for more information about the version used)

Prepare u-boot configuration in workspace

To prepare the u-boot sources for modify the default configuration and create patches, do the following steps:

  1. It is not possible to call menuconfig if UBOOT_CONFIG is defined. But UBOOT_CONFIG is needed to assign a defconfig file to UBOOT_MACHINE. UBOOT_MACHINE must therefore be defined manually. The variable UBOOT_CONFIG is predefined in the machine configuration file for cyclone5 with the value 'cyclone5-socdk' (see meta-altera/conf/machine/cyclone5.conf). The associated defconfig file is therefore socfpga_cylcone5_defconfig (see meta-altera/recipes-bsp/u-boot/u-boot-socfpga-common.inc). Accordingly these variables must be defined in local.conf
    1. :

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      echo -e '\
    nUBOOT_MACHINE = "socfpga_cyclone5_defconfig"' >> path/to/yocto/poky/build/conf/local.conf echo -e 'UBOOT_CONFIG = "
    1. nPREFERRED_VERSION_u-boot-socfpga = "v2021.04%"' >> path/to/yocto/poky/
    build
    1. meta-custom/conf/machine/
    local
    1. custom.conf

    Run following command to prepare the workspace and fetch and unpack the sources:

    Code Block
    languagebash
    themeMidnight
    linenumberstrue
    devtool modify u-boot-socfpga -O

Configure u-boot with menuconfig

To make changes to u-boot configuration, follow these steps:

Launch menuconfig with following command and make your changes

Other variables in the custom.conf file are changed or added at other points in this guide.

Add required parameters to local.conf

Scroll Ignore

Before you start configuring the meta-custom layer, the MACHINE variable in the path/to/yocto/poky/build/conf/local.conf file must be set to the correct machine. The correct machine name is defined in the meta-custom/conf/machine/custom.conf file with the variable KMACHINE.
Remove the default value of the MACHINE variable in local.conf and add the new MACHINE 'custom':

Code Block
languagebash
themeMidnight
linenumberstrue
devtool menuconfig u-boot-socfpga
  • Exit and save your configuration. devtool-fragment.cfg will be created automatically.
  • Create patches for u-boot source files

    Do following steps to create patches for u-boot source files:

    Navigate to u-boot-socfpga in the workspace and add, modify or remove files:

    Code Block
    languagebash
    themeMidnight
    linenumberstrue
    cd path/to
    sed -i '/^MACHINE/s/MACHINE/#MACHINE/g' path/to/yocto/poky/build/
    workspace/sources/u-boot-socfpgaRun a build to test your changes
    conf/local.conf
    echo -e '\nMACHINE = "custom"' >> path/to/yocto/poky/build/conf/local.conf


    Create workspace

    Scroll Ignore

    The following command creates the workspace directory and adds it to bblayers.conf:

    Code Block
    languagebash
    themeMidnight
    linenumberstrue
    devtool 
    build
    create-workspace


    Configure u-boot

    -socfpga

    Add the changes made with:

    Code Block
    languagebash
    themeMidnight
    linenumberstrue
    git add .

    Commit your changes and add a short message. The message is used to name the patch file:

    Code Block
    languagebash
    themeMidnight
    linenumberstrue
    git commit -m "<message>"

    If you want to generate more patches, repeat steps 1 - 4, otherwise navigate back to the poky directory:

    Code Block
    languagebash
    themeMidnight
    linenumberstrue
    cd path/to/yocto/poky

    Scroll Ignore

    Prepare u-boot configuration in workspace

    To prepare the u-boot sources for modify the default configuration and create patches, do the following steps:

    1. To set the correct default defconfig file for the u-boot, it is required to set the UBOOT_MACHINE variable in the meta-custom/conf/machine/custom.conf file. The defconfig file 'socfpga_cylcone5_defconfig' will be used as default u-boot configuration (see meta-altera/recipes-bsp/u-boot/u-boot-socfpga-common.inc for other Intel fpga defconfig files). If UBOOT_MACHINE has been defined, UBOOT_CONFIG is no longer needded.
      Remove the variable UBOOT_CONFIG and add UBOOT_MACHINE to meta-custom/conf/machine/custom.conf

    Create and update u-boot recipe bbappend

    Add the devtool-fragment.cfg and the patches to the meta-custom layer with
    1. :

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
    devtool
    1. sed 
    update
    1. -
    recipe u-boot-socfpga -a
    1. i '/^UBOOT_CONFIG/d' path/to/yocto/poky/meta-custom
    -O

    Finish u-boot modification

    Remove the UBOOT_CONFIG and UBOOT_MACHINE variables from local.conf if you use the default defconfig file for the MACHINE 'cyclone5'
    1. /conf/machine/custom.conf
      echo -e '\nUBOOT_MACHINE = "socfpga_cyclone5_defconfig"' >> path/to/yocto/poky/meta-custom/conf/machine/custom.conf
      


    2. Run following command to prepare the workspace and fetch and unpack the sources:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
    sed
    1. devtool modify 
    -i '/UBOOT_MACHINE = "socfpga_cyclone5_defconfig"/d' path/to/yocto/poky/build/conf/local.conf sed -i '/UBOOT_CONFIG = ""/d' path/to/yocto/poky/build/conf/local.conf
    1. u-boot-socfpga -O


    Configure u-boot with menuconfig

    To make changes to u-boot configuration, follow these steps:

    1. Launch menuconfig with following command and make your changes:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      devtool menuconfig u-boot-socfpga


    2. Exit and save your configuration. devtool-fragment.cfg will be created automatically.

    Create patches for u-boot source files

    Do following steps to create patches for u-boot source files:

    1. Navigate to u-boot-socfpga in the workspace and add, modify or remove files

    Configure linux kernel

    Scroll Ignore
    scroll-pdftrue
    scroll-officetrue
    scroll-chmtrue
    scroll-docbooktrue
    scroll-eclipsehelptrue
    scroll-epubtrue
    scroll-htmltrue

    Prepare linux kernel configuration in workspace

    To prepare the linux kernel sources for modify the default configuration and create patches, do the following steps:

    1. Run following command to prepare the workspace and fetch and unpack the sources:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      devtool modify linux-altera-lts -O

    Configure linux kernel with menuconfig

    To make changes to linux kernel configuration, follow these steps:

    1. cd path/to/yocto/poky/build/workspace/sources/u-boot-socfpga


    2. Run a build to test Launch menuconfig with following command and make your changes:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      devtool menuconfigbuild linuxu-altera-lts
    3. Exit and save your configuration. devtool-fragment.cfg will be created automatically.

    Create patches for linux kernel source files

    Do following steps to create patches for u-boot source files:

    1. boot-socfpga


    2. Add the changes made with:

      Code Block

      Navigate to linux-altera-lts in the workspace and add, modify or remove files:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      cd path/to/yocto/poky/build/workspace/sources/linux-altera-lts
      git add .


    3. Commit your changes and add a short message. The message is used to name the patch fileRun a build to test your changes:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      devtoolgit buildcommit linux-altera-lts

      Add the changes made with:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      git add .
      -m "<message>"

      If you get the following error message: "*** Please tell me who you are. Run ...", run this commands to define a name and email

      Commit your changes and add a short message. The message is used to name the patch file

      :

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      git config --local user.email "oe.patch@oe"
      git commitconfig -m-local user.name "<message>OpenEmbedded"


    4. If you want to generate more patches, repeat step steps 1 - 4, otherwise navigate back to the poky directory:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      cd path/to/yocto/poky


    Create and update u-boot recipe bbappend

    Add the devtool-fragment.cfg and the patches to the meta-custom layer with:

    Code Block
    languagebash
    themeMidnight
    linenumberstrue
    devtool update-recipe linuxu-alteraboot-ltssocfpga -a path/to/yocto/poky/meta-custom -O
    Remove workspace


    Configure linux kernel

    Scroll Ignore
    scroll-pdftrue
    scroll-officetrue
    scroll-chmtrue
    scroll-docbooktrue
    scroll-eclipsehelptrue
    scroll-epubtrue
    scroll-htmltrue
    Remove the workspace from bblayers.conf and delete the workspace folder

    Prepare linux kernel configuration in workspace

    To prepare the linux kernel sources for modify the default configuration and create patches, do the following steps:

    1. Run following command to prepare the workspace and fetch and unpack the sources:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
    cd path/to/yocto/poky/build
    bitbake-layers remove-layer workspace
    rm -rf path/to/yocto/poky/build/workspace
    1. devtool modify linux-altera-lts -O


    Configure linux kernel with menuconfig

    To make changes to linux kernel configuration, follow these steps:

    1. Launch menuconfig with following command and make your changes:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      devtool menuconfig linux-altera-lts


    2. Exit and save your configuration. devtool-fragment.cfg will be created automatically.

    Create patches for linux kernel source files

    Do following steps to create patches for u-boot source files:

    1. Navigate to linux-altera-lts in the workspace and add, modify or remove files

    Add required files to custom meta layer

    Scroll Ignore
    scroll-pdftrue
    scroll-officetrue
    scroll-chmtrue
    scroll-docbooktrue
    scroll-eclipsehelptrue
    scroll-epubtrue
    scroll-htmltrue

    Add handoff files to u-boot

    If you create a u-boot file for an Intel Cyclone V / Arria V with quartus version 20.1 you have to convert the handoff data into source code.

    1. compile your quartus project
    2. run the embedded command shell (Intel SoC EDS):

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      ~/intelFPGA_lite/20.1/embedded/embedded_command_shell.sh
      cd path/to/yocto/poky/build/workspace/sources/linux-altera-lts


    3. Run a build to test your changesnavigate to your quartus project directory and convert the handoff data into source code:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      cd path/to/quartus/project
      mkdir -p build
      bsp-create-settings --type spl --bsp-dir build \
      --preloader-settings-dir hps_isw_handoff/soc_system_hps_0/ \
      --settings build/settings.bsp

    Next you have to run the qts_filter to take the sources from the handoff folder, format them and copy them to u-boot source code.

    1. devtool build linux-altera-lts


    2. Add the changes made with:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      git add .


    3. Commit your changes and add a short message. The message is used to name the patch fileFetch qts_filter.sh from github:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      wget https://github.com/altera-opensource/u-boot-socfpga/blob/socfpga_v2021.04/arch/arm/mach-socfpga/qts-filter.sh
      git commit -m "<message>"


    4. If you want to generate more patches, repeat step 1 - 4, otherwise navigate back to the poky directoryRun qts_filter for cyclone5 to format and copy the handoff files to custom meta layer:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      mkdir -pcd path/to/yocto/poky/meta-custom/recipes-bsp/u-boot/u-boot-socfpga/qts
      ./qts_filter.sh cyclone5 \
      				path/to/quartus/project \
      				path/to/quartus/project/build \
      				path/to/yocto/


    Create and update linux kernel recipe bbappend

    Add the devtool-fragment.cfg and the patches to the meta-custom layer with:

    Code Block
    languagebash
    themeMidnight
    linenumberstrue
    devtool update-recipe linux-altera-lts -a path/to/yocto/poky/meta-custom
    /recipes-bsp/u-boot/u-boot-socfpga/qts
     -O


    Remove workspace

    Scroll Ignore
    scroll-pdftrue
    scroll-officetrue
    scroll-chmtrue
    scroll-docbooktrue
    scroll-eclipsehelptrue
    scroll-epubtrue
    scroll-htmltrue

    Remove the workspace from bblayers.conf and delete the workspace folder

    Add the generated files to the u-boot bbappend file

    :

    Code Block
    languagebash
    themeMidnight
    linenumberstrue
    cd
     path/to/yocto/poky/build
    
    recipetool edit u-boot-socfpga

    Add qts_filter files and the  following task to copy the qts_filter files to the correct place in u-boot sources during build image (if your are using another board, you have to adjust the file path):

    Code Block
    languagejs
    SRC_URI += "file://qts/iocsr_config.h \
    			file://qts/pinmux_config.h \
    			file://qts/pll_config.h \
    			file://qts/sdram_config.h \
    			"
    
    do_configure_prepend () {
    	install -m 0644 ${WORKDIR}/qts/iocsr_config.h ${S}/board/altera/cyclone5-socdk/qts/
    	install -m 0644 ${WORKDIR}/qts/pinmux_config.h ${S}/board/altera/cyclone5-socdk/qts/
    	install -m 0644 ${WORKDIR}/qts/pll_config.h ${S}/board/altera/cyclone5-socdk/qts/
    	install -m 0644 ${WORKDIR}/qts/sdram_config.h ${S}/board/altera/cyclone5-socdk/qts/
    }
    bitbake-layers remove-layer workspace
    rm -rf path/to/yocto/poky/build/workspace

    Add custom files to meta layer

    Scroll Ignore
    scroll-pdftrue
    scroll-officetrue
    scroll-chmtrue
    scroll-docbooktrue
    scroll-eclipsehelptrue
    scroll-epubtrue
    scroll-htmltrue

    Add handoff files to u-boot

    If you create a u-boot file for an Intel Cyclone V / Arria V with quartus version 20.1 you have to convert the handoff data into source code.

    1. compile your quartus project
    2. run the embedded command shell (Intel SoC EDS):

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      ~/intelFPGA_lite/20.1/embedded/embedded_command_shell.sh


    3. navigate to your quartus project directory and convert the handoff data into source code:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      cd path/to/quartus/project
      mkdir -p build
      bsp-create-settings --type spl --bsp-dir build \
      --preloader-settings-dir hps_isw_handoff/* \
      --settings build/settings.bsp


    Next you have to run the qts_filter to take the sources from the handoff folder, format them and copy them to u-boot source code.

    1. Fetch qts_filter.sh from github:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      wget https://raw.githubusercontent.com/altera-opensource/u-boot-socfpga/socfpga_v2021.04/arch/arm/mach-socfpga/qts-filter.sh


    2. Run qts_filter for cyclone5 to format and copy the handoff files to custom meta layer:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      mkdir -p path/to/yocto/poky/meta-custom/recipes-bsp/u-boot/u-boot-socfpga/qts
      ./qts-filter.sh cyclone5 \
      				path/to/quartus/project \
      				path/to/quartus/project/build \
      				path/to/yocto/poky/meta-custom/recipes-bsp/u-boot/u-boot-socfpga/qts


    3. Add the generated files to the u-boot bbappend file:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      cd  path/to/yocto/poky/meta-custom/recipes-bsp/u-boot
      gedit u-boot-socfpga*.bbappend


      Add qts_filter files and the following task to copy the qts_filter files to the correct place in u-boot sources during build image (if your are using another board, you have to adjust the file path):

      Code Block
      languagejs
      SRC_URI += "file://qts/iocsr_config.h \
      			file://qts/pinmux_config.h \
      			file://qts/pll_config.h \
      			file://qts/sdram_config.h \
      			"
      
      do_configure_prepend () {
      	install -m 0644 ${WORKDIR}/qts/iocsr_config.h ${S}/board/altera/cyclone5-socdk/qts
      	install -m 0644 ${WORKDIR}/qts/pinmux_config.h ${S}/board/altera/cyclone5-socdk/qts
      	install -m 0644 ${WORKDIR}/qts/pll_config.h ${S}/board/altera/cyclone5-socdk/qts
      	install -m 0644 ${WORKDIR}/qts/sdram_config.h ${S}/board/altera/cyclone5-socdk/qts
      }


    For more information see u-boot-socfpga/doc/README.socfpga.

    Add custom device tree

    u-boot

    To add an own device tree to u-boot do following steps:

    1. Copy the .dts/.dtsi files to meta-custom/recipes-bsp/u-boot/u-boot-socfpga/dts:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      mkdir -p path/to/yocto/poky/meta-custom/recipes-bsp/u-boot/u-boot-socfpga/dts
      cp custom.dts path/to/yocto/poky/meta-custom/recipes-bsp/u-boot/u-boot-socfpga/dts/custom.dts
      cp custom-u-boot.dtsi path/to/yocto/poky/meta-custom/recipes-bsp/u-boot/u-boot-socfpga/dts/custom-u-boot.dtsi


    2. Add the .dts/.dtsi files to the u-boot bbappend file:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      cd  path/to/yocto/poky/meta-custom/recipes-bsp/u-boot
      gedit u-boot-socfpga*.bbappend

      Copy the following code to the u-boot bbappend file to copy the files to the correct directory and add them to the correct Makefile:

      Code Block
      languagejs
      SRC_URI += "[...]
      			file://dts/custom.dts \
      			file://dts/custom-u-boot.dtsi \
      			"
      
      do_configure_prepend () {
      	[...]
      	install -m 0644 ${WORKDIR}/dts/custom.dts ${S}/arch/arm/dts
      	install -m 0644 ${WORKDIR}/dts/custom-u-boot.dtsi ${S}/arch/arm/dts
      }


    3. Redefine the variable UBOOT_EXTLINUX_FDT_default with the file name of your device tree in the machine configration file of meta-custom:

      Code Block
      themeMidnight
      linenumberstrue
      sed -i '/^UBOOT_EXTLINUX_FDT_default/s/".*"/"..\/custom.dtb"/g' path/to/yocto/poky/meta-custom/conf/machine/custom.conf


    4. Change in menuconfig the device tree to custom.dts:
      1. Run menuconfig as described here: Configure u-boot (Note: If a devtool-fragment.cfg file for u-boot already exists in the meta-custom layer, you should update it manually, otherwise the existing changes there will be deleted)
      2. Go to Boot options → Default fdt file and change the value to 'custom.dtb'
      3. Go to Device Tree Control → Default Device Tree for DT control and change the value to 'custom'

    linux kernel

    Adding your own device tree to the linux kernel is similar to the steps above:

    1. Copy the .dts file to meta-custom/recipes-kernel/linux/linux-altera-lts/dts:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      mkdir -p path/to/yocto/poky/meta-custom/recipes-kernel/linux/linux-altera-lts/dts
      cp custom.dts path/to/yocto/poky/meta-custom/recipes-kernel/linux/linux-altera-lts/dts/custom.dts


    2. Add the .dts file to the linux kernel bbappend file:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      cd  path/to/yocto/poky/meta-custom/recipes-kernel/linux
      gedit liunx-altera-lts*.bbappend

      Copy the following code to the linux kernel bbappend file to copy the files to the correct directory during image generation:

      Code Block
      languagejs
      SRC_URI += "[...]
      			file://dts/custom.dts \
      			"
      
      do_configure_prepend () {
      	[...]
      	install -m 0644 ${WORKDIR}/dts/custom.dts ${S}/arch/${ARCH}/boot/dts
      }


    3. Redefine the variable KERNEL_DEVICETREE with the file name of your device tree in the machine configration file of meta-custom.

      1. Open the custom.conf file:

        Code Block
        themeMidnight
        linenumberstrue
         gedit path/to/yocto/poky/meta-custom/conf/machine/custom.conf


      2. Delete the content of the variable KERNEL_DEVICETREE and add your customized device tree:

        Code Block
        languagejs
        KERNEL_DEVICETREE = "custom.dtb"
        


    (optional) Add fpga configuration file to meta layer

    It is possible to add an fpga configuration file to the meta layer, which is used to configure the fpga from u-boot.

    1. First generate an rbf file from the sof file generated by the quartus project:
      1. run the nios ii command shell (Intel Quartus):

        Code Block
        languagebash
        themeMidnight
        linenumberstrue
        ~/intelFPGA_lite/20.1/nios2eds/nios2_command_shell.sh


      2. run following command to convert the sof file to rbf:

        Code Block
        languagebash
        themeMidnight
        linenumberstrue
        cd path/to/quartus/project/output_files
        quartus_cpf -c -o bitstream_compression=on custom.sof soc_system.rbf


    2. Run following commands to create a recipe in the specified directory:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      mkdir -p path/to/yocto/poky/meta-custom/recipes-bsp/rbf
      cat > path/to/yocto/poky/meta-custom/recipes-bsp/rbf/custom-rbf.bb << EOF
      DESCRIPTION = "Add fpga configuration file to image"
      LICENSE = "MIT"
      LIC_FILES_CHKSUM = "file://\${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" 
      
      PACKAGE_ARCH = "\${MACHINE_ARCH}"
      PV = "1.0\${PR}" 
      
      FILESEXTRAPATHS_prepend := "\${THISDIR}/files:"
      SRC_URI = " file://soc_system.rbf"  
      
      do_install () {
      	install -d \${D}/images/\${MACHINE}
      	install -m 0644 \${WORKDIR}/soc_system.rbf \${D}/images/\${MACHINE}
      	install -d \${DEPLOY_DIR}/images/\${MACHINE}
      	cp \${WORKDIR}/soc_system.rbf \${DEPLOY_DIR}/images/\${MACHINE}
      }
      
      FILES_\${PN} += "/images/\${MACHINE}" 
      
      EOF


    3. Create the files folder in meta-custom/recipes-bsp/rbf and copy the rbf file there:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      mkdir -p path/to/yocto/poky/meta-custom/recipes-bsp/rbf/files
      cp path/to/soc_system.rbf path/to/yocto/poky/meta-custom/recipes-bsp/rbf/files/


    4. Add with the variable IMAGE_BOOT_FILES the rbf file to the FAT partition of the image in the machine configuration file of meta-custom layer:

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      echo -e '\nIMAGE_BOOT_FILES += "soc_system.rbf"' >> path/to/yocto/poky/meta-custom/conf/machine/custom.conf


    5. Modify the image recipe to add the createed recipe to your image. This command refers to the provided image core-image-minimal.bb, you can also create your own image recipe and add your created recipes.

      Code Block
      languagebash
      themeMidnight
      linenumberstrue
      echo -e '\nIMAGE_INSTALL_append = " custom-rbf"' >> path/to/yocto/poky/meta/recipes-core/images/core-image-minimal.bb


    6. Add the following commands to CONFIG_BOOTCOMMAND via u-boot menuconfig, so that u-boot will configure the fpga with the rbf file:

      1. Run menuconfig as described here: Configure u-boot (Note: If a devtool-fragment.cfg file for u-boot already exists in the meta-custom layer, you should update it manually, otherwise the existing changes there will be deleted)
      2. Go to Boot options and enable 'Enable a default value for bootcmd'
      3. Change the value of 'bootcmd value' to 'load mmc 0:1 $loadaddr soc_system.rbf; fpga load 0 $loadaddr $filesize; bridge enable; run distro_bootcmd'

    References

    Scroll Ignore

    For more information see u-boot-socfpga/doc/README.socfpga.

    References

    Scroll Ignore
    scroll-pdftrue
    scroll-officetrue
    scroll-chmtrue
    scroll-docbooktrue
    scroll-eclipsehelptrue
    scroll-epubtrue
    scroll-htmltrue
    1. Linux Kernel Development Manual
    2. Reference Manual#devtool Quick Reference
    3. Board Support Package (BSP) Developers's Guide
    4. u-boot-socfpga/doc/README.socfpga
    5. Patching the source for a recipe
    6. Intel SoC EDS User Guide


    Scroll Only


    HTML
    <style>
    .wiki-content .columnLayout .cell.aside {
    width: 0%;
    }</style>
    



    Scroll pdf ignore


    Custom_fix_page_content

    Table of contents

    Table of Contents
    outlinetrue