错误
今天编译驱动模块的时候报错,具体如下所示。
zhongyi@ubuntu:~/workdir/linux_driver/device_tree_rgb_led$ make
make -C ../ebf-buster-linux/build_image/build M=/home/zhongyi/workdir/linux_driver/device_tree_rgb_led modules
make[1]: Entering directory '/home/zhongyi/workdir/linux_driver/ebf-buster-linux/build_image/build'
make[2]: Entering directory '/home/zhongyi/workdir/linux_driver/ebf-buster-linux/build_image/build'
make[2]: *** /home/zhongyi/workdir/ebf-buster-linux: No such file or directory. Stop.
make[2]: Leaving directory '/home/zhongyi/workdir/linux_driver/ebf-buster-linux/build_image/build'
Makefile:24: recipe for target '__sub-make' failed
make[1]: *** [__sub-make] Error 2
make[1]: Leaving directory '/home/zhongyi/workdir/linux_driver/ebf-buster-linux/build_image/build'
Makefile:10: recipe for target 'all' failed
make: *** [all] Error 2
提示进入 ‘/home/zhongyi/workdir/linux_driver/ebf-buster-linux/build_image/build’ 的时候失败。看了下,build_image文件夹确实是存在的。这就很奇怪了。
解决
尝试重新构建下内核。
执行以下命令,删除内核编译产生的所有文件。
make mrproper
执行编译内核的脚本
./make_deb.sh
再次尝试make编译驱动模块
zhongyi@ubuntu:~/workdir/linux_driver/device_tree_rgb_led$ make
make -C ../ebf-buster-linux/build_image/build M=/home/zhongyi/workdir/linux_driver/device_tree_rgb_led modules
make[1]: Entering directory '/home/zhongyi/workdir/linux_driver/ebf-buster-linux/build_image/build'
mkdir: cannot create directory ‘/home/zhongyi/workdir/linux_driver/device_tree_rgb_led/.tmp_versions’: Permission denied
/bin/sh: 1: cannot create /home/zhongyi/workdir/linux_driver/device_tree_rgb_led/modules.order: Permission denied
/home/zhongyi/workdir/linux_driver/ebf-buster-linux/scripts/Makefile.build:462: recipe for target '/home/zhongyi/workdir/linux_driver/device_tree_rgb_led/modules.order' failed
make[4]: *** [/home/zhongyi/workdir/linux_driver/device_tree_rgb_led/modules.order] Error 2
/home/zhongyi/workdir/linux_driver/ebf-buster-linux/Makefile:1519: recipe for target '_module_/home/zhongyi/workdir/linux_driver/device_tree_rgb_led' failed
make[3]: *** [_module_/home/zhongyi/workdir/linux_driver/device_tree_rgb_led] Error 2
Makefile:146: recipe for target 'sub-make' failed
make[2]: *** [sub-make] Error 2
Makefile:24: recipe for target '__sub-make' failed
make[1]: *** [__sub-make] Error 2
make[1]: Leaving directory '/home/zhongyi/workdir/linux_driver/ebf-buster-linux/build_image/build'
Makefile:10: recipe for target 'all' failed
make: *** [all] Error 2
仍然报错,提示没有权限。
执行sudo make
进行编译。问题解决。
zhongyi@ubuntu:~/workdir/linux_driver/device_tree_rgb_led$ sudo make
[sudo] password for zhongyi:
make -C ../ebf-buster-linux/build_image/build M=/home/zhongyi/workdir/linux_driver/device_tree_rgb_led modules
make[1]: Entering directory '/home/zhongyi/workdir/linux_driver/ebf-buster-linux/build_image/build'
CC [M] /home/zhongyi/workdir/linux_driver/device_tree_rgb_led/rgb_led.o
Building modules, stage 2.
MODPOST 1 modules
CC /home/zhongyi/workdir/linux_driver/device_tree_rgb_led/rgb_led.mod.o
LD [M] /home/zhongyi/workdir/linux_driver/device_tree_rgb_led/rgb_led.ko
make[1]: Leaving directory '/home/zhongyi/workdir/linux_driver/ebf-buster-linux/build_image/build
驱动模块也正常生成。
zhongyi@ubuntu:~/workdir/linux_driver/device_tree_rgb_led$ ls
imx6ull-seeed-npi.dts Makefile modules.order Module.symvers rgb_led.c rgb_led.ko rgb_led.mod.c rgb_led.mod.o rgb_led.o test_app.c