This section only records the general trimming method without introducing specific file modifications.
Linux Kernel Trimming Steps
1 Modify the ARCH and CROSS_COMPILE environment variables in the makefile
ARCH ?= arm
CROSS_COMPILE ?= XXX (your cross compiler)
2 Find the configuration file xxxdeconfig in the arch/arm/configs folder, and modify it appropriately. Run the following in the root directory:
make xxxdeconfig
3 Run make menuconfig in the root directory. If new content has been added in xxxdeconfig, Kconfig needs to be modified to match xxxdeconfig.
4 Run make in the root directory
This completes the kernel compilation. The modifications made during the execution of xxxdeconfig and menuconfig are a form of trimming.
The Relationship between xxxdeconfig, menuconfig, and .config
Previously, we mentioned running xxxdeconfig and menuconfig. What is their relationship? Running xxxdeconfig generates a .config file, which will eventually be transformed into header files and used by other functions. Some content is as follows:
// For example
CONFIG_CREATE_ARCH_SYMLINK=y
# CONFIG_ARC is not set
CONFIG_ARM=y
# CONFIG_M68K is not set
# CONFIG_MICROBLAZE is not set
# CONFIG_MIPS is not set
# CONFIG_NDS32 is not set
# CONFIG_NIOS2 is not set
# CONFIG_PPC is not set
# CONFIG_SANDBOX is not set
# CONFIG_SH is not set
# CONFIG_X86 is not set
# CONFIG_XTENSA is not set
CONFIG_SYS_ARCH="arm"
CONFIG_SYS_CPU="armv7"
CONFIG_SYS_SOC="zynq"
...
This is equivalent to trimming modifications through a macro file, where relevant content can be added or removed.
menuconfig is a further supplement to the .config file. Running make menuconfig will produce a graphical interface, which first reads the .config content and displays it graphically. Then, modifications to the .config file can be made through the graphical interface.
If new content is added in xxxdeconfig, to make the graphical interface of make menuconfig display it, the Kconfig file needs to be modified to match. The Kconfig file acts as the backend file for menuconfig.
If the .config file is not visible after compilation, it may be hidden. Pressing ctrl+h will display hidden files, and it should be visible.
Uboot Modification Trimming and Differences
The trimming of uboot is basically not much different from the kernel, except that it generally requires one more step (modifying a board-level header file).
1 Modify the ARCH and CROSS_COMPILE environment variables in the makefile
ARCH ?= arm
CROSS_COMPILE ?= XXX (your cross compiler)
2 Find the configuration file xxxdeconfig in the arch/arm/configs folder, and modify it appropriately. Run the following in the root directory:
make xxxdeconfig
3 Run make menuconfig in the root directory. If new content has been added in xxxdeconfig, Kconfig needs to be modified to match xxxdeconfig.
4 Modify the board-level header file XXX.h
5 Run make in the root directory
This completes the kernel compilation. The modifications made during the execution of xxxdeconfig and menuconfig are a form of trimming.
The reason for this additional header file modification step is that the program will reference this header file. Below is a snippet of the .config file:
...
CONFIG_SYS_VENDOR="xilinx"
CONFIG_SYS_BOARD="zynq"
CONFIG_SYS_CONFIG_NAME="zynq_zc70x"
...
The zynq_zc70x.h is the header file that needs to be referenced (generally located in the include folder). Open this file:
...#include <configs/zynq-common.h>...
Continue to open /zynq-common.h
#ifndef __CONFIG_ZYNQ_COMMON_H
#define __CONFIG_ZYNQ_COMMON_H
/* CPU clock */
#ifndef CONFIG_CPU_FREQ_HZ
# define CONFIG_CPU_FREQ_HZ 800000000
#endif
/* Cache options */
#define CONFIG_SYS_L2CACHE_OFF
#ifndef CONFIG_SYS_L2CACHE_OFF
# define CONFIG_SYS_L2_PL310
# define CONFIG_SYS_PL310_BASE 0xf8f02000
#endif
#define ZYNQ_SCUTIMER_BASEADDR 0xF8F00600
#define CONFIG_SYS_TIMERBASE ZYNQ_SCUTIMER_BASEADDR
#define CONFIG_SYS_TIMER_COUNTS_DOWN
#define CONFIG_SYS_TIMER_COUNTER (CONFIG_SYS_TIMERBASE + 0x4)
/* Serial drivers */
/* The following table includes the supported baudrates */
#define CONFIG_SYS_BAUDRATE_TABLE \
{300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400}
#define CONFIG_ARM_DCC
/* Ethernet driver */
#if defined(CONFIG_ZYNQ_GEM)
# define CONFIG_MII
# define CONFIG_SYS_FAULT_ECHO_LINK_DOWN
# define CONFIG_BOOTP_BOOTPATH
# define CONFIG_BOOTP_GATEWAY
# define CONFIG_BOOTP_HOSTNAME
...
As can be seen, it contains many parameters, and relevant parameters can be modified in this file.
Leave a Comment
Your email address will not be published. Required fields are marked *