Jump to content
Electronics-Lab.com Community

Kernel Trimming Ideas Based on the T507 Linux System

Recommended Posts

Purpose of Trimming

Customers sometimes have certain requirements for the boot time after power-on, so it is necessary to tailor the kernel to optimize the boot time and reduce it.Low system power consumption.

Brief Introduction to Makefiles, Kconfig and .config Files

  • Makefile: A file in text form that compiles the source files
  • Kconfig: A file in text for the kernel's configuration menu.
  • .config: The configuration on which the kernel is compiled
  • Kconfig and Makefile files are usually present in the directory structure of the Linux kernel.
  • Distributed at all levels of the catalogue
  • Kconfig constitutes a distributed database of kernel configurations, with each Kconfig describing the kernel associated with the source files of the directory to which it belongs.
  • Configuration menu. Read out the configuration menu from Kconfig when the kernel graphically configures make menuconfig, and save it to.config after the user finishes the configuration.
  • When the kernel is compiled, the main Makefile calls this.config to know how the user has configured the kernel.

Introduction to Makefile and Kconfig Syntax

● Makefile

The Makefile subdirectory is contained by the top-level Makefile. It is used to define what is compiled as a module and what is conditionally compiled.

(1) Direct compilation obj-y +=xxx.o

It means that xxx.o is compiled from xxx.c or xxx.s and compiled directly into the kernel.

(2) Conditional compilation obj-$(CONFIG_HELLO) +=xxx.o

The CONFIG_XXX of the .config file determines whether a file is compiled into the kernel or not.

(3) Module compilation obj-m +=xxx.o

It means that xxx is compiled as a module, i.e. it is compiled when make modules is executed.



● Kconfig

Each config menu item has a type definition. bool: boolean type, tristate: three states (built-in, module, remove), string: a sequence of characters, hex: hexadecimal, integer: a whole number

Function: determine the menu item displayed when make menuconfig.



1) NEW _ LEDS: The name of the configuration option. The prefix "CONFIG _" "is omitted.

2) tristate: Indicates whether the item is programmed into the kernel or into a module. The display as < >, if selected to compile as a kernel module, it will generate a configuration CONFIG_HELLO_MODULE=m in .config. Choosing Y will directly compile into the kernel, generating a configuration CONFIG_HELLO_MODULE=y in .config.

3) bool: This type can only be checked or unchecked. It is displayed as [ ] when making menuconfig, that is, it cannot be configured as a module.

4) dependon: This option depends on another option, only when the dependon is checked, the prompt message of the current configuration item will appear to set the current configuration item.

5) select: Reverse dependency, when this option is checked, the item defined after select is also checked.

6) help: help information.

tristate and bool followed by strings are the configuration item names displayed in make menuconfig.

Definitions in Kconfig like "menuconfig NEW_LEDS" or "menu "Video support for sunxi"" are typically top-level directories of a directory, where in menuconfig you can directly trim the corresponding driver by searching for that configuration item.

Catalogue Hierarchy Iteration :

In Kconfig, there are statements like "source "drivers/usb/Kconfig"" used to include (or nest) new Kconfig files, allowing each directory to manage its own configuration content without having to write all those configurations in the same file, making it easier for modification and management.

Partially Driven Tailoring

1. Tailoring Ideas

Taking the GPADC function as an example, the location of the driver in the source code kernel is:drivers/input/sensor/sunxi_gpadc.c,

So we can go to the Kconfig file in that path, and directly search for "menu” in the Kconfig file, which generally corresponds to the top-level directory of that driver.


We can see that the configuration option is named INPUT_SENSOR, corresponding to the name "Sensors" in menuconfig. Afterwards, we can directly search for this configuration option in menuconfig. Execute make menuconfig at the kernel path

ARCH=arm64 Enter the graphical configuration interface:


On this screen, type /, then INPUT_SENSOR, and press Enter.



As shown in the figure, this item is configured under the Device Drivers ---> Input device support path, and the Generic

The "input layer (needed for keyboard, mouse, ...)" configuration option is set to "y" (yes).


Cancel the configuration for Sensors, then save and exit as a .config file. Afterwards, go back to the OKT507-linux-sdk path, compile the kernel separately, and then package the image.

forlinx@ubuntu:~/work/OKT507-linux-sdk$ ./build.sh kernel

forlinx@ubuntu:~/work/OKT507-linux-sdk$ ./build.sh pack

2. Partial Drive Path



Location of the driver in the source kernel

Device Name

Path in Menuconfig




Device Drivers --->

Remove:Network device support

Network card






Device Drivers ---> Graphics support ---> Frame buffer Devices ---> Video support for sunxi --->Remove: HDMI2.0 Driver Support(sunxi-disp2) (not yet fully modified)

Usb-U disk



Device Drivers ---> USB support ---> Remove:USB Mass Storage support




Device Drivers ---> USB support --->Remove:USB Serial Converter support




Device Drivers ---> Multimedia support ---> Media USB Adapters --->Remove:USB Video Class (UVC)




Device Drivers ---> Multimedia support ---> Media USB Adapters --->Remove:USB Video Class (UVC)




Device Drivers ---> Remove:Watchdog Timer Support




Networking support ---> Bluetooth subsystem support ---> Bluetooth device drivers --->Uncheck all (remember to record the original configuration)




Device Drivers ---> Sound card support ---> Advanced Linux Sound Architecture ---> ALSA for SoC audio support ---> Allwinner SoC Audio support --->Uncheck all (remember to record the original configuration)




Device Drivers ---> Remove:Pulse-Width Modulation (PWM) Support




Device Drivers ---> Multimedia support ---> V4L platform devices --->Remove:sunxi video input (camera csi/mipi isp vipp)driverOpen OKT507-linux-sdk/kernel/linux-4.9/drivers/media/platform/Makefile,comment out obj-y +=













Location of the driver in the source kernel

Path in Menuconfig

Device Name

GT911 touch


Device Drivers ---> Input device support ---> Touchscreens --->Remove:Goodix I2C touchscreen gt911、Goodix I2C touchscreen gt928、TSC2007 based touchscreens

/dev/input/event*View event with evtestCorresponding name, for example:The corresponding name of GPADC issunxi-gpadc0sunxi-gpadc1sunxi-gpadc2sunxi-gpadc3

GT928 touch


TSC2007 touch







Device Drivers ---> Input device supportRemove:Sensors



Device Drivers ---> Multimedia support Remove:Remote controller decoders、Remote Controller devices



Device Drivers ---> Remove:Real Time Clock



The above is the trimming of one of the drivers, other functions can be trimmed following the methods mentioned earlier.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...