Linux kernel image format

Source: Internet
Author: User

<linux kernel image format >

?? The Linux kernel has images in multiple formats, including Vmlinux, image, Zimage, Bzimage, Uimage, Xipimage, Bootpimage, and more.

? kernel image format Vmlinux

?? The Vmlinux is a bootable, uncompressed, compressible kernel image, and the VM represents virtual Memory. (indicates that Linux supports virtual memory, hence the name VM) it is compiled by the user to the kernel source code, essentially the elf format of the file . That is to say, Vmlinux is the most primitive kernel file that is compiled, uncompressed. This format of the image file is stored on the pc .

? Elf Format files:

The Elf (executable and linkable format) can be implemented in a linked format, and is published as an application binary interface by the UNIX lab, with the extension elf. It is easy to think that in elf format files, in addition to the binary code, It also includes some information about the executable file, such as the symbol table.

?? Vmlinuz is an executable Linux kernel, which is located in/boot/vmlinuz, which is generally a soft link, such as a soft link for vmlinuz-3.13.0-32-generic. Vmlinuz is a compressed file of Vmlinux . There are two ways to build a vmlinuz. One is to build the kernel with "make zimage", and the other is to create the kernel at compile time by command make Bzimage.

? kernel image format: Image

?? image is a kernel code that is processed by Objcopy and contains only binary data , which is not already in elf format , but the kernel image of this format has not been compressed yet.

? objcopy:

?? GNU uses the tool objcopy function is to copy the contents of one target file into another target file, that is, one format of the target file can be converted to another format of the target file. By using binary as the output target (-o binary), you can produce an original binary file that essentially discards all symbols and relocation information, leaving only the binary data.

? kernel image format: zimage

?? Zimage is a kind of compressed image file commonly used by arm Linux, it is vmlinux through Objcopy, Objcopy realizes The vmlinux elf file is copied into a pure binary data file plus The decompression code is compressed by gzip , the command format is #make Zimage. Linux image files in this format are stored on NAND. For small cores, it exists for backwards compatibility.

? kernel image format: bzimage

?? Bzimage is not compressed with bzip2, BZ means big zimage, its format and zimage similar, but the use of different compression algorithm, note thatbzimage compression rate is higher, is a compressed kernel image .
?? Zimage/bzimage: They are not only a compressed file , but also have an uncompressed code embedded in the beginning of the two files. The difference is that the old Zimage unzip the kernel to low-end memory (the first 640K), bzimage the kernel to high-end memory (1M or more). If the kernel is small, you can use one of the zimage or Bzimage, and the two modes of booting the system run the same. The large kernel uses bzimage and cannot use Zimage.

? kernel image format: uimage

?? Uimage is a uboot dedicated image file , which is preceded by a zimage with a length of 0x40 header information (i.e., uimage is a binary file), Information about the type, loading location, generation time, size, and so on of the image file is described in the header information. In other words, zimage and uimage are not any different if executed directly from the 0x40 position of uimage. command format is #make Uimage. Linux image files in this format are stored on NAND.

? how to generate Uimage??

Look for the Mkimage file in the Uboot/tools directory, copy it to the system/usr/local/bin directory, and complete the authoring tool. Then run make uimage in the kernel directory, and if successful, you can find the Uimage file in the arch/arm/boot/directory, which is 64 bytes more than Zimage.
?? Because bootloader generally occupy the 0x0 address, so uimage compared to zimage advantage is can and bootloader coexist. In fact, is an automatic and manual differences, with the description of the Uimage head, u-boot know the corresponding image information, if there is no head you need to manually do those parameters.

? kernel image format: xipimage

?? This format of the Linux image file is stored on Norflash , and the runtime does not need to be copied into the memory SDRAM, can be run directly in the Norflash.

<linux kernel image generation process >

?? In embedded Linux, the boot process of the kernel is divided into two stages. Where the first phase of the startup code is placed in the arch/arm/kernel/head. s file, the file is architecture-related, independent of the hardware surrounding the development Board, primarily initializing the arm core. The second phase of the boot code is the MAIN.C in the Init directory. Now, take the command #make Zimage as an example to illustrate Arm-linux kernel image generation process.

? When the user compiles the Linux kernel source code, the kernel 1th/2 phase will generate the executable file Vmlinux, which is an uncompressed image file, very large, cannot be downloaded directly into the NAND, usually placed on the PC, This is also the most primitive Linux image file. Generally the file is about 50M.

? Image file Vmlinux because it is very large, it must not be directly burned into the NAND, so it needs to be binary, that is, after objcopy processing, so that it contains only the binary data kernel code, to remove unnecessary file information, etc. This makes the image image file. The image file is also uncompressed, and is only smaller by binary. The file is about 5M.

? In general, the kernel image in memory SDRAM is compressed, and is only decompressed at runtime. Therefore, the image file image is compressed using gzip first (compression ratio is about 2:1), then the compressed image file and two files in the source code arch/arm/boot/ Compressed/head. S, ARCH/ARM/BOOT/COMPRESSED/MISC.C together to deliver the compressed image file Compress/vmlinux. The file is around 2.5M. Note that these two source files are decompression programs that are used to decompress the compressed image zimage in the memory SDRAM.

? The compressed image file Compress/vmlinux is binary and eventually generates the image file Zimage, which is approximately 2.5M at the time of the experiment. Of course, when running a compressed image file Zimage in memory SDRAM, the two decompression programs are called First arch/arm/ Boot/compressed/head. S, ARCH/ARM/BOOT/COMPRESSED/MISC.C unzip itself, and then perform the first phase of kernel start code arch/arm/kernel/head. S. In short, when running the kernel in memory, kernel itself, then executes the first-stage boot code. The image file that runs in memory at the time of the experiment is approximately 5 m, the same size as the image image file.

< precautions >

? Website:http://lxr.linux.no/ The site through the Linux kernel source code, without decompression, online query, very convenient.

? The resulting image file Vmlinux is placed in the top-level directory of the source code.

? The resulting image file image, Zimage are all in the Arch/arm/boot directory.

? When you start the board, there will be a lot of hints in HyperTerminal, including:

? Booting Linux .../indicates that the kernel is being copied from NAND to memory/

? Unpressed./indicates that the kernel is being decompressed/

? The kernel kernel in Nandflash is copied to the memory SDRAM only when the user enters the boot command or after the Boot_delay delay time. That is, when Vivi enters command-line mode, there is no kernel kernel in SDRAM.

? Execute the command under the kernel source directory:

? <1> #tree/Print out the directory structure of the kernel source code

? <2> #tree-L 1/print out the first level directory structure of kernel source code

? <3> #tree >/home/lishuai/linux.txt/redirect Kernel source directory structure to a file, users can view their directory structure at any time, very convenient/

<wiz_tmp_tag id= "Wiz-table-range-border" contenteditable= "false" style= "Display:none;" >

From for notes (Wiz)

Linux kernel image format

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.