Trick on the Version Magic Number of Linux Kernel

Trick on the Verson Magic Number of Linux Kernel

MAR 15TH, 2013 |
COMMENTS

Recently, I was working on building a modified wireless driver for Nexus
7 to support monitor mode. There are quite a few things that are very
subtle and easy to get confused. I’ll just write down the steps in case
that I forgot and might need them again.

This
is actually a very good guide for building customized kernel module
except the issue I will talk about below.

Kernel vermagic

The version magic number of the kernel that being used to build the
externel module has to be exactly the same as the kernel running on the
device. It won’t be a problem if you build the module and kernel, then
load both of them to the device. However, in this case, I would like to
avoid to build and replace the whole kernel. The wireless driver is the
only kernel module that I want to build. Therefore, the kernel version
magic has to be modified. The vermagic for the device is
“3.1.10-g05b777c SMP preempt mod_unload ARMv7”, while my source code
gives “3.1.10-g22b4fcd-dirty SMP preempt mod_unload ARMv7”. So “3.1.10”
is the kernel version, it should match with the version of the kernel
source. It consists of the following four parts which can be found at
the beginning of Makefile:

这里写图片描述

The guide
indicates that modifying the Makefile as shown below, simply use the VC
number as EXTRAVERSION which is originaly omitted will solve the
problem. However, you will end up with something like
“3.1.10-g05b777c-g22b4fcd-dirty SMP preempt mod_unload ARMv7”.

这里写图片描述

“-g05b777c” is the number of current version generated by the version
control system(git, svn, etc.). After a little dig into Makefile, it
turns out version number is stored in the file
include/config/kernel.release and the local version is generated by the
script scripts/setlocalversion. By default, it will check if version
control system is available. If so, then it will append “dirty” to local
version after the commit number if the commit haven’t been submitted.
That is where “-g22b4fcd-dirty” comes from. We could simply supplement a
parameter as scripts/setlocalversion –save-scmversion and it won’t
generate the local version number.

kernel source root path:Makefile

这里写图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值