How to reduce the kernel image size?

cancel
Showing results for 
Search instead for 
Did you mean: 

How to reduce the kernel image size?

5,275 Views
naveennvn
Contributor III

Hi all,

     I am using LS2085AQDS board. I need to reduce the kernel image size for that i disabled some configs as per my requirement in kernel configuration file.

     Currently my Image size is 8 MB. I need to make it as below 5 MB.

     Is there any other ways for reducing kernel image size?

Thanks,

Naveen.

Labels (1)
12 Replies

1,951 Views
lunminliang
NXP Employee
NXP Employee

Hello naveennvn,

Perhaps you can have a look at this:

Kernel Size Tuning Guide - eLinux.org

It describes Linux-tiny patches, and also some related config options and their recommended value such as:

CONFIG optionDescriptionDefaultSmall
CONFIG_CORE_SMALL tune some kernel data sizes N Y
CONFIG_NET_SMALL tune some net-related data sizes N Y
CONFIG_KMALLOC_ACCOUNTINGturn on kmalloc accounting N Y *
CONFIG_AUDIT_BOOTMEM print out all bootmem allocations N Y *
CONFIG_DEPRECATE_INLINEScause compiler to emit info about inlines N Y *
CONFIG_PRINTK allow disable of printk code and message dataY N


Have a great day,
Lunmin

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,951 Views
naveennvn
Contributor III

Hi Lunmin,

               Thanks for your support. From where i need to do these changes in .config file or ls2085a_defconfig file. I did the changes in both the files and compiled successfully also kernel image size is reduced. Exactly in which file i need to do this changes.

               And one more thing in .config file so many configs are there. I need to know how that configs are created and enabled. Can you help me please..?

Thanks,

Naveen

0 Kudos

1,951 Views
yipingwang
NXP TechSupport
NXP TechSupport

Hello naveennvn,

Would you please let me why you want to reduce the Kernel image?


Have a great day,
Yiping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,951 Views
naveennvn
Contributor III

Hi Yiping,

        Thanks for your great support,

        I know while creating kernel itb the kernel image is compressed automatically on that time my 8MB kernel image is compressed to 4MB. Actually my requirement is to make the kernel image as below 5MB in uncompressed mode for that i excluded some unwanted configs in ls2085a_defconfig and .config file.

        Because, now my kernel itb size is 40MB i need to make it as below 20MB for that i removed some packages in rootfs. But that one is not enough for my requirement for that i'm reducing the kernel image size.

        I don't know this way is correct or wrong. If its wrong means please correct me and help me to make the kernelitb below 20MB.

Thanks,

Naveen

0 Kudos

1,951 Views
yipingwang
NXP TechSupport
NXP TechSupport

Hello naveennvn,

The simple way to generate a kernel itb image below 20M is using fsl-image-minimal as rootfs image type, and the built kernel itb image is about 11M.

You need to modify "ROOTFS_IMAGE" variable as "fsl-image-minimal" in meta-fsl-networking/images/fsl-image-kernelitb.bb, then execute "bitbake fsl-image-kernelitb"  to rebuild the itb image again.

Not sure whether this method is acceptable for you.


Have a great day,
Yiping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,951 Views
naveennvn
Contributor III

Hi Yiping,

May i know the difference between fsl-image-core and fsl-image-minimal.

How to add a package in minimal file?

Thanks,

-Naveen

0 Kudos

1,951 Views
yipingwang
NXP TechSupport
NXP TechSupport

Hello Naveen,

fsl-image-minimal contains basic packages to boot up a board.

fsl-image-core contains common open source package and FSL specific packages.

Please add the package name in the variable "IMAGE_INSTALL" in the recipe meta-fsl-networking/images/fsl-image-minimal.bb.


Have a great day,
Yiping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,951 Views
naveennvn
Contributor III

Hi Yiping,

     I'm using ls2085aqds board. It contains 8 xfi ports. while booting u-boot and kernel it shows 12 interfaces.

    

     may i know what are all the remaining four interfaces?

     And how to remove those interfaces? Because those interfaces only took more time consumption. So i need to reduce that.

     Can u please help me on that..

Logs :

1.U-Boot :

      DPNI1 [PRIME], DPNI2, DPNI3, DPNI4, DPNI5, DPNI6, DPNI7, DPNI8, DPNI9, DPNI10, DPNI11, DPNI12

2. Kernel :

[    9.914707] fsl_ldpaa_eth dpni.1: ldpaa ethernet: Probed interface ni1

[   10.984891] fsl_ldpaa_eth dpni.2: ldpaa ethernet: Probed interface ni2

[   12.057551] fsl_ldpaa_eth dpni.3: ldpaa ethernet: Probed interface ni3

[   13.130733] fsl_ldpaa_eth dpni.4: ldpaa ethernet: Probed interface ni4

[   14.203885] fsl_ldpaa_eth dpni.5: ldpaa ethernet: Probed interface ni5

[   15.277054] fsl_ldpaa_eth dpni.6: ldpaa ethernet: Probed interface ni6

[   16.350270] fsl_ldpaa_eth dpni.7: ldpaa ethernet: Probed interface ni7

[   17.422924] fsl_ldpaa_eth dpni.8: ldpaa ethernet: Probed interface ni8

[   18.495092] fsl_ldpaa_eth dpni.9: ldpaa ethernet: Probed interface ni9

[   19.573250] fsl_ldpaa_eth dpni.10: ldpaa ethernet: Probed interface ni10

[   20.651592] fsl_ldpaa_eth dpni.11: ldpaa ethernet: Probed interface ni11

[   21.729916] fsl_ldpaa_eth dpni.12: ldpaa ethernet: Probed interface ni12

Thanks,

-Naveen

0 Kudos

1,951 Views
naveennvn
Contributor III

Hi


     Can anyone help on this..?

Thanks,

-Naveen

0 Kudos

1,951 Views
yipingwang
NXP TechSupport
NXP TechSupport

Hello naveennvn,

Please create a new thread to track your new problem.

Thanks,

Yiping

0 Kudos

1,951 Views
naveennvn
Contributor III

Hi Yiping,

          Thanks for your responses,

          Now i got the reduced size kernel itb.

Thanks,

-Naveen.

0 Kudos

1,951 Views
yipingwang
NXP TechSupport
NXP TechSupport

Hello naveennvn,

The 8M Kernel image is uncompressed.

In LS2085 you need to use Kernel.itb file which includes Linux Kernel, Platform Device Tree and Rootfs.

In the Yocto build environment, please run the command

bitbake fsl-image-kernelitb

You will get the image kernel-ls2085aqds.itb.

Here is an example how to boot the system.

If kernel image is greater than 16MB, set the following environment variable as follows to specify the kernel size.

setenv kernel_size 0x2800000

This variable should be updated based on Kernel image size.

Linux kernel parameters are set via the u-boot variable bootargs. The standard parameters are:

setenv bootargs ‘console=ttyS0,115200 root=/dev/ram0 earlycon=uart8250,mmio,0x21c0600,115200 ramdisk_size=2000000 default_hugepagesz=2m hugepagesz=2m hugepages=16’

These parameters:

Select file system to be a ram disk populated from an image in the kernel itb file.

Allocate huge pages for NADK use.

Boot the kernel image located in vBank0. The image needs to be copied to DDR first.

cp.b $kernel_start $kernel_load $kernel_size

bootm $kernel_load


Have a great day,
Yiping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------