问题
I'm trying to build the latest linux crypto drivers for a Ubuntu server. Ubuntu server has a running kernel, extras and headers installed. However, the source code for the crypto modules are coming from Torvald's GitHub (and not Ubuntu).
I'm also working from the kernel doc Building External Modules. I cloned the latest kernel with:
git clone --depth=1 https://github.com/torvalds/linux.git
Then:
cd linux
Next:
$ make -C /usr/src/linux-headers-4.2.0-34 M=$PWD crypto
make: Entering directory '/usr/src/linux-headers-4.2.0-34'
ERROR: Kernel configuration is invalid.
include/generated/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.
make: Nothing to be done for 'crypto'.
make: Leaving directory '/usr/src/linux-headers-4.2.0-34'
And:
$ find /usr/src -name 'autoconf.h'
/usr/src/linux-headers-4.2.0-34-generic/include/generated/autoconf.h
$ find /usr/src -name 'auto.conf'
/usr/src/linux-headers-4.2.0-34-generic/include/config/auto.conf
And this:
$ find /usr/src -type d -name 'build'
/usr/src/linux-headers-4.2.0-34/tools/build
/usr/src/linux-headers-4.2.0-34-generic/include/config/build
Trying to use the build
directory results in the following:
$ make -C /usr/src/linux-headers-4.2.0-34/tools/build M=$PWD crypto
make: Entering directory '/usr/src/linux-headers-4.2.0-34/tools/build'
make: *** No rule to make target 'crypto'. Stop.
make: Leaving directory '/usr/src/linux-headers-4.2.0-34/tools/build'
I'm obviously missing something obvious. That's not surprising since I know next to nothing about kbuild. I have an exiting configuration and sources at /usr/src
, and I have new files at $PWD/crypto
. Its not clear to me why I am generating a new configuration for an existing configuration.
How do I update kernel crypto modules against a running kernel provided by someone else?
回答1:
Actually here two things are there to care about:
Is the running kernel version is same are of the source we are using.
As previously compiled kernel may not be having all the dependencies which may be used in latest version, while compilation of external module with latest kernel source may be dependent on any part of the code, which is only present in latest version. So it is recommended to use the latest version kernel with which we are using the external module.
Second, the .config file for kernel compilation
You can copy it from /boot/config(current-version)*
of your file system to .config
in kernel source top directory. Current version we can get it from uname -r
So procedure will be if running version (check with command uname -r) is not equal to downloaded source, then you need to compile and use new kernel or otherwise download same version of kernel as of running kernel. For kernel compilation use the config file present in boot directory, copy it as stated above.
Then you can proceed with a normal way of compiling the external module and load it with running kernel without any issue.
来源:https://stackoverflow.com/questions/36240143/build-external-modules-against-a-running-kernel