交叉编译Linux设备驱动遇到的坑

0 背景

目标平台架构:ARM64
交叉编译工具链:gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu
编译平台:Ubuntu22.04
目标平台Linux内核源码版本:5.10
编译的东西:普通的测试字符驱动

1 /bin/sh: 1: scripts/basic/fixdep: not found

解决方案:到Linux内核源码目录(非编译平台Ubuntu22.04的,而是目标平台的)下,执行make scripts

2 /bin/sh: 1: scripts/mod/modpost: not found sed: couldn’t flush stdout: Broken pipe

解决方案:到Linux内核源码目录下,执行make modules_prepare