c - 在 Linux 中构建 PLX SDK 驱动程序产生 "No such file or directory"

标签 c linux module linux-kernel centos

我正在尝试构建源代码并陷入悲伤。

[root@localhost Driver]# pwd
/usr/src/PlxSdk/Driver
[root@localhost Driver]# ls -la
total 36
drwxr-xr-x. 7 root root  183 Sep 15 18:10 .
drwxr-xr-x. 8 root root  123 Sep 15 18:10 ..
-rwxr-xr-x. 1 root root  658 Sep 15 18:10 buildalldrivers
-rwxr-xr-x. 1 root root 4524 Sep 15 18:10 builddriver
-rw-r--r--. 1 root root  590 Sep 15 18:10 Makefile
...
[root@localhost Driver]# ./buildalldrivers 

   ------------------

Build: Plx8000_NT

- PLA: CentOS Linux release 8.2.2004 (Core) 
- KER: 4.18.0-193.el8.x86_64
- INC: /lib/modules/4.18.0-193.el8.x86_64/build/include
- CPU: x86_64 (64-bit Little Endian)
- CMP: gcc
- TYP: 8000_NT Driver
- PKG: PCI/PCIe SDK v8.00
- CFG: Release

make[1]: *** /lib/modules/4.18.0-193.el8.x86_64/build: No such file or directory.  Stop.
make: *** [/usr/src/PlxSdk/Makefiles/Targets.def:46: BuildDriver] Error 2
   ------------------
我看到了这个信息SO post ,它谈到了我的问题,但没有一个答案有帮助。Use $ uname -r to check the kernel version4.18.0-193.el8.x86_64
投诉是No such file or directory ,但是有一个构建目录,并且确实存在内核开发人员工具。
[root@localhost Driver]# ls -la /lib/modules/4.18.0-193.el8.x86_64
total 16440
drwxr-xr-x.  6 root root    4096 Sep 15 20:20 .
drwxr-xr-x.  4 root root      64 Sep 14 14:27 ..
-rw-r--r--.  1 root root     295 May  8 07:07 bls.conf
lrwxrwxrwx.  1 root root      54 Sep 15 20:20 build -> ../../../usr/src/kernels/4.18.0-193.14.2.el8_2.x86_64/
-rw-r--r--.  1 root root  187648 May  8 07:07 config
drwxr-xr-x. 12 root root     128 Sep 14 14:27 kernel
-rw-r--r--.  1 root root  865312 Sep 14 14:31 modules.alias
-rw-r--r--.  1 root root  827199 Sep 14 14:31 modules.alias.bin
-rw-r--r--.  1 root root     488 May  8 07:07 modules.block
-rw-r--r--.  1 root root    7534 May  8 07:07 modules.builtin
-rw-r--r--.  1 root root    9748 Sep 14 14:31 modules.builtin.bin
-rw-r--r--.  1 root root  287699 Sep 14 14:31 modules.dep
-rw-r--r--.  1 root root  397124 Sep 14 14:31 modules.dep.bin
-rw-r--r--.  1 root root     365 Sep 14 14:31 modules.devname
-rw-r--r--.  1 root root     140 May  8 07:07 modules.drm
-rw-r--r--.  1 root root      59 May  8 07:07 modules.modesetting
-rw-r--r--.  1 root root    1602 May  8 07:07 modules.networking
-rw-r--r--.  1 root root  100539 May  8 07:07 modules.order
-rw-r--r--.  1 root root     553 Sep 14 14:31 modules.softdep
-rw-r--r--.  1 root root  414722 Sep 14 14:31 modules.symbols
-rw-r--r--.  1 root root  505717 Sep 14 14:31 modules.symbols.bin
lrwxrwxrwx.  1 root root       5 May  8 07:07 source -> build
-rw-r--r--.  1 root root  347581 May  8 07:07 symvers.gz
-rw-------.  1 root root 3909996 May  8 07:07 System.map
drwxr-xr-x.  2 root root       6 May  8 07:06 updates
drwxr-xr-x.  2 root root      40 Sep 14 14:27 vdso
-rwxr-xr-x.  1 root root 8913656 May  8 07:07 vmlinuz
-rw-r--r--.  1 root root     166 May  8 07:06 .vmlinuz.hmac
drwxr-xr-x.  3 root root      23 Sep 14 14:30 weak-updates
[root@localhost Driver]# 
构建链接有效且闪烁。
[root@localhost Driver]# ls -la /usr/src/kernels/4.18.0-193.14.2.el8_2.x86_64/
total 5348
drwxr-xr-x.  24 root root    4096 Sep 15 20:56 .
drwxr-xr-x.   3 root root      42 Sep 15 17:13 ..
drwxr-xr-x.  26 root root    4096 Sep 15 17:13 arch
drwxr-xr-x.   3 root root      78 Sep 15 17:13 block
drwxr-xr-x.   2 root root      37 Sep 15 17:13 certs
-rw-r--r--.   1 root root  187644 Jul 26 00:02 .config
drwxr-xr-x.   4 root root      76 Sep 15 17:13 crypto
drwxr-xr-x. 135 root root    4096 Sep 15 17:13 drivers
drwxr-xr-x.   2 root root      22 Sep 15 17:13 firmware
drwxr-xr-x.  73 root root    4096 Sep 15 17:13 fs
drwxr-xr-x.  30 root root    4096 Sep 15 17:14 include
drwxr-xr-x.   2 root root      37 Sep 15 17:14 init
drwxr-xr-x.   2 root root      22 Sep 15 17:14 ipc
-rw-r--r--.   1 root root     575 Jul 26 00:02 Kconfig
drwxr-xr-x.  17 root root    4096 Sep 15 17:14 kernel
drwxr-xr-x.  16 root root    4096 Sep 15 17:14 lib
-rw-r--r--.   1 root root   60925 Jul 26 00:02 Makefile
-rw-r--r--.   1 root root    1325 Jul 26 00:02 Makefile.rhelver
drwxr-xr-x.   3 root root      71 Sep 15 17:14 mm
-rw-r--r--.   1 root root       0 Sep 15 20:51 modules.order
-rw-r--r--.   1 root root 1241984 Jul 26 00:02 Module.symvers
drwxr-xr-x.  70 root root    4096 Sep 15 17:14 net
drwxr-xr-x.  26 root root    4096 Sep 15 17:14 samples
drwxr-xr-x.  13 root root    8192 Sep 15 17:14 scripts
drwxr-xr-x.  10 root root     151 Sep 15 17:14 security
drwxr-xr-x.  26 root root    4096 Sep 15 17:14 sound
-rw-r--r--.   1 root root 3910607 Jul 26 00:02 System.map
drwxr-xr-x.   2 root root       6 Sep 15 20:51 .tmp_versions
drwxr-xr-x.  29 root root    4096 Sep 15 17:14 tools
drwxr-xr-x.   2 root root      37 Sep 15 17:14 usr
drwxr-xr-x.   4 root root      44 Sep 15 17:14 virt
-rw-r--r--.   1 root root      41 Jul 26 00:02 vmlinux.id
[root@localhost Driver]# 
sudo dnf install kernel-devel-$(uname -r)已安装
@Nighthawk663 在他的回答中说 Notice that the "source" link is also broken because it points to build.我的 Source链接也指向构建,但我所做的一切都没有让它去其他任何地方。我不知道这是否是一个有效的评论。
[root@localhost Driver]# rpm -i /home/mnvme/Downloads/kernel-devel-4.18.0-193.el8.x86_64.rpm 
package kernel-devel-4.18.0-193.14.2.el8_2.x86_64 (which is newer than kernel-devel-4.18.0-193.el8.x86_64) is already installed
[root@localhost Driver]# 
PLX SDK Linux Support Release Notes page 说明了一些要求,我遵循了这些要求:In order to build the files supplied, the shell environment variable PLX_SDK_DIR must be set. This should be set to the root location of where the PlxSdk folder is created.
# export PLX_SDK_DIR=$HOME/PlxSdk
#
# Or in my case
export PLX_SDK_DIR=/usr/src/PlxSdk
我确实更新了我的 .bashrc包含该行和注释的文件。
我想验证 gcc工作并且编译器没有问题,所以我构建了 API 和其中一个示例。这是构建样本之一的输出。
[root@localhost Samples]# cd ApiTest
[root@localhost ApiTest]# make

Build: ApiTest

- PLA: CentOS Linux release 8.2.2004 (Core) 
- CPU: x86_64 (64-bit Little Endian)
- CMP: gcc
- TYP: Sample App
- PKG: PCI/PCIe SDK v8.00
- CFG: Release

CC  /usr/src/PlxSdk/Samples/Shared/ConsFunc.c
CC  /usr/src/PlxSdk/Samples/Shared/PlxInit.c
CC  ApiTest.c
LNK ApiTest

Application "App/ApiTest" built successfully

[root@localhost ApiTest]# cd ..
[root@localhost Samples]# 
因此,问题在于严格地构建驱动程序,特别是内核中存在一些使构建工具不满意的东西。
尝试加载驱动程序表明我没有按预期构建驱动程序。 (为了完整起见,我还说明了加载命令。)
[root@localhost Bin]# ./Plx_load 8000d d

Install: Plx8000_DMA_dbg
  Load module......... ERROR: Driver not built or invalid path
    \-- /usr/src/PlxSdk/Driver/Source.Plx8000_DMA/Output/Plx8000_DMA_dbg.ko

[root@localhost Bin]# 
笔记:
PLX 发行说明说明了以下内容,适用于我的问题。

Kernel 2.6 Kernel 2.6 introduced the Linux kernel build system. In order to build PLX drivers, or any other drivers for that matter, the Linux build system requires the following:

·Linux kernel development package, which matches the destination kernel version, must be installed

·In some cases, the current running kernel must be configured and built manually If the PLX driver fails to build, please verify the requirements mentioned above are met.


如前所述,我有与目标内核版本匹配的 Linux 内核开发包,我不确定第二点。我会对此进行调查。
想法?

最佳答案

该问题的具体答案是在样本上创建没有 ../../.. 之类的符号链接(symbolic link)。
我以 root 身份执行了/lib/modules/4.18... 目录中的命令。

ln -s /usr/src/kernels/4.18.0-193.14.2.el8_2.x86_64/ build
这样做然后产生了一个纯蓝色的黑色链接,我可以在其中制作一张 CD。
然后我能够解决我的下一个问题,但第一个问题解决了。
有趣的是我之前尝试过上面的命令。也许我必须安装一些东西然后做那条线。我所知道的是上述一切的高潮解决了这个问题。感谢@JohnBollinger 引导到正确的方向。
[mnvme@localhost Driver]$ ./buildalldrivers 

       ------------------

Build: Plx8000_NT

- PLA: CentOS Linux release 8.2.2004 (Core) 
- KER: ver 4.18.0-193.14.2.el8_2.x86_64
- INC: /lib/modules/4.18.0-193.el8.x86_64/build/include
- CPU: x86_64 (64-bit Little Endian)
- CMP: gcc
- TYP: 8000_NT Driver
- PKG: PCI/PCIe SDK v8.00
- CFG: Release

arch/x86/Makefile:248: *** You are building kernel with non-retpoline compiler, please update your compiler..  Stop.
make: *** [/usr/src/PlxSdk/Makefiles/Targets.def:46: BuildDriver] Error 2
non-retpoline 的解决方案错误来自搜索和this邮政。我必须:
导出每个项目的 PLX_CHIP 类型并将项目设置为 root。
从 # 提示符:
cd/usr/src/PlxSdk
导出 PLX_CHIP=8000_NT
制作
导出 PLX_CHIP=8000_DMA
制作
导出 PLX_CHIP=6000_NT
制作
9000 代码有一个编译器错误。

关于c - 在 Linux 中构建 PLX SDK 驱动程序产生 "No such file or directory",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63923258/

相关文章:

c - 为什么 if 循环在请求下一个输入之前迭代两次?

php - 设置 Apache 。无法写入 var 文件夹

command-line - 动态实例化 OCaml 中的模块

c++ - 运行时检查失败 #0 -(ESP 的值未正确保存)- 调用存储在结构中的函数时

c - C 中的文件处理(使用 fread 和 fwrite)

c - 为什么我的代码会出现 "nested functions are disabled..."错误?

c - 信号处理程序终止程序

linux - 如何检查程序在 bash 脚本中是否成功运行?

c - 内核文件中函数错误的多重定义

python - Mosso Python 模块