element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
FPGA
  • Technologies
  • More
FPGA
Blog Accelerating PetaLinux BSP Build Time
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join FPGA to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: narrucmot
  • Date Created: 24 Jun 2020 10:11 PM Date Created
  • Views 8445 views
  • Likes 6 likes
  • Comments 2 comments
  • ultra96-v2
  • ultrazed-ev
  • microzed
  • avnet
  • zynq
  • petalinux
  • sstate_dir
  • ultrazed-eg
  • picozed
  • designed by avnet
  • dl_dir
  • zynq mpsoc
  • bsp
  • bash script
  • sstate-cache
  • minized
Related
Recommended

Accelerating PetaLinux BSP Build Time

narrucmot
narrucmot
24 Jun 2020

Have you ever wished that your PetaLinux project didn't take so long to build?  Have you ever wanted a way to make the build happen faster?

 

Alas!  There are simple steps to follow to accelerate your PetaLinux project build times.  As much as a 50% reduction in build time can be achieved!

 

Project Build Caches

The building of a PetaLinux project produces a lot of intermediate output files as bitbake builds the many recipes and processes the thousands of tasks for the u-boot, kernel, and rootfs configurations.  If you have ever examined the 'build' folder of a PetaLinux project you have probably noticed the 'downloads' and 'sstate-cache' folders:

image

These folders hold the intermediate outputs of the build tasks and provide a cache mechanism so the same tasks don't have to be repeated every time 'petalinux-build' is run.  However, if a full 'mrproper' clean ('petalinux-build -x mrproper -f') of a PetaLinux project is run these outputs are deleted, and this makes subsequent project builds take longer as these output cache folders are re-created.  It is sometimes necessary to do a 'mrproper' clean, though, especially when recovering from a previously failed build.  The solution is that there is a way to store these cache folders outside the PetaLinux project folders so they can be reused and shared for future builds.

 

There are two project variables, SSTATE_DIR and DL_DIR, that specify the locations of these cache folders.  The SSTATE_DIR specifies the path to the shared state (sstate) cache and the DL_DIR tells bitbake where to store the source downloads for the packages it needs to build.  The SSTATE_DIR is architecture-specific (AARCH64 for Zynq MPSoC, ARM for Zynq, and mb-full for MicroBlaze).  A PetaLinux project that targets a Zynq device (ARM) cannot share the SSTATE_DIR of a project that targets a Zynq MPSoC (AARCH64) device or a MicroBlaze soft CPU.  However, DL_DIR can be shared by all PetaLinux projects regardless of CPU type.

 

To set the SSTATE_DIR and DL_DIR variables for a PetaLinux project, one must first create the downloads and architecture-specific sstate folders outside of the PetaLinux project.  These folders can be anywhere the user has read/write permissions.  For example the Avnet build scripts (Using Avnet Build Scripts to Build a PetaLinux BSP) will create these folders in the same parent folder as the associated git repository (https://github.com/Avnet/petalinux):

image

Edit the petalinuxbsp.conf file of the PetaLinux project (<project>/project-spec/meta-user/conf/petalinuxbsp.conf) and add the SSTATE_DIR and DL_DIR variables to the end of the file:

DL_DIR = "/path/to/cache/<PetaLinux version>/downloads"

SSTATE_DIR = "/path/to/cache/<PetaLinux version>/sstate_<arm | aarch64 | mb-full>"

 

If the 'downloads' and 'sstate-cache' folders already exist in the build folder of your PetaLinux project you can copy or move their contents to the cache folders you just created.

 

Installed Caches From Xilinx

In addition to storing local copies of the software package downloads and sstate cache, it is also possible to install full archives of the standard PetaLinux packages.  Xilinx provides downloads archives and sstate caches that contain the standard packages that can be built with PetaLinux.  This downloads archive and sstate cache can be downloaded from Xilinx for the version of PetaLinux you are using:

https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/embedded-design-tools.html

 

Extract the downloads and cache archives to a convenient folder on the hard drive.  Since they are PetaLinux version-specific, a good place is probably the PetaLinux install folder:

image

Launch a command window and edit the PetaLinux project configuration to update the 'Local sstate feeds settings' and 'Add pre-mirror url' settings for the locations of the downloads archive and sstate cache.  Don't forget to run the PetaLinux settings shell script first:

$ source /path/to/petalinux/install/settings.sh

$ cd /path/to/petalinux/project

$ petalinux-config

 

Navigate to Yocto Settings -> Add pre-mirror url and enter the path to the installed downloads archive.  Note the path must be prepended with 'file://'.  Click OK:

image

Navigate to Yocto Settings -> Local sstate feeds settings and enter the path to the installed sstate cache.  Click OK:

image

Save and exit the System Configuration editor.

 

Test the Changes with a Fresh Project Build

Clean and rebuild the PetaLinux project:

$ petalinux-build -x mrproper -f

$ petalinux-build

 

Dramatic Improvement in Build Time!

These steps to create project build caches and install the Xilinx-provided caches can have a dramatic effect on reducing build times for your PetaLinux projects.  As much as a 50% reduction in build time can be achieved!  For PetaLinux projects with large filesystems, such as that for Avnet's Ultra96-V2Ultra96-V2 board, this can save many hours of build time.  Imagine all the fun you can have while you aren't waiting for PetaLinux to finish building your project...  image

  • Sign in to reply
  • bartokon
    bartokon over 4 years ago in reply to jrhtech

    You could create local cache repo for all of your petalinux projects, regardless of bsp used, also copying two lines of text is faster than petalinux-config and go through settings image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jrhtech
    jrhtech over 5 years ago

    The downloads and sstate-cache are installed by petalinux and the paths are automatically added by the config process(see the generated file build/conf/plnxtool.conf).   What's not clear is if there is an advantage to adding your own additional paths.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube