Linux驱动编译和加载问题

作者

QQ群:852283276
微信:arm80x86
微信公众号:青儿创客基地
B站:主页 https://space.bilibili.com/208826118

参考

ln: target ‘libcublas’ is not a directory
i.MX6Q kernel compilation for camera/video (gstreamer)
解析 Linux 内核可装载模块的版本检查机制
version magic '3.10.0_hifone SMP mod_unload ARMv7 p2v8 ’ should be '3.10.0_s40 SMP mod_unload ARMv7
error: macro “TIME” might prevent reproducible builds [-Werror=date-time]

编译内核时指定输出目录

$ make O=dir/to/store/output/files
# or
$ export KBUILD_OUTPUT=dir/to/store/output/files/
$ make

error: macro “DATE” might prevent reproducible builds [-Werror=date-time]

ccflags-y += -Wno-error=date-time -Wno-date-time

** 108 printk messages dropped **

这是Xilinx Zynq的默认配置,都改成17。

(14) Kernel log buffer size (16 => 64KB, 17 => 128KB)                                                                           
(12) CPU kernel log buffer size contribution (13 => 8 KB, 17 => 128KB)

多个c文件编译驱动

obj-m:=pcie_chipset.o
pcie_chipset-objs := pcie_ep.o intc/xilinx_intc.o xaxienet/xilinx_axienet_main.o xaxienet/xilinx_axienet_mdio.o

Invalid module format

银河麒麟4.0,在目标机上编译驱动,此时不是交叉编译,/lib/modules下面有几个文件夹,内核路径使用uname -r,否则报上述问题。

loading out-of-tree module taints kernel.

模块依据代码编写与编译时的位置可分:内部模块和外部模块,即 in-tree module 和 out-of-tree module,在内核树外部编写并构建的模块就是外部模块。

version magic '4.13.16 SMP mod_unload ’ should be '4.13.0-36-generic SMP mod_unload ’

修改,

include/generated/utsrelease.h
#define UTS_RELEASE "4.13.16"
#define UTS_RELEASE "4.13.0-36-generic"
include/config/kernel.release
4.13.16
4.13.0-36-generic

或内核源代码的makefile

VERSION = 4
PATCHLEVEL = 13
SUBLEVEL = 16
EXTRAVERSION =
VERSION = 4
PATCHLEVEL = 13
SUBLEVEL = 0
EXTRAVERSION = -36-generic

make modules报错ln: target ‘/source’ is not a directory

sudo -E env "PATH=$PATH" make INSTALL_MOD_PATH=~/Apalis-iMX6-LXDE-Image_2.8.4/rootfs/ modules_install

现象,

zc@ubuntu:~/project$ make modules_install
ln: target '/source' is not a directory
Makefile:1232: recipe for target '_modinst_' failed
make: *** [_modinst_] Error 1

调试Makefile发现,

ln -s /program/zynqmp/linux-xlnx-v2018.2 /project/zynqmp_rootfs/lib/modules/4.14.0-fdk-1.0.0-20181120.1856 /source

版本号后面多加了个空格,导致语法错误,哎。

网卡驱动无法卸载

驱动pcie_chipset Used参数为1,无法卸载,执行ifconfig enp3s0 down之后可以卸载。

$ lsmod
Module                  Size  Used by
pcie_chipset           45502  1
xphy                    2568  0
uio                    14551  1 pcie_chipset
$ sudo ifconfig enp3s0 down
$ lsmod
Module                  Size  Used by
pcie_chipset           45502  0
xphy                    2568  0
uio                    14551  1 pcie_chipset

替换系统驱动文件之后仍加载老驱动

需要更新ramfs,

$ sudo update-initramfs -u
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值