Difference between revisions of "BELK-TN-006: Using PetaLinux to Build BELK/BXELK Software Components"

From DAVE Developer's Wiki
Jump to: navigation, search
(Building the Linux kernel)
(33 intermediate revisions by 2 users not shown)
Line 2: Line 2:
 
{{Applies To Bora}}
 
{{Applies To Bora}}
 
{{Applies To BoraX}}
 
{{Applies To BoraX}}
{{AppliesToBORA_TN}}
 
{{AppliesToBORA_Xpress_TN}}
 
 
{{InfoBoxBottom}}
 
{{InfoBoxBottom}}
__FORCETOC__
 
  
 
== History ==
 
== History ==
Line 16: Line 13:
 
|September 2018
 
|September 2018
 
|First public release
 
|First public release
|-
 
|1.1.0
 
|November 2018
 
|Added missing command to generate the DTB file
 
 
|-
 
|-
 
|}
 
|}
  
 
== Introduction ==
 
== Introduction ==
As explained [[Logical_structure_of_Bora_and_BoraX_Embedded_Linux_Kits_(BELK/BXELK)|here]], BELK/BXELK structure is not based on the [https://www.xilinx.com/products/design-tools/embedded-software/petalinux-sdk.html PetaLinux build system] (*). Instead, BELK/BXELK make use of a standardized Yocto-based build system to build all the software components—U-Boot, Linux kernel, and root filesystem—that run on the Processing System (PS). This approach is more flexible and more modularized but it requires a little bit more knowledge of embedded Linux systems.
+
As explained [[Logical_structure_of_Bora_and_BoraX_Embedded_Linux_Kits_(BELK/BXELK)|here]], BELK/BXELK structure is not based on [https://www.xilinx.com/products/design-tools/embedded-software/petalinux-sdk.html PetaLinux build system]. Instead, BELK/BXELK make use of a standardized Yocto-based build system to build all the software components—U-Boot, Linux kernel, and root filesystem—that run on the Processing System (PS). This choice is more flexible and more modularized but it requires a little bit more knowledge of embedded Linux systems.
  
That being said, there are cases in which it can be convenient to build such components with PetaLinux build system, however. This technical note shows how to use the PetaLinux build system to build the Linux kernel released with BELK/BXELK.
+
That being said, there are cases in which it can be convenient to build such components with PetaLinux build system, however. This technical note shows how to build the Linux kernel image released with BELK/BXELK with PetaLinux build system.
  
 
The procedure was tested with the following configuration.
 
The procedure was tested with the following configuration.
Line 41: Line 34:
 
|4.0.0
 
|4.0.0
 
|-
 
|-
| style="text-align: center;" |Host operating system
+
| style="text-align: center;" |
|Ubuntu 14.04.5 LTS
+
|
 
|-
 
|-
 
|}
 
|}
  
It is assumed that PetaLinux is already installed on the host machine (for more details, please refer to [https://www.xilinx.com/support/documentation-navigation/see-all-versions.html?xlnxproducttypes=Design%20Tools&xlnxdocumentid=UG1144 ''UG1144 - PetaLinux Tools Documentation: Reference Guide'']).
+
== Building the Linux kernel ==
 +
petalinux-create --type project --template zynq --name bora1
  
 +
petalinux-config --get-hw-description=/home/dvdk/devel/bora/bora-minimal/bora-minimal.sdk/
  
 +
kernel directory
  
(*) Please note that PetaLinux itself works on top of the Yocto build system.
+
DTS include directory
 
 
== Building the Linux Kernel ==
 
First of all, set up the PetaLinux environment:
 
<pre class="workstation-terminal">
 
dvdk@osboxes:~/devel/bora/prj$ source /opt/petalinux/settings.sh
 
PetaLinux environment set to '/opt/petalinux'
 
INFO: Checking free disk space
 
INFO: Checking installed tools
 
INFO: Checking installed development libraries
 
INFO: Checking network and other services
 
</pre>
 
 
 
 
 
Then, create a project from the <code>zynq</code> template:
 
<pre class="workstation-terminal">
 
dvdk@osboxes:~/devel/bora/prj$ petalinux-create --type project --template zynq --name bora_1
 
INFO: Create project: bora_1
 
INFO: New project successfully created in /home/dvdk/devel/bora/prj/bora_1
 
</pre>
 
 
 
 
 
Import the hardware specification file (.hdf) generated by your Vivado project. This step will open automatically the text-based configuration menu of PetaLinux build system: when it shows up, just exit and save the configuration without changing anything.
 
<pre class="workstation-terminal">
 
dvdk@osboxes:~/devel/bora/prj/bora_1$ petalinux-config --get-hw-description=/home/dvdk/devel/bora/bora-minimal/bora-minimal.sdk/
 
INFO: Getting hardware description...
 
INFO: Rename bora_wrapper.hdf to system.hdf
 
[INFO] generating Kconfig for project
 
                                                                                                                                                         
 
[INFO] menuconfig project
 
/home/dvdk/devel/bora/prj/bora_1/build/misc/config/Kconfig.syshw:30:warning: defaults for choice values not supported
 
/home/dvdk/devel/bora/prj/bora_1/build/misc/config/Kconfig:574:warning: config symbol defined without type
 
configuration written to /home/dvdk/devel/bora/prj/bora_1/project-spec/configs/config
 
 
 
*** End of the configuration.
 
*** Execute 'make' to start the build or try 'make help'.
 
 
 
[INFO] sourcing bitbake
 
[INFO] generating plnxtool conf
 
[INFO] generating meta-plnx-generated layer
 
~/devel/bora/prj/bora_1/build/misc/plnx-generated ~/devel/bora/prj/bora_1
 
~/devel/bora/prj/bora_1
 
[INFO] generating machine configuration
 
[INFO] generating bbappends for project . This may take time !
 
~/devel/bora/prj/bora_1/build/misc/plnx-generated ~/devel/bora/prj/bora_1
 
~/devel/bora/prj/bora_1
 
[INFO] generating u-boot configuration files
 
                                                                                                                                                         
 
[INFO] generating kernel configuration files
 
[INFO] generating kconfig for Rootfs
 
Generate rootfs kconfig
 
[INFO] oldconfig rootfs
 
[INFO] generating petalinux-user-image.bb
 
</pre>
 
[[File:Belk petalinux kernel1.png|thumb|center|600px]]
 
 
 
 
 
Your project tree should look like this at this point:
 
<pre class="workstation-terminal">
 
dvdk@osboxes:~/devel/bora/prj/bora_1$ tree -d
 
.
 
├── build
 
│   ├── cache
 
│   ├── conf
 
│   ├── misc
 
│   │   ├── config
 
│   │   │   ├── data
 
│   │   │   └── hw-description
 
│   │   ├── plnx-generated
 
│   │   └── rootfs_config
 
│   └── tmp
 
│      └── cache
 
│          └── linaro-glibc
 
│              └── plnx_arm
 
│                  └── x86_64
 
├── components
 
│   └── plnx_workspace
 
└── project-spec
 
    ├── configs
 
    ├── hw-description
 
    ├── meta-plnx-generated
 
    │   ├── conf
 
    │   │   └── machine
 
    │   ├── recipes-bsp
 
    │   │   ├── device-tree
 
    │   │   ├── fsbl
 
    │   │   ├── hdf
 
    │   │   └── u-boot
 
    │   │      └── configs
 
    │   ├── recipes-core
 
    │   │   ├── busybox
 
    │   │   │   └── files
 
    │   │   └── images
 
    │   └── recipes-kernel
 
    │      └── linux
 
    │          └── configs
 
    └── meta-user
 
        ├── conf
 
        ├── recipes-apps
 
        │   ├── gpio-demo
 
        │   │   └── files
 
        │   └── peekpoke
 
        │      └── files
 
        ├── recipes-bsp
 
        │   ├── device-tree
 
        │   │   └── files
 
        │   └── u-boot
 
        │      └── files
 
        └── recipes-core
 
            └── images
 
 
 
49 directories
 
</pre>
 
 
 
 
 
Clone the Linux kernel sources from DAVE's git repisitory in the :
 
<pre class="workstation-terminal">
 
dvdk@osboxes:~/devel/bora/prj/bora_1/components$mkdir ext_sources
 
dvdk@osboxes:~/devel/bora/prj/bora_1/components$cd ext_sources
 
dvdk@osboxes:~/devel/bora/prj/bora_1/components/ext_sources$git clone git@git.dave.eu/bora/linux-xlnx.git -b bora-4.x.x
 
Cloning into 'linux-xlnx'...
 
...
 
</pre>
 
 
 
 
 
Replace the file <code>xilinx_zynq_defconfig</code> with a symbolic link to <code>bora_defconfig</code>:
 
<pre class="workstation-terminal">
 
dvdk@osboxes:~/devel/bora/prj/bora_1/components/ext_sources$ cd linux-xlnx/arch/arm/configs/
 
dvdk@osboxes:~/devel/bora/prj/bora_1/components/ext_sources/linux-xlnx/arch/arm/configs$ rm xilinx_zynq_defconfig
 
dvdk@osboxes:~/devel/bora/prj/bora_1/components/ext_sources/linux-xlnx/arch/arm/configs$ ln -s bora_defconfig xilinx_zynq_defconfig
 
dvdk@osboxes:~/devel/bora/prj/bora_1/components/ext_sources/linux-xlnx/arch/arm/configs$ ll xilinx_zynq_defconfig
 
lrwxrwxrwx 1 dvdk dvdk 14 set 21 14:30 xilinx_zynq_defconfig -> bora_defconfig
 
</pre>
 
 
 
 
 
Open the PetaLinux configuration menu and set up the kernel source
 
<pre class="workstation-terminal">
 
dvdk@osboxes:~/devel/bora/prj/bora_1$ petalinux-config
 
</pre>
 
 
 
 
 
Configure the build system in order to use an external kernel (''Linux Components Selection'' item):
 
[[File:Belk petalinux kernel2.png|thumb|center|600px]]
 
 
 
 
 
Set the path of the directory containing the BELK/BXELK Linux kernel tree (<code>${TOPDIR}/../components/ext_sources/linux-xlnx</code>):
 
[[File:Belk petalinux kernel3.png|thumb|center|600px]]
 
 
 
 
 
Configure the build system in order to use a custom directory for device tree include files: enable the ''Auto Config Settings --> Specify a manual device tree include directory'' item and set the ''Manual device tree include directory'' to <code>${TOPDIR}/../components/ext_sources/linux-xlnx/arch/arm/boot/dts/include</code>:
 
[[File:Belk petalinux kernel4.png|thumb|center|600px]]
 
 
 
 
 
Set the ''Root file system type'' to ''NFS'' in order to generate a <code>uImage</code> that doesn't include any file system:
 
[[File:Belk petalinux kernel5.png|thumb|center|600px]]
 
  
 +
Add in build/conf/plnxtool.conf
 +
LINUX_VERSION_EXTENSION = "-belk-4.0.0"
  
Exit and save the configuration.
+
dvdk@osboxes:~/devel/bora/prj/bora1/components/ext_sources/linux-xlnx$ cd arch/arm/configs/
 +
dvdk@osboxes:~/devel/bora/prj/bora1/components/ext_sources/linux-xlnx/arch/arm/configs$ rm xilinx_zynq_defconfig
 +
dvdk@osboxes:~/devel/bora/prj/bora1/components/ext_sources/linux-xlnx/arch/arm/configs$ ln -s bora_defconfig xilinx_zynq_defconfig
 +
dvdk@osboxes:~/devel/bora/prj/bora1/components/ext_sources/linux-xlnx/arch/arm/configs$ ll xilinx_zynq_defconfig
 +
lrwxrwxrwx 1 dvdk dvdk 14 set 21 10:30 xilinx_zynq_defconfig -> bora_defconfig
  
  
Add the following lines to the file <code>project-spec/meta-user/conf/petalinuxbsp.conf</code>:
+
project-spec/meta-user/conf/petalinuxbsp.conf
<pre class="workstation-terminal">
 
LINUX_VERSION_EXTENSION = "-belk-4.0.0"
 
 
KERNEL_DEVICETREE = "bora.dtb"
 
KERNEL_DEVICETREE = "bora.dtb"
</pre>
 
 
 
Build the kernel:
 
<pre class="workstation-terminal">
 
dvdk@osboxes:~/devel/bora/prj/bora_1$ petalinux-build -v -c kernel
 
[INFO] building kernel
 
[INFO] sourcing bitbake
 
INFO: bitbake virtual/kernel
 
Loading cache: 100% |######################################################################################################################| Time: 0:00:00
 
Loaded 3234 entries from dependency cache.
 
Parsing recipes: 100% |####################################################################################################################| Time: 0:00:03
 
Parsing of 2446 .bb files complete (2410 cached, 36 parsed). 3236 targets, 224 skipped, 0 masked, 0 errors.
 
NOTE: Resolving any missing task queue dependencies
 
Initialising tasks: 100% |#################################################################################################################| Time: 0:00:57
 
Checking sstate mirror object availability: 100% |#########################################################################################| Time: 0:00:21
 
NOTE: Executing SetScene Tasks
 
NOTE: Executing RunQueue Tasks
 
linux-xlnx-4.9-belk-4.0.0+git999-r0 do_compile: NOTE: linux-xlnx: compiling from external source tree /home/dvdk/devel/bora/prj/bora_1/build/../components/ext_sources/linux-xlnx
 
fsbl-2017.2+gitAUTOINC+122565ec40-r0 do_compile: NOTE: fsbl: compiling from external source tree /opt/petalinux/tools/hsm/data/embeddedsw
 
NOTE: Tasks Summary: Attempted 2410 tasks of which 1869 didn't need to be rerun and all succeeded.
 
INFO: Copying Images from deploy to images
 
INFO: Creating images/linux directory
 
[INFO] successfully built kernel
 
</pre>
 
 
 
Create the <code>uImage</code> file:
 
<pre class="workstation-terminal">
 
dvdk@osboxes:~/devel/bora/prj/bora_1$ petalinux-package --image -c kernel --format uImage
 
SDK environment now set up; additionally you may now run devtool to perform development tasks.
 
Run devtool --help for further details.
 
 
### Shell environment set up for builds. ###
 
 
You can now run 'bitbake <target>'
 
 
Common targets are:
 
    core-image-minimal
 
    core-image-sato
 
    meta-toolchain
 
    meta-ide-support
 
 
You can also run generated qemu images with a command like 'runqemu qemux86'
 
INFO: Adding user layer: /home/dvdk/devel/bora/prj/bora_1/project-spec/meta-user
 
INFO: generating uImage
 
INFO: bitbake -R /home/dvdk/devel/bora/prj/bora_1/build/conf/kerneltype.conf virtual/kernel
 
Parsing recipes: 100% |####################################################################################################################| Time: 0:03:09
 
Parsing of 2446 .bb files complete (0 cached, 2446 parsed). 3236 targets, 224 skipped, 0 masked, 0 errors.
 
NOTE: Resolving any missing task queue dependencies
 
Initialising tasks: 100% |#################################################################################################################| Time: 0:00:17
 
Checking sstate mirror object availability: 100% |#########################################################################################| Time: 0:00:12
 
NOTE: Executing SetScene Tasks
 
NOTE: Executing RunQueue Tasks
 
linux-xlnx-4.9-belk-4.0.0+git999-r0 do_compile: NOTE: linux-xlnx: compiling from external source tree /home/dvdk/devel/bora/prj/bora_1/build/../components/ext_sources/linux-xlnx
 
NOTE: Tasks Summary: Attempted 2410 tasks of which 2349 didn't need to be rerun and all succeeded.
 
</pre>
 
 
 
Compile the device tree:
 
<pre class="workstation-terminal">
 
dvdk@osboxes:~/devel/bora/prj/bora_1$ petalinux-build -v -c device-tree
 
[INFO] building device-tree
 
[INFO] sourcing bitbake
 
INFO: bitbake virtual/dtb
 
Loading cache: 100% |###################################################################################################################################| Time: 0:00:00
 
Loaded 3233 entries from dependency cache.
 
Parsing recipes: 100% |#################################################################################################################################| Time: 0:01:45
 
Parsing of 2446 .bb files complete (2413 cached, 33 parsed). 3236 targets, 224 skipped, 0 masked, 0 errors.
 
NOTE: Resolving any missing task queue dependencies
 
Initialising tasks: 100% |##############################################################################################################################| Time: 0:00:02
 
Checking sstate mirror object availability: 100% |######################################################################################################| Time: 0:00:02
 
NOTE: Executing SetScene Tasks
 
NOTE: Executing RunQueue Tasks
 
NOTE: Tasks Summary: Attempted 748 tasks of which 748 didn't need to be rerun and all succeeded.
 
INFO: Copying Images from deploy to images
 
[INFO] successfully built device-tree
 
</pre>
 
 
 
After the build is completed, the <code>uImage</code> file and the device tree blob (<code>system.dtb</code>) are located in the <code>images/linux</code> directory.
 
===Device tree handling===
 
One of the most appreciated features of PetaLinux is the automatic generation of the Linux Device Tree including the nodes associated with the IPs instantiated in the PL. When used in combination with the Device Tree provided by the BELK/BXELK, this generation process works as depicted in the following image.
 
 
 
[[File:BELK-PetaLinux-DTB.png|thumb|center|600px|Combined Device Tree generation process]]
 
 
 
In essence, PetaLinux combines the original Bora/BoraX device tree (<code>bora.dts</code>) with another auxiliary device tree generated on the base of hardware description file (.hdf). The resulting DTB (<code>system.dtb</code>) provides all the nodes required by the system to operate properly.
 
 
It is worth remembering that the user can add further customizations to the resulting DTB by editing this file <code><plnx-projroot>/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi</code>. For more details, please refer to the ''Xilinx UG1144 PetaLinux Tools Documentation - Reference Guide''.
 

Revision as of 08:47, 21 September 2018

Info Box
Bora5-small.jpg Applies to Bora
BORA Xpress.png Applies to BORA Xpress

History[edit | edit source]

Version Date Notes
1.0.0 September 2018 First public release

Introduction[edit | edit source]

As explained here, BELK/BXELK structure is not based on PetaLinux build system. Instead, BELK/BXELK make use of a standardized Yocto-based build system to build all the software components—U-Boot, Linux kernel, and root filesystem—that run on the Processing System (PS). This choice is more flexible and more modularized but it requires a little bit more knowledge of embedded Linux systems.

That being said, there are cases in which it can be convenient to build such components with PetaLinux build system, however. This technical note shows how to build the Linux kernel image released with BELK/BXELK with PetaLinux build system.

The procedure was tested with the following configuration.

Component Version
PetaLinux 2017.2
BELK/BXELK 4.0.0

Building the Linux kernel[edit | edit source]

petalinux-create --type project --template zynq --name bora1

petalinux-config --get-hw-description=/home/dvdk/devel/bora/bora-minimal/bora-minimal.sdk/

kernel directory

DTS include directory

Add in build/conf/plnxtool.conf LINUX_VERSION_EXTENSION = "-belk-4.0.0"

dvdk@osboxes:~/devel/bora/prj/bora1/components/ext_sources/linux-xlnx$ cd arch/arm/configs/ dvdk@osboxes:~/devel/bora/prj/bora1/components/ext_sources/linux-xlnx/arch/arm/configs$ rm xilinx_zynq_defconfig dvdk@osboxes:~/devel/bora/prj/bora1/components/ext_sources/linux-xlnx/arch/arm/configs$ ln -s bora_defconfig xilinx_zynq_defconfig dvdk@osboxes:~/devel/bora/prj/bora1/components/ext_sources/linux-xlnx/arch/arm/configs$ ll xilinx_zynq_defconfig lrwxrwxrwx 1 dvdk dvdk 14 set 21 10:30 xilinx_zynq_defconfig -> bora_defconfig


project-spec/meta-user/conf/petalinuxbsp.conf KERNEL_DEVICETREE = "bora.dtb"