Reading Notes Building embedded linux system Chapter 5 kernel thinking

Source: Internet
Author: User

General linux provides a compiled kernel, but this method is rarely used in embedded operating systems. We will provide a simple kernel configuration as much as possible to remove features we don't need. First, we need to select the linux kernel.

We can get the official Linux kernel version (official, upstream or mainline) at http://www.kernel.org/which is provided by Torvalds and other volunteers around the world. Although version 2.4 is still used on many devices, it should be based on version 2.6 for new development. These versions are usually more concerned with x86 desktop and server, but they do not ignore embedded devices. The embedded operating system is related to the CPU structure. For example, in the result of ARM, ARM developers add specific patches based on the official version. These patches will be fed back to Linus and entered into the official version. We may choose linux kernel as a website community. Someone or a group of people will maintain your selected architecture, such as ARM and PowerPC. If we change the kernel code, we should give feedback as soon as possible so that your program can be used in the next version, which is also required by GPL.

We can also get the kernel from a third-party manufacturer. Although it is based on the upstream version, it includes many patches that provide special functions, and many modifications have been made to revise bugs, there may be many differences in its upstream versions. This is a bit similar to the kernel encapsulated by moblin.

After we select the kernel, we configure the kernel and select the desired part. The embedded architecture includes the following options: Code maturity level options, General setup, Loadable module support, Block layer, Networking, Device drivers, Filesystems, Kernel hacking, Security options, Cryptographic options, library routines. The first step is to select the correct CPU architecture. You can use make config, make oldconfig, make menuconfig, and make xconfig to generate a. config file in source code. Menuconfig is generally used. For some xconfig architectures, such as PPC, the menu may be faulty. The previous chapter describes how to use the cross plateform toolchain. The command is as follows: $ make ARCH = arm CROSS_COMPILE = arm-linux-menuconfig.

In makefile, there is an EXTRAVERSION parameter. For example, if it is set to-rmk1, the kernel is 2.6.29-rmk1, which can be used to provide different versions, such as adding some modules.

The next step is compile, including kernel image and kernel modules. The example for compiling kernel is make ARCH = arm CROSS_COMPILE = arm-linux-zImage. zImage indicates gzip compression. For x86, it can also be bzImage (big zImage, and bz2 compression), this step is used to verify that we have correctly configured the kernel, or whether the cross-development tool chain environment is correct. After compilation, You can compile the kernel module, for example, make ARCH = arm CROSS_COMPILE = arm-linux-modules. If you want to delete the previously processed content, including the configuration file, compiled. o file, and kernel img, you can use the make ARCH = arm CROSS_COMPILE = arm-linux-distclean command. Before using this command, save the configuration file img.

Install the SDK after compilation. This will be described in Chapter 6th and in Chapter 9th. For managing multiple kernel img, each includes zImage or bzImage under vmlinux, System. map,. config, and arch/your_arch/boot. Some architectures, such as PPC, have many boot directories. Therefore, img may not be set to arch/your_arch/boot/zImage, but may be arch/ppc/images/vmlinux.gz. We recommend that you store all of them in the $ (PRJROOT)/images/path. Kernel module installation, which is included in makefile, will be installed in the/lib/modules directory by default. However, we use the cross environment instead of updating the kernel module of the local machine. Example: $ make ARCH = arm CROSS_COMPILE = arm-linux-INSTALL_MOD_PATH =$ {PRJROOT}/images/modules-2.6.20 modules_install. After that, we will build the dependencies required by the module running in the module and use depmod. However, this command does not use the cross environment. We will download depmod from the busybox website. pl. Some operations will be verified in our next experiment.

A common cause of Kernel errors is the kernel panic. When the system gets a serious error (for example, the root file system location is missing), it stops all processes and generates a kernelpanic message. The recovery of panic is system restart. You can set panic = 1 in the boot parameter of kernel (restart after 1 second ). However, in the actual running environment, sometimes the restart is not enough, so we need to remind the operator of the emergency. In other words, we need to redefine the processing method after the panic appears. This is defined in kernel/panic. C and can be rewritten separately.

Related Article

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.