开发机是x86,目标机是arm64,如何在开发机将内核的ko编译完成并拷贝到目标机
在开发机如下操作:
首先设置环境变量
test/linux-kernel$ pwd
/home/test/linux-kernel
test/linux-kernel$ mkdir build
test/linux-kernel/build$ cd ..
test/linux-kernel$ export PATH=/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin:$PATH
test/linux-kernel$ export ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
test/linux-kernel$ export CC=aarch64-linux-gnu-gcc
test/linux-kernel$ export INSTALL_MOD_PATH=/home/test/linux-kernel/build
完成menconfig之后完成编译动作
test/linux-kernel$ make
CALL scripts/checksyscalls.sh
CHK include/generated/compile.h
Building modules, stage 2.
MODPOST 305 modules
开始安装到指定目录
test/linux-kernel$ make modules_install
INSTALL arch/arm64/crypto/aes-neon-bs.ko
INSTALL arch/arm64/crypto/chacha20-neon.ko
... ...
INSTALL sound/hda/snd-hda-core.ko
INSTALL sound/pci/hda/snd-hda-codec.ko
INSTALL sound/soc/codecs/snd-soc-hdmi-codec.ko
INSTALL sound/soc/generic/snd-soc-audio-graph-card.ko
INSTALL sound/soc/generic/snd-soc-simple-card-utils.ko
INSTALL sound/soc/generic/snd-soc-simple-card.ko
DEPMOD 4.19.111-embeded
查看目标文件
test/linux-kernel$ ls buil
build/ built-in.a
test/linux-kernel$ ls buil
build/ built-in.a
test/linux-kernel$ ls build
lib
test/linux-kernel$ ls build/lib/
modules
test/linux-kernel$ ls build/lib/modules/
4.19.111-embeded
test/linux-kernel$ ls build/lib/modules/4.19.111-embeded/
build modules.alias modules.builtin modules.builtin.bin modules.dep.bin modules.order modules.symbols source
kernel modules.alias.bin modules.builtin.alias.bin modules.dep modules.devname modules.softdep modules.symbols.bin
然后把 build/lib/modules/4.19.111-embeded 拷贝到目标机的 /lib/modules 目录下

本文介绍如何在x86开发机上为arm64目标机编译Linux内核模块,并将其安装到指定目录。通过设置环境变量及使用特定的交叉编译工具链,实现了内核模块的跨平台编译。

被折叠的 条评论
为什么被折叠?



