Linux kernel 如何为特定的内核版本构建内核和内核模块?

Linux kernel 如何为特定的内核版本构建内核和内核模块?,linux-kernel,arm,kernel-module,Linux Kernel,Arm,Kernel Module,我需要构建内核来拥有vermagic 3.10.28-gbc1b510-33899-g9fa745e SMP preempt mod_unload modversions ARMv7 但在通过modinfo构建和验证某些模块后,它会显示出来 3.10.28 preempt mod_unload modversions ARMv6 看起来我无法加载模块,因为不同的vermagic。如何使vermagic的内核和模块完全相同?。我正在使用buildroot 我创建这个shell脚本是为了准备构建

我需要构建内核来拥有vermagic

3.10.28-gbc1b510-33899-g9fa745e SMP preempt mod_unload modversions ARMv7
但在通过modinfo构建和验证某些模块后,它会显示出来

3.10.28 preempt mod_unload modversions ARMv6
看起来我无法加载模块,因为不同的vermagic。如何使vermagic的内核和模块完全相同?。我正在使用buildroot

我创建这个shell脚本是为了准备构建

#!/bin/sh
export PATH=$PATH:/buildroot-2018.02.3/output/host/arm-buildroot-linux-gnueabi/bin:/buildroot-2018.02.3/output/host/bin:/buildroot-2018.02.3/output/host/sbin:/buildroot-2018.02.3/output/host/bin
export LD_LIBRARY_PATH=/buildroot-2018.02.3/output/host/lib
export LIBRARY_PATH=/buildroot-2018.02.3/output/host/lib
export PKG_CONFIG_PATH=/buildroot-2018.02.3/output/host/arm-buildroot-linux-gnueabi/sysroot/usr/lib/pkgconfig
exec /bin/bash
然后我进入文件夹

/buildroot-2018.02.3/output/build/linux-3.10.28/

然后复制.config并

make ARCH=arm menuconfig


我使用的是原始内核konfig,另外还选择了一些选项作为模块构建,而不需要修改任何其他选项。

有linux-3.10.28/arch/arm/Makefile文件。在这个文件中有那些定义

arch-$(CONFIG_CPU_32v7)     :=-D__LINUX_ARM_ARCH__=7 $(call cc-option,-march=armv7-a,-march=armv5t -Wa$(comma)-march=armv7-a)
arch-$(CONFIG_CPU_32v6)     :=-D__LINUX_ARM_ARCH__=6 $(call cc-option,-march=armv6,-march=armv5t -Wa$(comma)-march=armv6)
我在某个地方找到了一个建议,让我去替换它

arch-$(CONFIG_CPU_32v6)     :=-D__LINUX_ARM_ARCH__=6 $(call cc-option,-march=armv6,-march=armv5t -Wa$(comma)-march=armv6)

我奥尔索取消了这两项注释:

tune-$(CONFIG_CPU_V6)       :=$(call cc-option,-mtune=arm1136j-s,-mtune=strongarm)
tune-$(CONFIG_CPU_V6K)      :=$(call cc-option,-mtune=arm1136j-s,-mtune=strongarm)
我补充说

-gbc1b510-33899-g9fa745e SMP
作为kernel.config中的本地_版本


现在modinfo打印的版本字符串是一样的。

我知道在哪里添加-gbc1b510-33899-g9fa745e,但我不知道为什么模块没有SMP-它是在kernel.config中选择的,不知道为什么它是为armv6而不是ARMV7构建的。你在交叉编译吗?是的,我正在使用buildroot的gcc进行corss编译。在PCI上构建arm在linux源代码foder的Makefile中将-march=armv7添加到CFLAGS之后,我会尝试,但它不会像编译
make-ARCH=arm-CROSS\u COMPILE=/usr/bin/arm-linux-gnueabi-CFLAGS=-march=armv7-a那样编译smth。您需要传递编译器要编译的体系结构。我猜这默认为armv6,但您可以使用
-march
-mcpu
进行切换。
arch-$(CONFIG_CPU_32v6)     :=-D__LINUX_ARM_ARCH__=7 $(call cc-option,-march=armv7-a,-march=armv5t -Wa$(comma)-march=armv7-a)
tune-$(CONFIG_CPU_V6)       :=$(call cc-option,-mtune=arm1136j-s,-mtune=strongarm)
tune-$(CONFIG_CPU_V6K)      :=$(call cc-option,-mtune=arm1136j-s,-mtune=strongarm)
-gbc1b510-33899-g9fa745e SMP