Compile driver modules of multiple core versions on one system
Source: Internet
Author: User
Compile the driver modules of multiple core versions on a system-general Linux technology-Linux programming and kernel information. The following is a detailed description. We can compile different driver modules by using only one core source code in one system,
The method is as follows: 1. Install the core source code of the corresponding version.
2, enter the/usr/src directory, assuming you install the source code 2.4.17-1, then you need to establish a connection linux point to/usr/src/linux-2.4.17-1 directory, because many driver source codes use the/usr/src/linux directory.
3. Check the following two directories in your system:/usr/include/linux/usr/include/asm. If it does not exist or is not a join, you need to establish a join, point to/usr/src/linux/include/linux and/usr/src/linux/include/asm: ln-s/usr/src/linux/include/linux/usr/include/linux ln-s/usr/src/linux/include/asm/usr/include/asm
4. Next, modify the configuration of the core source code to adapt to Compiling different versions of the driver module: * first enter the/usr/src/linux directory and run the command make mrproper, then determine the version you want to compile. Assume It is 2.4.17-1 BOOT, first go to the/usr/src/linux directory and modify the Makefile file. The first few lines of the file are as follows: VERSION = 2 PATCHLEVEL = 4 SUBLEVEL = 17 EXTRAVERSION =-1 custom change the last line to the-1 BOOT you need, and save and exit. Then copy the configs/kernel-2.4.18-i386-BOOT.config file to the current directory named. config and then execute the command make oldconfig for configuration. After the configuration is complete, execute the command make dep, and then complete the configuration of the core source code. If you need to compile other versions, such as SMP, repeat the above steps to change the line in Makefile to-1smp, then copy the configs/kernel-2.4.18-i686-smp.config file to the current directory named. and then execute the make oldconfig and make dep commands consecutively. Then, you can re-compile your driver source code.
5. When compiling the driver source code, you can refer to the README or INSTALL file. After modifying the core source code configuration, you can start compiling. After compiling a version, remember to back up the file, because the original driver module will be washed out in the next compilation. After the driver module is compiled, you can find the key word kernel_version to view the corresponding version.
6. If you only get a few C files and header files, it indicates that you want to replace the corresponding files in the core source code and re-compile the core module, it will take a long time to compile, here is a simple method, that is, to compile only this driver without re-compiling all core modules. Run the command: gcc-DMODULE-d1_kernel _-O6-c filename. c can directly compile the C program into a driver module, which is generated under the current directory. * If there are multiple C Programs, you can use the above command to compile them separately, and then use the command ld-r-o destname. o sourcename. o to connect them.
7. If you need to compile it in the core source code, you can execute this command: make-n modules> cmd. sh is not a compilation module, but a command to be executed during compilation, so we can edit cmd. sh file, find the commands for compiling your modules, copy them out, and save them as a script file, then execute your script file in the corresponding directory to get the driver module.
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