kernel的module目录名疑问

2023-12-31 16:36
文章标签 module 疑问 kernel 目录名

本文主要是介绍kernel的module目录名疑问,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

kernel的module目录名疑问

遇到的问题:
当修改内核后重新编译后烧到设备上,启动后发现kernel的module名和uname -r对不上了,导致驱动无法加载,出现如下的错误信息

modprobe: can't change directory to '4.1.15-g8b02ff45-dirty': No such file or directory

原因:kernel的module目录匹配是由kernel编译时生成的版本决定的,本来制作rootfs时创建module文件夹名字是4.1.15,但是修改了内核,内核的version生成信息变了,相应的源码如下:

# Read KERNELRELEASE from include/config/kernel.release (if it exists)
KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
....
define filechk_kernel.releaseecho "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
endef# Store (new) KERNELRELEASE string in include/config/kernel.release
include/config/kernel.release: include/config/auto.conf FORCE$(call filechk,kernel.release)

$(KERNELRELEASE)就是最终生成的4.1.15-g8b02ff45-dirty, 它由$(KERNELVERSION)setlocalversion 脚本执行的结果拼接而成,其中$(KERNELVERSION)就是内核原本的版本号4.1.15,而
-g8b02ff45-dirty就是脚本的输出, setlocalversion 脚本如下:

	# Check for git and a git repo.if test -z "$(git rev-parse --show-cdup 2>/dev/null)" &&head=`git rev-parse --verify --short HEAD 2>/dev/null`; then# If we are at a tagged commit (like "v2.6.30-rc6"), we ignore# it, because this version is defined in the top level Makefile.if [ -z "`git describe --exact-match 2>/dev/null`" ]; then# If only the short version is requested, don't bother# running further git commandsif $short; thenecho "+"returnfi# If we are past a tagged commit (like# "v2.6.30-rc5-302-g72357d5"), we pretty print it.if atag="`git describe 2>/dev/null`"; thenecho "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'# If we don't have a tag at all we print -g{commitish}.elseprintf '%s%s' -g $headfifi# Is this git on svn?if git config --get svn-remote.svn.url >/dev/null; thenprintf -- '-svn%s' "`git svn find-rev $head`"fi# Check for uncommitted changesif git diff-index --name-only HEAD | grep -qv "^scripts/package"; thenprintf '%s' -dirtyfi# All done with gitreturnfi

这里主要分为两个部分

  1. 获取当前这一份源码对应的内核版本的git tag信息(没有tag就输出commit-id), 然后拼接在内核主版本号后面,也就是上面的g8b02ff45
  2. 获取kernel仓库当前是否存在git或者svn仓库是否存在自己的修改提交,如果存在则拼接-dirty在后面

这篇关于kernel的module目录名疑问的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/556581

相关文章

Linux_kernel驱动开发11

一、改回nfs方式挂载根文件系统         在产品将要上线之前,需要制作不同类型格式的根文件系统         在产品研发阶段,我们还是需要使用nfs的方式挂载根文件系统         优点:可以直接在上位机中修改文件系统内容,延长EMMC的寿命         【1】重启上位机nfs服务         sudo service nfs-kernel-server resta

笔记整理—内核!启动!—kernel部分(2)从汇编阶段到start_kernel

kernel起始与ENTRY(stext),和uboot一样,都是从汇编阶段开始的,因为对于kernel而言,还没进行栈的维护,所以无法使用c语言。_HEAD定义了后面代码属于段名为.head .text的段。         内核起始部分代码被解压代码调用,前面关于uboot的文章中有提到过(eg:zImage)。uboot启动是无条件的,只要代码的位置对,上电就工作,kern

欧拉系统 kernel 升级、降级

系统版本  cat  /etc/os-release  NAME="openEuler"VERSION="22.03 (LTS-SP1)"ID="openEuler"VERSION_ID="22.03"PRETTY_NAME="openEuler 22.03 (LTS-SP1)"ANSI_COLOR="0;31" 系统初始 kernel 版本 5.10.0-136.12.0.

[Linux Kernel Block Layer第一篇] block layer架构设计

目录 1. single queue架构 2. multi-queue架构(blk-mq)  3. 问题 随着SSD快速存储设备的发展,内核社区越发发现,存储的性能瓶颈从硬件存储设备转移到了内核block layer,主要因为当时的内核block layer是single hw queue的架构,导致cpu锁竞争问题严重,本文先提纲挈领的介绍内核block layer的架构演进,然

Kernel 中MakeFile 使用if条件编译

有时需要通过if  else来选择编译哪个驱动,单纯的obj-$(CONFIG_)就不是很方便,下面提供两种参考案例: 案例一: 来源:drivers/char/tpm/Makefileifdef CONFIG_ACPItpm-y += tpm_eventlog.o tpm_acpi.oelseifdef CONFIG_TCG_IBMVTPMtpm-y += tpm_eventlog.o

jupyter在加载pkl文件时报错ModuleNotFoundError: No module named 'pandas.core.internals.managers'; '的解决方法

笔者当看到这个错误的时候一脸懵逼,在pycharm上正常运行的code 放在jupyter就不成了,于是就研究一翻。 一开始以为自己的pkl文件有问题,研究重点放在这里,最后发现不是。 然后取搜索pycharm和jupyter下的python的\Lib\site-packages\pandas\core\internals有什么不同 发现jupyter下没有pandas\core\intern

【NodeJS】Error: Cannot find module 'ms'

转载自:http://blog.csdn.net/echo_ae/article/details/75097004 问题: Error: Cannot find module 'ms'at Function.Module._resolveFilename (module.js:469:15)at Function.Module._load (module.js:417:25)at Module

【虚拟机/服务器】配置ngx_http_empty_gif_module记录

下载Nginx源码 查看Nginx内置模块 1、在可视化界面中 可以看到 ngx_http_empty_gif_module.c 是Nginx的内置模块,不需要再进行安装 2、在bash命令行中 tar nginx 解压后进入nginx目录,./configure --help | grep empty_gif 即可查看我想要的 ngx_http_empty_gif_module

笔记整理—内核!启动!—kernel部分(1)驱动与内核的关系

首先,恭喜完成了uboot部分的内容整理,其次补充一点,uboot第一部分和第二部分的工作不是一定的,在不同的版本中,可能这个初始化早一点,那个的又放在了第二部分,版本不同,造成的工作顺序不同,但终归是要完成基本内容初始化并传参给kernel的。         那么至于驱动与内核的关系,用一张图来说明最适合不过:         驱动位于OS层的中下层与硬件相接。驱动是内

多个,多层嵌套module,打aar包

参考https://blog.51cto.com/4259297/1699714 1.在要打包的module中下添加fat-aar.gradle文件。(该文件只能在项目个gradle是2.3.3是才可食用) 2.把项目的gradle修改为2.3.3,但是不打包的gradle依然是以前的。 3.由于打包的的gradle和不打包的是不一样的,所以需要在修改gradle的文件中的添加判断标志