4th Day--linux Kernel learning-morning

Source: Internet
Author: User

How to use the drive
1. Compile into the kernel * make Uimage
After entering the system
Mknod/dev/led C 500 0 creating a device node

2. Compile as module M make module
After entering the system
Mknod/dev/led C 500 0 creating a device node
Insmod Fs4412_led_drv.ko (Driver executable program) load driver

Compilation of Uimage
1. Steps
Make Uimage-jnum NUM = number of processors * Processor cores

2. Process
Go to makefile under the top level directory
If I can't find uimage, I'll find the include.
504 include $ (srctree)/arch/$ (srcarch)/makefile ==> arch/arm/makefile
203 Srcarch: = $ (ARCH) =arm

Enter Arch/arm/makefile
299 boot_targets = zimage Image xipimage bootpimage uimage

304 $ (boot_targets): Vmlinux
305 $ (Q) $ (make) $ (build) =$ (boot) machine=$ (machine) $ (boot)/[email protected] ==> arch/arm/boot/uimage

Make-p creating a global variable under the project catalog
Q = @ 272 make = Make
Makefile @make $ (build) Make-c build path executes makefile under the specified path
291 Boot: = Arch/arm/boot

233 Machine: = arch/arm/mach-$ (Word 1,$ (machine-y))/
155 machine-$ (Config_arch_exynos) + = EXYNOS (in config file. config)
Machine=arch/arm/mach-exynos

Make-c arch/arm/boot Machine=arch/arm/mach-exynos Arch/arm/boot/uimage

Enter the Arch/arm/boot/makefile

Include $ (srctree)/$ (machine)/makefile.boot ==> arch/arm/mach-exynos/makefile.boot
1 zreladdr-y + = 0x40008000 uimage start-up address
2 params_phys-y: = 0x40000100 parameter Location

Obj Current makefile Path
$ (obj)/uimage: $ (obj)/zimage Force ==> indicates that a forced build uimage build requires zimage build

$ (obj)/zimage: $ (obj)/compressed/vmlinux force Zimage generated requires arch/arm/boot/compressed/vmlinux

$ (obj)/compressed/vmlinux: $ (obj)/image force
$ (Q) $ (make) $ (build) =$ (obj)/compressed [email protected]

Make-c Arch/arm/boot/compressed/arch/arm/boot/compressed/vmlinux

Enter Arch/arm/boot/compressed/makefile

185 $ (obj)/vmlinux: $ (obj)/vmlinux.lds $ (obj)/$ (HEAD) $ (obj)/piggy.$ (suffix_y). o \
186 $ (Addprefix $ (obj)/, $ (OBJS)) $ (Lib1funcs) $ (ashldi3) \
187 $ (BSWAPSDI2) force

Vmlinux.lds relies on makefile and kconfig under vmlinux.lds.in and upper paths
The head = HEAD.O (by the head in the current directory.) S generation)
suffix_$ (config_kernel_gzip) = GZIP
PIGGY.GZIP.O refers to gzip compression compression code

195 $ (obj)/piggy.$ (suffix_y). O: $ (obj)/piggy.$ (suffix_y) force
192 $ (obj)/piggy.$ (suffix_y): $ (obj)/. /image force PIGGY.GZIP.O generation is dependent on the Image under the upper path

Addprefix The stitching Path
Objs Required Target library files (many)
Lib1funcs feature-related library files
148 Lib1funcs = $ (obj)/LIB1FUNCS.O
154 Ashldi3 = $ (obj)/ASHLDI3.O related to Toolchain
Bswapsdi2 = $ (obj)/BSWAPSDI2.O code related to compression format

Back to Arch/arm/boot/makefile
$ (obj)/image:vmlinux Force represents the Vmlinux under the top-level path

Go back to the top-level path under Makefile
817 vmlinux:scripts/link-vmlinux.sh $ (vmlinux-deps) force
809 Vmlinux-deps: = $ (kbuild_lds) $ (kbuild_vmlinux_init) $ (kbuild_vmlinux_main)
802 export Kbuild_vmlinux_init: = $ (head-y) $ (init-y)
803 Export Kbuild_vmlinux_main: = $ (core-y) $ (libs-y) $ (drivers-y) $ (net-y) All inclusive
804 Export Kbuild_lds: = arch/$ (Srcarch)/kernel/vmlinux.lds


530 Init-y: = init/
531 Drivers-y: = drivers/sound/firmware/
532 Net-y: = net/
533 Libs-y: = lib/
534 Core-y: = usr/

Head-y = HEAD.O (arch/arm/kernel/head. S-generated files) first file launched
Kbuild_lds: = arch/$ (srcarch)/kernel/vmlinux.lds Arch/arm/kernel/vmlinux.lds
To generate the uimage we need.

Vmlinux.lds. LDS Link script tool to generate Vmlinux files
Vmlinux the Real kernel program
Image has been compressed for the first time
Zimage after the second compression
Uimage used the Mkimage to add the head, in order to uboot identification

Vmlinux 60M (no additional drivers added, just the default configuration, the actual add should be about 70M)
Image 5M or so
Zimage 2768232
Uimage 2768296 uimage greater than Zimage 64B is added by Mkimage 64B Head This head is for Uboot to identify to use the head (Uboot version related)

Uboot after loading the kernel uimage read the head-to-zimage for decopressed image--> Vmlinux (really executed in the Development Board program)

The Uimage compilation process is the reverse of the START process

Linux kernel start-up process
The entry is arch/arm/kernel/head. S

4th Day--linux Kernel learning-morning

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.