Analysis of the configuration process of Linux transplantation

Publisher:BlissfulCharmLatest update time:2024-08-26 Source: cnblogsKeywords:Linux Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The Linux transplantation process has been listed in the transplantation steps of Linux transplantation. Now let's analyze the Linux configuration process. The following two configuration processes will be analyzed:


1. Make s3c2410_defconfig analysis


2. Make menuconfig analysis


1. Make s3c2410_defconfig analysis


First, start analyzing from the top-level Makefile and find a target similar to smdk2410_defconfig. Found the %config target. This means that targets with the suffix config follow this rule. The config in front of %config is a Kconfig keyword, indicating the beginning of a configuration option.


416 config %config: scripts_basic outputmakefile FORCE

417 $(Q)mkdir -p include/linux include/config

418 $(Q)$(MAKE) $(build)=scripts/kconfig $@

Continue to analyze the dependencies of the s3c2410_defconfig target scripts_basic outputmakefile FORCE


①, scripts_basic dependency analysis, it is also a target. It has no dependencies, where Q means if V=1 is entered in the command parameter, Q=empty, which means printing this rule, otherwise not printing this rule; MAKE=make is defined in the system parameters.


328 scripts_basic:

349 $(Q)$(MAKE) $(build)=scripts/basic

The build variable is a general variable, which is defined in the $(srctree)/scripts/Kbuild.include file, where srctree is the directory where the Linux kernel is located.


121 build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj

Translate the scripts_basic dependency to


scripts_basic:

make -f $(srctree)/scripts/Makefile.build obj=scripts/basic

It means entering the Makefile.build file make, and the obj parameter is scripts/basic. Then open the Makefile.build file for analysis, and its goal is:


005 src := $(obj)


007 PHONY := __build

008 __build:


083 __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y))

084 $(if $(KBUILD_MODULES),$(obj-m))

085 $(subdir-ym) $(always)

086 @:


Next, analyze the role of src: $(srctree)/scripts/Makefile.build includes the Makefile in the src (i.e. scripts/basic) directory (if there is Kbuild, it includes Kbuild)


16 kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))//kbuild-dir=scripts/basic

17 include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile) // If Kbuild exists, include Kbuild, otherwise protect Makefile

Back to the final goal: the command of the rule is a colon command ":". The colon (:) command is a built-in command of bash and is usually regarded as a true command. The help explanation of bash (help :) is: No effect; the command does nothing. A zero exit code is returned. (No effect, the command is a no-op, and the exit status is always 0).


Except for $(always), (builtin−target)(lib-target) (extra−y)(subdir-ym), the variables of __build are not defined in $(srctree)/scripts/basic/Makefile, so builtin-target, lib-target, extra-y, and subdir-ym are all empty strings, and only always has a value. always is defined as dochecklxdialog in scripts/kconfig/Makefile, and the comment of the rule where the dochecklxdialog target is located reads # Check that we have the required ncurses stuff installed for lxdialog (menuconfig). In other words, the dependency dochecklxdialog of the build target is used to check whether the ncurses library required to generate the configuration dialog box has been installed on the local machine. If not, the make process will report an error and exit. Therefore, before making menuconfig, we must ensure that the library has been installed locally.


The above text is copied from the analysis of the execution process of make menuconfig when configuring the Linux Kernel. In summary, the scripts_basic dependency is used to check whether the ncurses library has been installed on the local machine. This library is needed when generating the menuconfig interface.


②, outputmakefile dependency analysis, it is also a target, no dependency. If KBUILD_SRC is not empty, the rule is executed. KBUILD_SRC is empty, so it is not executed


358 outputmakefile:

359 ifneq ($(KBUILD_SRC),)

360 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile

361 $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)

362 endif

③、FORCE dependency analysis, it is also a goal. As follows:


1491 PHONY += FORCE

1492 FORCE:

From the above, we can see that FORCE has neither dependent rules nor executable commands under it. If a rule has no commands or dependencies, and its target is not an existing file name. When executing this rule, the target is always considered to be the latest. That is to say: once this rule is executed, make thinks that its target has been updated. When such a target is used as a dependency of a rule, because the dependency is always considered to be updated, the command defined in the rule where the dependency is located will always be executed. The rule where FORCE is located is empty, and nothing is done. FORCE is defined as a pseudo-target, so it is always considered to be the latest (newer than the target) when it is a dependency, so the target with FORCE as a dependency will be regenerated every time make is run. Here, the rule command of the FORCE pseudo-target is empty, so FORCE is equivalent to a keyword in the Kbuild system. If we want a target to be regenerated every time make is run, we write FORCE as the dependency of the target.


The above text is copied from the analysis of the make menuconfig execution process when configuring the Linux Kernel.



④. Then analyze the first rule $(Q)mkdir -p include/linux include/config, which means creating two folders include/linux include/config


⑤. Finally, analyze the second rule $(Q)$(MAKE) $(build)=scripts/kconfig $@ and expand it to get:


make -f $(srctree)/scripts/Makefile.build obj=scripts/kconfig smdk2410_defconfig

The above rule means calling the Makefile.build file, and the final target is s3c2410_defconfig. From the analysis of the first item above, we can know that the Makefile.build file contains scripts/kconfig/Makefile, and s3c2410_defconfig is defined in this file:


66 %_defconfig: $(obj)/conf

67 $(Q)$< -D arch/$(ARCH)/configs/$@ arch/$(ARCH)/Kconfig

Expand to:


66 s3c2410_defconfig: scripts/kconfig/conf

67 scripts/kconfig/conf -D arch/arm/configs/s3c2410_defconfig arch/arm/Kconfig

It means that the conf program is generated first, and then the conf program is used to parse the s3c2410_defconfig file and the Kconfig file to configure the board, and finally the .config file is generated for calling when making uImage.


1. Make menuconfig analysis, this target is consistent with the s3c2410_defconfig target, both are %config, so only the final stage of analysis, calling the Makefile.build file, including scripts/kconfig/Makefile, and menuconfig is defined in this file:


13 menuconfig: $(obj)/mconf

14 $< arch/$(ARCH)/Kconfig

Therefore, the command of the menuconfig target rule is scripts/kconfig/mconf arch/arm/Kconfig. mconf is actually an executable file in the scripts/kconfig directory. In this command, the arch/arm/Kconfig string is passed as a command line parameter to the executable file to run. If the executable file has .config content, the configuration interface is generated based on the .config content file; otherwise, the configuration interface is generated based on the menu configuration provided by the arch/arm/Kconfig file.


NOTE: Why is scripts/kconfig/mconf an executable file? Continue to read the content of scripts/kconfig/Makefile:


lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o

lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o


conf-objs := conf.o zconf.tab.o

mconf-objs := mconf.o zconf.tab.o $(lxdialog)

kxgettext-objs := kxgettext.o zconf.tab.o


hostprogs-y := conf qconf gconf kxgettext


ifeq ($(MAKECMDGOALS),menuconfig)

hostprogs -y += mconf

endif


ifeq ($(MAKECMDGOALS),xconfig)

qconf-target := 1

endif

ifeq ($(MAKECMDGOALS),gconfig)

gconf-target := 1

endif



ifeq ($(qconf-target),1)

qconf-cxxobjs := qconf.o

qconf-objs := kconfig_load.o zconf.tab.o

endif


If you need to compile some executable files for use in the kernel compilation stage during the kernel compilation process, you need to use the native program support feature of the Kbuild framework. In the Kbuild framework, the hostprogs-y variable is used specifically to indicate some executable files that need to be used in the kernel compilation stage. Through hostprogs-y += mconf, it indicates to the make program that mconf is an executable file that needs to be used in the compilation stage. In addition, the Kbuild framework uses the -objs suffix to indicate that the corresponding executable file needs to be linked and generated through multiple target files. mconf-objs := mconf.o zconf.tab.o $(lxdialog) indicates to make that the mconf file is generated by linking mconf.o zconf.tab.o lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o. Furthermore, when the generation rules are not explicitly stated, the Kbuild framework assumes that the .o file is compiled from the .c or .S file with the same name.


After saving the configuration information, a .config file will be generated in the kernel root directory, which saves the kernel configuration information.


Keywords:Linux Reference address:Analysis of the configuration process of Linux transplantation

Previous article:Analysis of make uImage compilation process in Linux transplantation
Next article:Linux transplantation steps

Recommended ReadingLatest update time:2024-11-16 09:22

A simple input subsystem program for Linux driver
In the brief analysis of the input subsystem of the Linux driver, we have analyzed the composition of the input subsystem. It is composed of the device layer, the core layer, and the event layer. The core layer provides some functions common to the device layer and the event layer, such as registration functions, un
[Microcontroller]
A simple input subsystem program for Linux driver
Linux breaks 3% PC market share for first time 30 years after launch
The PC market is dominated by the Windows operating system. Most business applications run the Windows operating system, although there are alternatives. However, Linux users often dream of the arrival of the "Year of Desktop Linux", hoping that one day, Linux will begin to dominate the PC market and begin large-scale
[Embedded]
Linux breaks 3% PC market share for first time 30 years after launch
Linux-2.6.38 to tiny6410 porting manual (1): nand flash
Environment: VirtualBox+ubuntu 10.04 Compiler, friendly, comes with arm-linux-gcc-4.5.1-v6-vfp-20101103.tgz Hardware: tiny6410, core board number 1107 1. Download the source code of linux-2.6.38, ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.38.tar.bz2 2. Unzip tar xvfj /mnt/ubuntu/linux
[Microcontroller]
Linux-2.6.38 to tiny6410 porting manual (1): nand flash
OK6410A development board (VIII) 22 linux-5.11 OK6410A start_kernel Functional perspective Phase 1
CPU0 From theKernel of u-boot to stext in start_kernel of linux - start_kernel Initialization of CPU registers sp register cpsr Supervisor Mode irq disabled fiq disabled little endian Initialization of cp15 registers cache dcache icache write buffer mmu page table domain access CPU1 … I
[Microcontroller]
ARM+Linux represents the future trend of embedded systems
Introduction: "Because ARM is the world's largest IP licensing company, all chip companies in the mobile phone field are based on ARM architecture, so we need to let people in the market and industry know about ARM's latest technology." James Bruce of ARM said. Not long ago, he just attended the 2009 (3rd) Mobile Inte
[Microcontroller]
Analysis of s3c2410 and dma related functions in linux-2.6.24.4
First, let's introduce the registers related to DMA of s3c2410. The s3c2410 has 4 channels of DMA, 9 registers per channel, a total of 36.       1. DISRCn This register stores the source address of the data to be transmitted.     2. DISRCCn Source control register. Bit 1 indicates the bus type of the data source, and
[Microcontroller]
linux i2c device test, i2c-dev driver test code
embed-linux version:linux-2.6.39-exp vmware-linux:ubuntu14.04 hardware: core chip at91sam9x25 cross-compile:arm-none-linux-gnueabi-gcc 4.5.2 code: #include stdio.h #include stdlib.h #include unistd.h #include sys/ioctl.h #include sys/types.h #include sys/stat.h #include fcntl.h //#include sys/select.h #include sys/tim
[Microcontroller]
Using Valgrind on ARM Linux
Linux valgrind ported to ARM-Linux  1. Cross-Compile (1) Download and unzip Valgrind-3.11 (2) Modify the configuration   Change armv7*) to armv7*|arm*) (3) Execute configure ./configure CC=arm-linux-gcc CPP=arm-linux-cpp CXX=arm-linux-g++  --host=arm-linux --prefix=/opt/valgrind/lib Note: CC=arm-linux-gc
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号