使用make-kpkg生成linux-header

$ sudo apt-get install kernel-package

生成linux-headers
$ export ARCH=arm
$ export DEB_HOST_ARCH=armhf
$ export CONCURRENCY_LEVEL=4
$ make-kpkg –rootcmd fakeroot –arch arm –cross-compile arm-linux-gnueabihf- –revision 1.0 –append-to-version -sunxi kernel_headers

生成linux-source
$ make-kpkg –rootcmd fakeroot –arch arm –cross-compile arm-linux-gnueabihf- –revision 1.0 –append-to-version -sunxi kernel_source
一定要指定export DEB_HOST_ARCH=armhf

如果要生成内核image deb包,可以make-kpkg kernel_image,会自动build内核并生成kernel的deb

产生的warning可以忽略

dpkg-architecture: warning: Specified GNU system type arm-linux-gnu does not match gcc system type x86_64-linux-gnu.

通过以上方式生成的deb包,用于host(x86_64)系统上使用,比如其他人在x86_64的ubuntu上想build基于cubieboard2的一个驱动,那么就可以在自己的x86_64 ubuntu上下载前面的linux-headers deb包,然后编译驱动
注:网上有人说linux-headers缺少一些文件,可能会导致某些驱动无法编译通过(如xiaomi wifi使用的MT7601U芯片),可以安装linux-source deb包编译试一试

如果解压linux-headers deb包,可以看到usr/src/scripts/basic/fixdep还是host(x86_64)平台上的可执行文件

$ file fixdep
fixdep: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xcfc5aa7e84cb43b9fc05733bde02ba70083364c0, not stripped

参考:Cross-compiling an Allwinner ARM Linux kernel on Debian amd64
PDF格式:Cross-compiling an Allwinner ARM Linux kernel on Debian amd64