当前位置:网站首页>单独编译内核模块
单独编译内核模块
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
边栏推荐
- 研究:数据安全工具在 60% 的情况下无法抵御勒索软件
- Implementing Yang Hui triangle with cyclic queue C language
- Sqoop import and export operation
- JDBC -- extract JDBC tool classes
- 从39个kaggle竞赛中总结出来的图像分割的Tips和Tricks
- 实战模拟│JWT 登录认证
- UNIX socket advanced learning diary -ipv4-ipv6 interoperability
- Detailed structure and code of inception V3
- Learning items
- Leetcode-1. Sum of two numbers (Application of hash table)
猜你喜欢

SAP 自开发记录用户登录日志等信息

Add a new cloud disk to Huawei virtual machine

Master-slave mode of redis cluster

Storage Basics

UNIX socket advanced learning diary -ipv4-ipv6 interoperability

超高效!Swagger-Yapi的秘密

Resnet+attention project complete code learning

非技术部门,如何参与 DevOps?

Taobao order amount check error, avoid capital loss API

2021.12.16-2021.12.20 empty four hand transaction records
随机推荐
Taobao short videos are automatically released in batches without manual RPA open source
Kotlin流程控制、循环
Understand redis persistence mechanism in one article
UNIX socket advanced learning diary -ipv4-ipv6 interoperability
Simply take stock reading notes (2/8)
Redis cluster configuration
在家庭智能照明中应用的测距传感芯片4530A
#yyds干货盘点#js截取文件后缀名
Super efficient! The secret of swagger Yapi
10 minute fitness method reading notes (5/5)
Pytoch monolayer bidirectional_ LSTM implements MNIST and fashionmnist data classification
CVPR 2022 | 基于稀疏 Transformer 的单步三维目标识别器
Language model
Simply take stock reading notes (1/8)
GPON technical standard analysis I
Oppo Xiaobu launched Obert, a large pre training model, and promoted to the top of kgclue
ActiveMQ installation and deployment simple configuration (personal test)
ZABBIX monitors mongodb (template and deployment operations)
[superhard core] is the core technology of redis
Compilation principle reading notes (1/12)