当前位置:网站首页>单独编译内核模块
单独编译内核模块
2022-07-05 12:38:00 【Li-Yongjun】
前言
在开发和调试某个内核模块时,如果采用整体编译内核的方式,那效率就太低了。我们通常采用单独编译的方式进行。
step 1
拷贝内核模块到 workspace,以英特尔以太网卡驱动 drivers/net/ethernet/intel/ 为例
cp linux-5.13/drivers/net/ethernet/intel/ ./ -rf
step 2
改写 Makefile
原始
# SPDX-License-Identifier: GPL-2.0
#
# Makefile for the Intel network device drivers.
#
obj-$(CONFIG_E100) += e100.o
obj-$(CONFIG_E1000) += e1000/
obj-$(CONFIG_E1000E) += e1000e/
obj-$(CONFIG_IGB) += igb/
obj-$(CONFIG_IGC) += igc/
obj-$(CONFIG_IGBVF) += igbvf/
obj-$(CONFIG_IXGBE) += ixgbe/
obj-$(CONFIG_IXGBEVF) += ixgbevf/
obj-$(CONFIG_I40E) += i40e/
obj-$(CONFIG_IXGB) += ixgb/
obj-$(CONFIG_IAVF) += iavf/
obj-$(CONFIG_FM10K) += fm10k/
obj-$(CONFIG_ICE) += ice/
改写后
# SPDX-License-Identifier: GPL-2.0
#
# Makefile for the Intel network device drivers.
#
obj-m += e100.o
obj-m += e1000/
#obj-$(CONFIG_E1000E) += e1000e/
#obj-$(CONFIG_IGB) += igb/
#obj-$(CONFIG_IGC) += igc/
#obj-$(CONFIG_IGBVF) += igbvf/
#obj-$(CONFIG_IXGBE) += ixgbe/
#obj-$(CONFIG_IXGBEVF) += ixgbevf/
#obj-$(CONFIG_I40E) += i40e/
#obj-$(CONFIG_IXGB) += ixgb/
#obj-$(CONFIG_IAVF) += iavf/
#obj-$(CONFIG_FM10K) += fm10k/
#obj-$(CONFIG_ICE) += ice/
KDIR=/lib/modules/$(shell uname -r)/build
DIRS := . $(shell find -type d)
GARBAGE_PATTERNS := *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions *.mod *.order *.symvers
GARBAGE := $(foreach DIR,$(DIRS),$(addprefix $(DIR)/,$(GARBAGE_PATTERNS)))
all:
$(MAKE) -C $(KDIR) M=$(shell pwd) modules
clean:
rm -rf $(GARBAGE)
注释掉不需要的模块,将需要的模块添加到 obj-m。
OK
边栏推荐
- Hexadecimal conversion summary
- JSON parsing error special character processing (really speechless... Troubleshooting for a long time)
- Add a new cloud disk to Huawei virtual machine
- GPON other manufacturers' configuration process analysis
- Pytoch implements tf Functions of the gather() function
- 滴滴开源DELTA:AI开发者可轻松训练自然语言模型
- 10 minute fitness method reading notes (2/5)
- Yum only downloads the RPM package of the software to the specified directory without installing it
- 我在滴滴做开源
- Wechat enterprise payment to change access, open quickly
猜你喜欢

SAP self-development records user login logs and other information

Storage Basics

ActiveMQ installation and deployment simple configuration (personal test)

I met Tencent in the morning and took out 38K, which showed me the basic smallpox

Kotlin变量

How to connect the API interface of Taobao open platform (super detailed)

Oppo Xiaobu launched Obert, a large pre training model, and promoted to the top of kgclue

Knowledge representation (KR)

Constructing expression binary tree with prefix expression

Pinduoduo flag insertion remarks API
随机推荐
Pytoch loads the initialization V3 pre training model and reports an error
Distributed solution - Comprehensive decryption of distributed task scheduling platform -xxljob
Storage Basics
Research: data security tools cannot resist blackmail software in 60% of cases
Pytorch two-layer loop to realize the segmentation of large pictures
C alarm design
ZABBIX monitors mongodb templates and configuration operations
struct MySQL
JDBC -- use JDBC connection to operate MySQL database
Keras implements verification code identification
非技术部门,如何参与 DevOps?
谈谈我写作生涯的画图技巧
OPPO小布推出预训练大模型OBERT,晋升KgCLUE榜首
从39个kaggle竞赛中总结出来的图像分割的Tips和Tricks
滴滴开源DELTA:AI开发者可轻松训练自然语言模型
2021.12.16-2021.12.20 empty four hand transaction records
Comprehensive upgrade of Taobao short video photosynthetic platform
How can labels/legends be added for all chart types in chart. js (chartjs.org)?
Implementing Yang Hui triangle with cyclic queue C language
Solution to order timeout unpaid