Trick on the Version Magic Number of Linux Kernel__Linux

來源:互聯網
上載者:User

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.