Change the temp folder used by PetaLinux

Change the temp folder used by PetaLinux

When working with PetaLinux tools, we need to be wary of the often very sizeable temporary files generated during builds. These temporary files can often take up more than 10GB, and they are crucial for the build process.

By default, PetaLinux tools create a temporary folder internal to the project directory. Having it set this way is useful because our projects are well contained and we have clear insight into the total disk space used by a project. However, it’s not uncommon to encounter configurations where the temporary folder is directed to /tmp. I just came across an example of this in the Vitis Video Analytics SDK repo.

The /tmp directory resides in the filesystem’s root on Linux systems. Typically, this partition isn’t allocated a substantial amount of space – which was the case with my setup, where it was limited to 25GB. Such a configuration can rapidly lead to the /tmp directory filling up, triggering the familiar Linux warning: “Low disk space on dev/sdX.”, and causing the build to crash.

Change the temp folder location

The temp folder used by a PetaLinux project is determined by the parameter CONFIG_TMP_DIR_LOCATION in the file project-spec/configs/config. By default, it looks like this:

#
# TMPDIR Location
#
CONFIG_TMP_DIR_LOCATION="${PROOT}/build/tmp"

The value above puts the temp folder inside the project root, so as long as you put your PetaLinux folder on a disk that has plenty of space, you wont have any problems.