Linux-driven Learning note 01--linux Kernel compilation

Source: Internet
Author: User
Tags gtk

Since the learning materials used are "Linux device Driver Development (second edition)", most of the text description of the Linux drive learning notes comes from this book, the study notes series used for their own learning and understanding of a way of review and review.

#make Config (the most traditional text-based configuration interface, not recommended)
#make menuconfig (Text menu-based configuration Interface)
#make Xconfig (requires QT to be installed)
#make Gconfig (requires GTK + to be installed)
Make config, make menuconfig, make xconfig and make gconfig used in configuring the Linux 2.6 kernel
The most recommended of these 4 ways is make menuconfig, which is not dependent on QT or GTK + and is very intuitive.

Make Menuconfig's configuration main interface:

Is the real time clock menu in the device Drive directory, and the image corresponding driver is located under SOURCE/LINUX-2.6.32-DEVKIT8500/DRIVERS/RTC,

The corresponding kconfig is as follows, it can be found that all the content in this interface is defined by the Kconfig file.

Kconfig:

# # RTC class/drivers configuration#config rtc_lib tristatemenuconfig rtc_class tristate"Real Time Clock"default n Depends on!S390Selectrtc_lib help Generic RTC class support. If you say yes here, you'll be allowed to plug one or MoreRTCs to your system. You'll probably want to enable one or Moreof the interfaces below. This driver can also is built as a module. If So, the module would be called RTC-Core.ifrtc_classconfig Rtc_hctosysBOOL "Set system time from RTC on startup and resume"depends on Rtc_class=y default y help If you say yes here, the system Time(Wallclock) would be set using the value of the read from a specified RTC device. This was useful to avoid unnecessary fsck runs at boot Time, and to network Better.config Rtc_hctosys_devicestring "RTC used to set the system time"depends on Rtc_hctosys=y default"rtc0"Help the RTC device that'll be used to (re) initialize the system clock, usually rtc0. Initialization is DoneWhen the system is starts up, and if it resumes from a low power state. This device should record Time inchUTC, since the kernel won'T dotimezone correction. The driver forThis RTC device must is loaded before Late_initcall functions run, so it must usually is statically linked. This clock should is battery-backed, so, it reads the correct TimeWhen the system boots from a power-off state.      Otherwise, your system would need an external clock source (like an NTP server). If the clock you specify are not battery backed, it could still be useful to reinitialize system TimeWhen the resuming from SystemSleepstates. Do not specify a RTC here unless it stays powered during all this system's supported sleep states.config Rtc_debugBOOL "RTC Debug Support"depends on Rtc_class=y help Say yes here to enable debugging supportinchThe RTC Framework and individual RTC Drivers.comment"RTC Interfaces"Config Rtc_intf_sysfs boolean"/SYS/CLASS/RTC/RTCN (SYSFS)"depends on SYSFS default Rtc_class help Say Yes hereifwant to use your RTCs using SYSFS interfaces,/SYS/CLASS/RTC/RTC0 through/sys/.../RTCN. If unsure, say Y.config Rtc_intf_proc boolean"/PROC/DRIVER/RTC (Procfs for rtc0)"depends on proc_fs default Rtc_class help Say Yes hereifYou want to use your first RTC through the proc interface,/proc/driver/RTC.      Other RTCs is not being available through that API. If unsure, say Y.endif # Rtc_class


The source file is nearly thousands of lines, here only to intercept the previous section for analysis,

Kconfig
Kernel configuration script file syntax is relatively simple, mainly including the following aspects.
(1) Menu entry.
Most of the kernel configuration options correspond to a menu entry in Kconfig:
Config modversions
BOOL "Module Versioning support"

Help
   usually. Modules compiled with your kernel.
  Saying Y here makes it ... The
Config keyword defines the new configuration options, and the next few lines define the properties for that configuration option. The properties of configuration options include type, data range, input hints, dependencies, selection relationships and help information, and default values.
Each configuration option must specify a type, including bool, TriState, String, hex, and int, where tristate and string are the two basic types, and the other types are based on both of these basic types. After the type definition can be followed by the input prompt, the following two segments of the script is equivalent:
bool "Networking support"
and
bool
Prompt "Networking"
the general format of the input prompt is:
Prompt <prompt> [if <expr>]
where optional if is used to represent the dependency of the hint. The
default value is in the format:
default <expr> [if <expr>]
One configuration option can have any number of default values, in which case only the first defined value is available. If the user does not set the corresponding option, the value of the configuration option is the default value. The
dependency is in the format:
depends on (or requires) <expr>
If multiple dependencies are defined, they are separated by a "&&" interval. Dependencies can also be applied to all other options in the menu (also accept if expressions), the following two-segment script is equivalent:
bool "foo" if bar
default y if bar
and
depends on bar
bool " The format of the Foo "
Default y
Selection relationship (also known as a reverse dependency) is:
Select <symbol> [if <expr>]
A If B is selected, B is automatically selected if A is selected. The expr (expression) in the
Kbuild Makefile is defined as:

<expr>:: = <symbol>
<symbol> ' = ' <symbol>
<symbol> '! = ' <symbol>
' (' <expr> ') '
'! ' <expr>
<expr> ' && ' <expr>
<expr> ' | | ' <expr>
That is, expr is made up of symbol, two symbol equals, two symbol, and expr's assignment, non, and
or operational composition. The symbol is divided into two categories, one is the very number symbol defined by the menu entry definition configuration option, and the other
Class is a constant symbol that is part of expr.
The format of the data range is:
Range <symbol> <symbol> [if <expr>]
option settings for int and hex types can accept input value ranges, the user can only enter greater than or equal to the first symbol,
A value less than or equal to the second symbol.
The format of the Help information is:
Help (or---help---)
Begin
...
End
The help information ends entirely with text indentation recognition. "---help---" and "help" have no difference in function, design "---help---"
The intention is to separate the configuration logic in the file from the prompts for the developer.
The Menuconfig keyword functions like config, but it requires all the sub-options to be independent
The line display.
(2) menu structure.
The position of the menu entry in the menu tree structure can be determined in two ways. The first way is:
Menu "Network Device Support"
Depends on NET
Config netdevices
...
Endmenu
All menu entrances between "menu" and "Endmenu" will be the "Network Device Support" sub-dish
Single. Also, all submenu options inherit the dependency of the parent menu, for example, "Network device Support" for "NET"
Dependencies are added to the dependency list of the configuration options netdevices.
Note that the "Network device Support" item followed by the menu is just 1 menus and does not have a corresponding actual configuration option
And there are 3 different states. This is the difference between it and CONFIG.
Another way is to generate a menu structure by analyzing dependencies. If the menu option depends to a certain extent on the previous selected
Item, it can be a submenu of this option. If the parent option is "N", the child option is not visible, and if the parent option is visible, the child option
to be visible. For example:
Config MODULES
BOOL "Enable loadable Module Support"
Config modversions
BOOL "Set version information on all module symbols"
Depends on MODULES

Comment "Module support disabled"
Depends on! MODULES
Modversions is directly dependent on MODULES, which is only visible if MODULES is not "n".
In addition, the Kconfig may also use the words "choices ... endchoice", "comment", "If...endif"
Legal structure. The structure of "choices ... endchoice" is:
Choice
<choice options>
<choice block>
Endchoice "
It defines a selection group whose accepted options (choice options) can be any of the properties described earlier, such as LDD6410
The VGA output resolution can be 1 024!768 or 800! 600, the Drivers/video/samsung/kconfig defines the
Under the choice:
Choice
Depends on FB_S3C_VGA
Prompt "Select VGA Resolution for s3c Framebuffer"
Default fb_s3c_vga_1024 _768
Config fb_s3c_vga_1024 _768
BOOL "1 024 *[email protected]"
---help---
Tba
Config fb_s3c_vga_640_480
BOOL "640*[email protected]"
---help---
Tba
Endchoic

The following describes the Makefileunder DRIVERS/RTC:

# # Makefile forRTC class/drivers. #ifeq ($ (config_rtc_debug), y) extra_cflags+= -Ddebugendifobj-$ (config_rtc_lib) + = rtc-Lib.oobj-$ (config_rtc_hctosys) + =Hctosys.oobj-$ (config_rtc_class) + = rtc-CORE.ORTC-core-y: =CLASS.O interface.oobj-$ (config_rtc_intf_alarm) + =Alarm.oobj-$ (config_rtc_intf_alarm_dev) + = alarm-DEV.ORTC-core-$ (config_rtc_intf_dev) + = rtc-DEV.ORTC-core-$ (config_rtc_intf_proc) + = rtc-PROC.ORTC-core-$ (CONFIG_RTC_INTF_SYSFS) + = rtc-sysfs.o# Keep the list ordered.obj-$ (config_rtc_drv_ab3100) + = rtc-Ab3100.oobj-$ (config_rtc_drv_at32ap700x) + = rtc-At32ap700x.oobj-$ (config_rtc_drv_at91rm9200) + = rtc-At91rm9200.oobj-$ (config_rtc_drv_at91sam9) + = rtc-At91sam9.oobj-$ (config_rtc_drv_au1xxx) + = rtc-Au1xxx.oobj-$ (config_rtc_drv_bfin) + = rtc-Bfin.oobj-$ (config_rtc_drv_bq4802) + = rtc-Bq4802.oobj-$ (config_rtc_drv_cmos) + = rtc-Cmos.oobj-$ (config_rtc_drv_coh901331) + = rtc-Coh901331.oobj-$ (CONFIG_RTC_DRV_DM355EVM) + = rtc-Dm355evm.oobj-$ (config_rtc_drv_ds1216) + = rtc-Ds1216.oobj-$ (config_rtc_drv_ds1286) + = rtc-Ds1286.oobj-$ (config_rtc_drv_ds1302) + = rtc-Ds1302.oobj-$ (config_rtc_drv_ds1305) + = rtc-Ds1305.oobj-$ (config_rtc_drv_ds1307) + = rtc-Ds1307.oobj-$ (config_rtc_drv_ds1374) + = rtc-Ds1374.oobj-$ (config_rtc_drv_ds1390) + = rtc-Ds1390.oobj-$ (config_rtc_drv_ds1511) + = rtc-Ds1511.oobj-$ (config_rtc_drv_ds1553) + = rtc-Ds1553.oobj-$ (config_rtc_drv_ds1672) + = rtc-Ds1672.oobj-$ (config_rtc_drv_ds1742) + = rtc-Ds1742.oobj-$ (config_rtc_drv_ds3234) + = rtc-Ds3234.oobj-$ (config_rtc_drv_efi) + = rtc-Efi.oobj-$ (config_rtc_drv_ep93xx) + = rtc-Ep93xx.oobj-$ (config_rtc_drv_fm3130) + = rtc-Fm3130.oobj-$ (config_rtc_drv_generic) + = rtc-Generic.oobj-$ (config_rtc_drv_isl1208) + = rtc-Isl1208.oobj-$ (config_rtc_drv_m41t80) + = rtc-M41t80.oobj-$ (config_rtc_drv_m41t94) + = rtc-M41t94.oobj-$ (config_rtc_drv_m48t35) + = rtc-M48t35.oobj-$ (config_rtc_drv_m48t59) + = rtc-M48t59.oobj-$ (config_rtc_drv_m48t86) + = rtc-M48t86.oobj-$ (CONFIG_RTC_MXC) + = rtc-Mxc.oobj-$ (config_rtc_drv_max6900) + = rtc-Max6900.oobj-$ (config_rtc_drv_max6902) + = rtc-Max6902.oobj-$ (config_rtc_drv_msm6242) + = rtc-Msm6242.oobj-$ (CONFIG_RTC_DRV_MV) + = rtc-MV. Oobj-$ (config_rtc_drv_omap) + = rtc-Omap.oobj-$ (config_rtc_drv_pcap) + = rtc-Pcap.oobj-$ (config_rtc_drv_pcf8563) + = rtc-Pcf8563.oobj-$ (config_rtc_drv_pcf8583) + = rtc-Pcf8583.oobj-$ (config_rtc_drv_pcf2123) + = rtc-Pcf2123.oobj-$ (config_rtc_drv_pcf50633) + = rtc-Pcf50633.oobj-$ (config_rtc_drv_pl030) + = rtc-Pl030.oobj-$ (config_rtc_drv_pl031) + = rtc-Pl031.oobj-$ (config_rtc_drv_ps3) + = rtc-Ps3.oobj-$ (CONFIG_RTC_DRV_PXA) + = rtc-Pxa.oobj-$ (config_rtc_drv_r9701) + = rtc-R9701.oobj-$ (CONFIG_RTC_DRV_RP5C01) + = rtc-Rp5c01.oobj-$ (config_rtc_drv_rs5c313) + = rtc-Rs5c313.oobj-$ (config_rtc_drv_rs5c348) + = rtc-Rs5c348.oobj-$ (config_rtc_drv_rs5c372) + = rtc-Rs5c372.oobj-$ (config_rtc_drv_rx8025) + = rtc-Rx8025.oobj-$ (config_rtc_drv_rx8581) + = rtc-Rx8581.oobj-$ (config_rtc_drv_s35390a) + = rtc-S35390a.oobj-$ (config_rtc_drv_s3c) + = rtc-S3c.oobj-$ (config_rtc_drv_sa1100) + = rtc-Sa1100.oobj-$ (config_rtc_drv_sh) + = rtc-SH. Oobj-$ (config_rtc_drv_starfire) + = rtc-Starfire.oobj-$ (config_rtc_drv_stk17ta8) + = rtc-Stk17ta8.oobj-$ (config_rtc_drv_stmp) + = rtc-Stmp3xxx.oobj-$ (config_rtc_drv_sun4v) + = rtc-Sun4v.oobj-$ (config_rtc_drv_test) + = rtc-Test.oobj-$ (config_rtc_drv_twl4030) + = rtc-Twl.oobj-$ (config_rtc_drv_tx4939) + = rtc-Tx4939.oobj-$ (config_rtc_drv_v3020) + = rtc-V3020.oobj-$ (config_rtc_drv_vr41xx) + = rtc-Vr41xx.oobj-$ (config_rtc_drv_wm831x) + = rtc-Wm831x.oobj-$ (config_rtc_drv_wm8350) + = rtc-Wm8350.oobj-$ (config_rtc_drv_x1205) + = RTC-X1205.O

This is primarily a brief introduction to the Kbuild (Kernel compilation system) Makefile in the sub-directories of the kernel source code, which is most often accessible to kernel modules or device-driven developers.
Makefile's syntax includes the following aspects.
(1) Target definition.
The goal definition is to define what content to compile as a module, which to compile and connect to the kernel.
For example:
obj-y + = foo.o
Indicates that the FOO.C or Foo.s file will be compiled FOO.O and connected into the kernel, andobj-mIndicates that the file is to be used as a modulo
Block compilation.no targets other than Y and M will be compiled in the Obj-x form.。
A more common practice is to determine how files are compiled based on the config_ variable of the. config file, such as:
Obj-$ (config_isdn) + = ISDN.O
Obj-$ (config_isdn_ppp_bsdcomp) + = ISDN_BSDCOMP.O
In addition to the objectives of the obj-form, there are lib-y libraries, hostprogs-y host programs and other targets, but the basic should be
Used in specific directories and situations.
(2)the definition of a multi-file module.
The simplest Makefile, as in the previous verse, is enough, if a module consists of multiple files, it will be slightly
Miscellaneous, this time should use the module name plus-y or-objs suffix form to define the module's constituent files. As in the following example:
#
# Makefile for the Linux ext2-filesystem routines.
#
Obj-$ (config_ext2 _fs) + = EXT2.O
ext2-y: = balloc.o dir.o file.o fsync.o ialloc.o inode.o \
IOCTL.O namei.o super.o symlink.o
ext2-$ (config_ext2 _fs_xattr) + = XATTR.O xattr_user.o xattr_trusted.o
ext2-$ (config_ext2 _fs_posix_acl) + = ACL.O
ext2-$ (config_ext2 _fs_security) + = XATTR_SECURITY.O
ext2-$ (config_ext2 _fs_xip) + = XIP.O
The name of the module is Ext2, and the final chain of BALLOC.O, DIR.O, FILE.O and many other target files are delivered to EXT2.O until Ext2.ko
files, and whether including XATTR.O, ACL.O, and so on, depends on the configuration of the kernel configuration file, for example, if Config_
EXT2
_fs_posix_acl is selected, the compilation acl.c gets ACL.O and eventually links into ext2.

(3) Iteration of the directory hierarchy.
The following example:
Obj-$ (config_ext2 _fs) + = ext2/
When the value of Config_ext2_fs is Y or M, Kbuild will include the ext2 directory in the target of the downward iteration.

Linux-driven Learning note 01--linux Kernel compilation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.