Skip to content. | Skip to navigation

Sections
You are here: Home Support Knowledge Base How can I build and boot compressed kernel images?

How can I build and boot compressed kernel images?

The default image.elf and image.ub system images are not compressed. Is it possible to create and boot from compressed images, to save Flash memory space?

Problem Description

By default, PetaLinux system images (image.elf, image.ub) are not compressed.  This results in faster kernel boot times, at the expense of additional flash memory usage required to store the image.

If you need to save flash memory, and can afford the increased boot time, it is possible to compress these images.

As of PetaLinux SDK v1.2, there is no automated procedure for generating compressed images.  This will be addressed in a future release.  It is also necessary to make a small modification to the u-boot configuration.  These steps are described below.

Prepare u-boot for decompressing large images

1. Edit the file which is in petalinux-dist/u-boot/include/configs/petalogix-microblaze-auto.h.template:

  1. Search for the definition of CONFIG_SYS_BOOTMAPSZ
  2. Replace its definition by  "#define CONFIG_SYS_BOOTMAPSZ (16 << 20)"
  3. Add "#define CONFIG_SYS_BOOTM_LEN 0x1000000" below the CONFIG_SYS_BOOTMAPSZ definition

Creating a compressed image

1. Rebuild the PetaLinux system image (run 'make' from the petalinux-dist directory)

2. After rebuilding PetaLinux, in the petalinux-dist/ directory, run the following command to create a compressed image:

$ gzip --force --best images/linux.bin

$ u-boot/tools/mkimage -A microblaze -O linux -T kernel -C gzip \
-a <MAIN_MEMORY_BASE_ADDR> -e <MAIN_MEMORY_BASE_ADDR> \
-n "PetaLinux 2.6-MMU" -d images/linux.bin.gz images/image.ub  

In this example please note

  • The <MAIN_MEMORY_BASE_ADDR> is the physical base address of the main memory IP CORE;
  • "\" is the line continue sign

3. copy the images/image.ub to the TFTP directory, the default one is /tftpboot

4. boot the board with the latest built u-boot.

5. In the u-boot, set the "netstart" variable with the following u-boot command:

u-boot> set netstart <MEM_ADDRESS_TO_TFTP_KERNEL_IMAGE>

The "netstart" variable is the memory address to store the TFTP kernel image. The offset of this this address should not be less than the size of the uncompressed kernel image.

E.g. for a memory base address is 0x48000000, and an uncompressed kernel image size of 9.5M, the offset of the "netstart" should be larger than 9.5M.

In this case, you would set "netstart" to 0x48a00000 (a 10Mbyte offset from main memory start)

6. After you have set the "netstart", you can run "netboot" from u-boot to TFTP and boot the compressed kernel image.

Resolution

A future release of PetaLinux SDK will have the ability to automatically generate compressed system images.

Document Actions
Quick Contact
Our customers say

The people at PetaLogix have been excellent to deal with; John and his team have been knowledgeable, professional and responsive at all stages and we fully recommend them.

Jim Law
Sr Hardware Designer, Iris Power LP

 
Site by:
Personal tools