Steps for Managing Image Size - 2020.2 English

PetaLinux Tools Documentation Reference Guide (UG1144)

Document ID
UG1144
Release Date
2020-11-24
Version
2020.2 English

The FIT Image size can be reduced using the following methods:

  1. Launch the root file system configuration menu using the following command:
    $ cd <plnx-proj-root>
    $ petalinux-config -c rootfs
  2. Select File System Packages.

    Under this submenu, you can find the list of options corresponding to the root file system packages. If your requirement does not need some of these packages, you can shrink the size of the root file system image by disabling them.

  3. Launch the kernel configuration menu using the following command:
    $ cd <plnx-proj-root>
    $ petalinux-config -c kernel
  4. Select General Setup.

    Under this sub-menu, you can find options to set the config items. Any item that is not mandatory to have in the system can be disabled to reduce the kernel image size. For example, CONFIG_SHMEM, CONFIG_AIO, CONFIG_SWAP, CONFIG_SYSVIPC. For more details, see the Linux kernel documentation.

    Note: Note that disabling of some config items may lead to unsuccessful boot. It is expected that you have the knowledge of config items before disabling them.

    Including extra configuration items and file system packages lead to increase in the kernel image size and the root file system size respectively.

    If the kernel or the root file system size increases and is greater than 128 MB, make the following changes in platform-top.h:

    For U-Boot, distro boot using platform-top.h in PetaLinux is disabled by default. U-Boot autoconfig is disabled in the following menu option.

    $ petalinux-config ---> Auto Config Settings ---> [ ] u-boot autoconfig

    Any U-Boot configuration and environment variables added to platorm-top.h are be included in the U-Boot build when autoconfig is disabled. To fix this issue, use one of the two following methods:

    • Method 1: This method demonstrates how to use the platform-top.h with U-Boot autoconfig disabled.
      1. Remove or comment out the following line in <plnx-proj-root>/project-spec/meta-user/recipes-bsp/u-boot/files/platform-top.h.
        #include <configs/platform-auto.h>
      2. Create a U-Boot fragment config file (for example: bsp.cfg) and set the CONFIG_SYS_CONFIG_NAME as follows in <plnx-proj-root>/project-spec/meta-user/recipes-bsp/u-boot/files/bsp.cfg.
        $ vim <plnx-proj-root>/project-spec/meta-user/recipes-bsp/u-boot/files/bsp.cfg
        CONFIG_SYS_CONFIG_NAME="platform-top"
      3. In <plnx-proj-root>/project-spec/meta-user/recipes-bsp/u-boot/u-boot-xlnx_%.bbappend recipes, include this bsp.cfg file in the SRC_URI variable. Install platform-top.h to u-boot/include/configs in the do_configure_append bitbake task as shown below.
        FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
        
        SRC_URI += " \
            file://platform-top.h \
            file://bsp.cfg \
        "
        
        do_configure_append () {
                if [ "${U_BOOT_AUTO_CONFIG}" = "1" ]; then
                        install ${WORKDIR}/platform-auto.h ${S}/include/configs/
                        install ${WORKDIR}/platform-top.h ${S}/include/configs/
                else
                        install ${WORKDIR}/platform-top.h ${S}/include/configs/
        	fi
        }
        
        do_configure_append_microblaze () {
                if [ "${U_BOOT_AUTO_CONFIG}" = "1" ]; then
                        install -d ${B}/source/board/xilinx/microblaze-generic/
                        install ${WORKDIR}/config.mk ${B}/source/board/xilinx/microblaze-generic/
                fi
        }
      4. Add the desired U-Boot configuration and environment variables to platform-top.h.
      5. Clean the U-Boot-xlnx sstate cache and rebuild the U-Boot-xlnx recipes:
        $ petalinux-build -c u-boot -x cleansstate
        $ petalinux-build -c u-boot
    • Method 2: This method demonstratess how to use platform-top.h with the U-Boot autoconfig enabled.
      1. Run the following PetaLinux command, then enable U-Boot autconfig and save.
        $ petalinux-config ---> Auto Config Settings ---> [*] u-boot autoconfig
      2. Add the desired U-Boot configuration and environment variables to platform-top.h.
      3. Clean the U-Boot-xlnx sstate cache and rebuild the U-Boot-xlnx recipes:
        $ petalinux-build -c u-boot -x cleansstate
        $ petalinux-build -c u-boot
  5. Mention the Bootm length in <plnx-proj-root>/project-spec/meta-user/recipes-bsp/u-boot/files/platform-top.h.
    #define CONFIG_SYS_BOOTM_LEN <value greater than image size>
  6. Undef CONFIG_SYS_BOOTMAPSZ in <plnx-proj-root>/project-spec/meta-user/recipes-bsp/u-boot/files/platform-top.h.