Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to compile ko files in Linux system

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

The content of this article mainly focuses on how to compile ko files in Linux system. The content of the article is clear and clear. It is very suitable for beginners to learn and is worth reading. Interested friends can follow the editor to read together. I hope you can get something through this article!

The ko file is a kernel module file, which is a module loaded by the kernel, usually a driver.

Introduction to KO file:

All the driver modules loaded under Linux are .o files, which are also called object files.

The .ko file is a kernel object file, which differs from .o in that it has more sections, such as .modinfo.

The method of compiling ko files in Linux system: 1. First, extract the downloaded kernel source code and copy it to the / usr/src path:

two。 Switch to the kernel source folder cd / usr/src/linux-2.6.32 under root permission:

3. Configure config:

Here, because my menuconfig cannot be started (according to the online reference materials, I installed ncurses and set the desktop resolution, I can only open it through the command display page (ctrl+alt+f1).), I skipped this step and went straight to make oldconfig (finally, setting the settings for compiling the kernel); 1

4. Compile the kernel make:

5. Install the module make modules_install:

6.make install:

7. Create the initrd file: mkinitramfs-o / boot/initrd.img-2.6.32 (the image is generated after the execution of this step), but the generated image cannot enter the installed kernel after restart. After this execution, continue to execute the next command.

8. Update image: update-initramfs-c-k 2.6.32, where the kernel installation is complete (here I worship the great god I referred to, who thought that different kernel versions could not be accessed after installation, this instruction changed my mind.)

9. Change the startup file: enter the / boot/grub folder and enter the command update-grub

10. Change the startup file: gedit / boot/grub/grub.cfg, then locate the installed kernel information and put it on top of the original kernel information (kernel startup information in curly braces)

11. Change the dwell time of the kernel selection page: or find all the timeout in the grub.cfg to make the change (in seconds). The if judgment does not need to change.

After rebooting, you can choose your new kernel to enter.

The following is the compilation of the .ko file.! Reference books, and access to online materials have not been compiled. Ko file, here is how I compiled:

1. First write a Makefile:

two。 Compile the file: I added the make compilation specification, make-C / lib/modules/2.6.32/build M=/home/linux/work/Testlinux/Testhallo (the .ko file was successfully compiled in this way as well in other projects)

What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

Thank you for your reading. I believe you have some understanding of "how to compile ko files in Linux system". Go to practice quickly. If you want to know more about it, you can follow the website! The editor will continue to bring you better articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report