#编译工具链
make tools/install
make toolchain/install
#先进入菜单将要编译的模块选择为M
make menuconfig
make target/linux/{clean,compile}
make package/kernel/linux/{clean,compile}
使用现成工具链,省得编译浪费时间:
wget https://downloads.openwrt.org/releases/21.02.6/targets/mediatek/mt7622/openwrt-sdk-21.02.6-mediatek-mt7622_gcc-8.4.0_musl.Linux-x86_64.tar.xz
tar Jxf openwrt-sdk-21.02.6-mediatek-mt7622_gcc-8.4.0_musl.Linux-x86_64.tar.xz
mv staging_dir staging_dir-back
mv openwrt-sdk-21.02.6-mediatek-mt7622_gcc-8.4.0_musl.Linux-x86_64/staging_dir ./
如mtkhnat模块和ipk位置:
build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/packages/ipkg-aarch64_cortex-a53/kmod-mediatek_hnat/lib/modules/5.4.238/mtkhnat.ko
bin/targets/mediatek/mt7981/packages/kmod-mediatek_hnat_5.4.238-1_aarch64_cortex-a53.ipk
如果编译的最新模块小版本号与系统不一致可用sed修改,要确保模块无大更新,不然可能有兼容性问题。
sed -i 's/5\.4\.238/5\.4\.225/g' build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/packages/ipkg-aarch64_cortex-a53/kmod-mediatek_hnat/lib/modules/5.4.238/mtkhnat.ko
https://openwrt.org/docs/guide-developer/toolchain/single.package
https://forum.openwrt.org/t/how-to-build-an-additional-kernel-module/56575/2
标签:openwrt