Running Petalinux
Building Petalinux
Release date: Feb 22, 2023
In the previous article, we set up the Petalinux development environment. The following various Petalinux commands should be available on Ubuntu.
$ petalinux-
petalinux-boot petalinux-config petalinux-devtool petalinux-upgrade
petalinux-build petalinux-create petalinux-package petalinux-util
In this article, we will use them to build Petalinux running on the Zybo Z7-20.
Table of Contents
Construct hardware
First, a simple hardware construction for the Zybo Z7-20 is performed using Vivado.
The following is a brief description of the procedure.
* For more information on the procedure, please see the article describing Vivado.
- Creating a new project in Vivado
- Creating Block Design in Vivado
- Add ZYNQ7 Prosessing System and click [Run Block Automation]
- Connect FCLK_CLK0 and M_AXI_GP0_ACLK
If it looks like the following, the creation is complete.
You can change the name and output destination of the generated XSA file, but this article will leave them as they are.
When completed, design_1_wrapper.xsa will be generated in the directory specified when the project was created.
Petalinux Project Creation
We will now use the Petalinux command to perform the build process.
First, create a Petalinux project.
The project can be created anywhere, but it should be created in the Vivado project directory created earlier so that the corresponding hardware is clear.
// Go to Vivado project directory
$ cd /home/username/workspace/petalinux1
// Create a Petalinux project named peta_project (name optional)
$ petalinux-create --type project --template zynq --name peta_project
NFO: Create project: peta_project
INFO: New project successfully created in /home/username/workspace/petalinux1/peta_project
The directory structure, including the Vivado deliverable design_1_wrapper.xsa, would look something like this
$ ls
design_1_wrapper.xsa petalinux1.cache petalinux1.hw petalinux1.runs petalinux1.srcs
peta_project petalinux1.gen petalinux1.ip_user_files petalinux1.sim petalinux1.xpr
Petalinux System Configuration
Next, initialize the Petalinux project with the hardware configuration created in Vivado.
// Go to the Petalinux project directory you created
$ cd peta_project
// Perform system configuration by specifying the XSA file created in Vivado
$ petalinux-config --get-hw-description=../design_1_wrapper.xsa
[INFO] Sourcing buildtools
INFO: Getting hardware description...
INFO: Renaming design_1_wrapper.xsa to system.xsa
[INFO] Generating Kconfig for project
[INFO] Menuconfig project
When you run petalinux-config, you will see the following menu
Select [Image Packaging Configuration --->] and check the first part of [Root filesystem type (xxxx) --->]. If the brackets are not set to EXT4 (SD/eMMC/SATA/USB), change them.
Select [Save] -> [Ok] -> [Exit] to save the settings, then select [Exit] twice more to close the menu.
*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.
[INFO] Extracting yocto SDK to components/yocto. This may take time!
[INFO] Sourcing build environment
[INFO] Generating kconfig for Rootfs
[INFO] Silentconfig rootfs
[INFO] Generating plnxtool conf
[INFO] Adding user layers
[INFO] Generating workspace directory
Petalinux Build
Finally, build Petalinux.
Please build while connected to the network, as multiple ftp, git servers, etc. will be accessed during the build process.
The build will take a few minutes. Please note that if the network line is too narrow or there is a failure, the build may take even longer or stop in the middle of the build.
$ petalinux-build
[INFO] Sourcing buildtools
[INFO] Building project
[INFO] Sourcing build environment
[INFO] Generating workspace directory
INFO: bitbake petalinux-image-minimal
NOTE: Started PRServer with DBfile: /home/username/workspace/petalinux1/peta_project/build/cache/prserv.sqlite3, Address: 127.0.0.1:44629, PID: 18569
Loading cache: 100% | | ETA: --:--:--
Loaded 0 entries from dependency cache.
Parsing recipes: 100% |#####################################################################################################################################################################| Time: 0:00:55
Parsing of 3592 .bb files complete (0 cached, 3592 parsed). 5394 targets, 554 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
NOTE: Fetching uninative binary shim file:///home/username/workspace/petalinux1/peta_project/components/yocto/downloads/uninative/126f4f7f6f21084ee140dac3eb4c536b963837826b7c38599db0b512c3377ba2/x86_64-nativesdk-libc-3.4.tar.xz;sha256sum=126f4f7f6f21084ee140dac3eb4c536b963837826b7c38599db0b512c3377ba2 (will check PREMIRRORS first)
Initialising tasks: 100% |##################################################################################################################################################################| Time: 0:00:05
Checking sstate mirror object availability: 100% |##########################################################################################################################################| Time: 0:00:18
Sstate summary: Wanted 1577 Local 0 Network 1358 Missed 219 Current 0 (86% match, 0% complete)
NOTE: Executing Tasks
...
An error may occur during the build process and the build may fail. If this is the case, try building again.
// Error during build
WARNING: base-files-soc-2022.1-r0 do_package_qa_setscene: Failed to fetch URL file://78/9e/sstate:base-files-soc:zynq-7z-xilinx-linux-gnueabi:2022.1:r0:zynq-7z:7:789e357513ef1fb7126affed8b1bd732a4a0afec0783b03391ac8f89cdd1e509_package_qa.tgz;downloadfilename=78/9e/sstate:base-files-soc:zynq-7z-xilinx-linux-gnueabi:2022.1:r0:zynq-7z:7:789e357513ef1fb7126affed8b1bd732a4a0afec0783b03391ac8f89cdd1e509_package_qa.tgz, attempting MIRRORS if available
ERROR: base-files-soc-2022.1-r0 do_package_qa_setscene: Fetcher failure: Unable to find file file://78/9e/sstate:base-files-soc:zynq-7z-xilinx-linux-gnueabi:2022.1:r0:zynq-7z:7:789e357513ef1fb7126affed8b1bd732a4a0afec0783b03391ac8f89cdd1e509_package_qa.tgz;downloadfilename=78/9e/sstate:base-files-soc:zynq-7z-xilinx-linux-gnueabi:2022.1:r0:zynq-7z:7:789e357513ef1fb7126affed8b1bd732a4a0afec0783b03391ac8f89cdd1e509_package_qa.tgz anywhere. The paths that were searched were:
/home/username/workspace/petalinux1/peta_project/build/sstate-cache
/home/username/workspace/petalinux1/peta_project/build/sstate-cache
WARNING: base-files-soc-2022.1-r0 do_package_qa_setscene: No sstate archive obtainable, will run full task instead.
ERROR: Logfile of failure stored in: /home/username/workspace/petalinux1/peta_project/build/tmp/work/zynq-7z-xilinx-linux-gnueabi/base-files-soc/2022.1-r0/temp/log.do_package_qa_setscene.26824
WARNING: Setscene task (/home/username/workspace/petalinux1/peta_project/components/yocto/layers/meta-petalinux/recipes-core/base-files/base-files-soc.bb:do_package_qa_setscene) failed with exit code '1' - real task will be run instead
NOTE: Tasks Summary: Attempted 4216 tasks of which 3727 didn't need to be rerun and all succeeded.
Summary: There were 2 WARNING messages shown.
Summary: There was 1 ERROR message shown, returning a non-zero exit code.
ERROR: Failed to build project. Check the /home/username/workspace/petalinux1/peta_project/build/build.log file for more details...
// Build again
$ petalinux-build
[INFO] Sourcing buildtools
[INFO] Building project
[INFO] Sourcing build environment
[INFO] Generating workspace directory
INFO: bitbake petalinux-image-minimal
NOTE: Started PRServer with DBfile: /home/username/workspace/petalinux1/peta_project/build/cache/prserv.sqlite3, Address: 127.0.0.1:36647, PID: 136488
Loading cache: 100% |#######################################################################################################################################################################| Time: 0:00:00
Loaded 5392 entries from dependency cache.
Parsing recipes: 100% |#####################################################################################################################################################################| Time: 0:00:00
Parsing of 3592 .bb files complete (3590 cached, 2 parsed). 5394 targets, 554 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
Initialising tasks: 100% |##################################################################################################################################################################| Time: 0:00:03
Checking sstate mirror object availability: 100% |##########################################################################################################################################| Time: 0:00:06
Sstate summary: Wanted 466 Local 17 Network 304 Missed 145 Current 1111 (68% match, 90% complete)
NOTE: Executing Tasks
NOTE: Tasks Summary: Attempted 4216 tasks of which 4212 didn't need to be rerun and all succeeded.
INFO: Failed to copy built images to tftp dir: /tftpboot
[INFO] Successfully built project
The build is complete when the final output is [INFO] Successfully built project.
* Similar to the previous article, the TFTP server is not used, so it is ignored here.
Build results are generated in images/linux.
$ ls images/linux/
boot.scr rootfs.cpio.gz rootfs.tar.gz u-boot.bin zynq_fsbl.elf
config rootfs.cpio.gz.u-boot system.bit u-boot.elf
image.ub rootfs.ext4 system.dtb uImage
pxelinux.cfg rootfs.jffs2 u-boot-dtb.bin vmlinux
rootfs.cpio rootfs.manifest u-boot-dtb.elf zImage
*All names, company names, product names, etc. mentioned herein are trademarks or registered trademarks of their respective companies.