Template:H5-KernelHeaderFile/zh
From FriendlyELEC WiKi
1 编译内核头文件安装包
以下操作在在开发板上进行:
1.1 本文适用于如下版本的固件
固件文件名: nanopi-XXX_sd_friendlycore-focal_4.14_arm64_YYYYMMDD.img 具体信息:
$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04 LTS Release: 20.04 Codename: focal $ cat /proc/version Linux version 4.14.111 (root@ubuntu) (gcc version 6.3.1 20170109 (Linaro GCC 6.3-2017.02)) #192 SMP Thu Jun 10 15:47:26 CST 2021
1.2 安装所需软件包
sudo apt-get update sudo apt-get install -y dpkg-dev libarchive-tools
1.3 制作内核头文件安装包
git clone https://github.com/friendlyarm/linux -b sunxi-4.14.y --depth 1 kernel-h5 cd kernel-h5 rm -rf .git make distclean touch .scmversion make CROSS_COMPILE= ARCH=arm64 sunxi_arm64_defconfig alias tar=bsdtar make CROSS_COMPILE= ARCH=arm64 bindeb-pkg -j4
显示如下信息表示成功:
dpkg-deb: building package 'linux-headers-4.14.111' in '../linux-headers-4.14.111_4.14.111-1_arm64.deb'. dpkg-deb: building package 'linux-libc-dev' in '../linux-libc-dev_4.14.111-1_arm64.deb'. dpkg-deb: building package 'linux-image-4.14.111' in '../linux-image-4.14.111_4.14.111-1_arm64.deb'. dpkg-genchanges: warning: substitution variable ${kernel:debarch} used, but is not defined dpkg-genchanges: info: binary-only upload (no source code included)
1.4 安装
sudo dpkg -i ../linux-headers-4.14.111_4.14.111-1_arm64.deb
1.5 测试
以编译pf_ring模块为例, 参考文档 https://www.ntop.org/guides/pf_ring/get_started/git_installation.html.
git clone https://github.com/ntop/PF_RING.git cd PF_RING/kernel/ make
编译完成后, 使用insmod尝试加载模块:
sudo insmod ./pf_ring.ko