当前位置:网站首页>单独编译内核模块
单独编译内核模块
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
边栏推荐
- Notes for preparation of information system project manager --- information knowledge
- GPON technical standard analysis I
- Detailed steps for upgrading window mysql5.5 to 5.7.36
- Learning items
- Redis clean cache
- Correct opening method of redis distributed lock
- How can labels/legends be added for all chart types in chart. js (chartjs.org)?
- Clear neo4j database data
- Full text search of MySQL
- Transactions from December 27 to 28, 2021
猜你喜欢

Making and using the cutting tool of TTF font library

Transactions from December 27 to 28, 2021

Summary of C language learning problems (VS)

Preliminary exploration of basic knowledge of MySQL

Average lookup length when hash table lookup fails

谈谈我写作生涯的画图技巧

Pytoch uses torchnet Classerrormeter in meter

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

Implementing Yang Hui triangle with cyclic queue C language
![[figure neural network] GNN from entry to mastery](/img/e2/bb045fb03bc255b8659f9ca7cdd26b.jpg)
[figure neural network] GNN from entry to mastery
随机推荐
10 minute fitness method reading notes (1/5)
Leetcode-1. Sum of two numbers (Application of hash table)
Pytoch counts the number of the same elements in the tensor
滴滴开源DELTA:AI开发者可轻松训练自然语言模型
Solution to order timeout unpaid
Flume common commands and basic operations
谈谈我写作生涯的画图技巧
Kotlin function
UNIX socket advanced learning diary -ipv4-ipv6 interoperability
Distance measuring sensor chip 4530a used in home intelligent lighting
激动人心!2022开放原子全球开源峰会报名火热开启!
Annotation problem and hidden Markov model
PIP command reports an error pip is configured with locations that requires tls/ssl problems
实战模拟│JWT 登录认证
[figure neural network] GNN from entry to mastery
Volatile instruction rearrangement and why instruction rearrangement is prohibited
Distributed cache architecture - cache avalanche & penetration & hit rate
JDBC -- extract JDBC tool classes
以VMware创新之道,重塑多云产品力
Pinduoduo flag insertion remarks API