zoukankan      html  css  js  c++  java
  • 设备驱动程序代码高版本内核问题解决

    • 操作系统版本

    root@ubuntu:~/vm_disk_dpdk/study/drive/examples/scull# sudo lsb_release -a

    No LSB modules are available.

    • Distributor ID: Ubuntu

    Description:    Ubuntu 14.04.3 LTS
    Release:        14.04
    Codename:       trusty
    root@ubuntu:~/vm_disk_dpdk/study/drive/examples/scull# uname -a
    Linux ubuntu 3.13.0-66-generic #108-Ubuntu SMP Wed Oct 7 15:20:27 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

    • 问题一:scripts/Makefile.build:49: *** CFLAGS was changed in "/home/enjoy/vm_disk_dpdk/study/drive/examples/scull/Makefile". Fix it to use ccflags-y.  Stop.

    change
     CFLAGS += $(PSTN_DEF) -Wall -O $(INCLUDES) -fno-common -DTARGET_CATAWBA
    to
     EXTRA_CFLAGS += $(PSTN_DEF) -Wall -O $(INCLUDES) -fno-common -DTARGET_CATAWBA
    and try 

    you could use something like this:
    sed -i 's/^CFLAGS/EXTRA_CFLAGS/' Makefile

    • 问题二:/home/enjoy/vm_disk_dpdk/study/drive/examples/scull/main.c:17:26: fatal error: linux/config.h: No such file or directory

    现在不用config.h,而是autoconf.h

    root@ubuntu:/usr/src/linux-headers-3.13.0-66-generic/include/linux# ln -s ../generated/autoconf.h config.h
    root@ubuntu:/usr/src/linux-headers-3.13.0-66-generic/include/linux# ll config.h 
    lrwxrwxrwx 1 root root 23 Dec 10 01:01 config.h -> ../generated/autoconf.h

    •  问题三:/home/enjoy/vm_disk_dpdk/study/drive/examples/scull/main.c:32:46: fatal error: asm/system.h: No such file or directory

    直接注释,有问题后面接着加别的头文件

    This file was removed in Linux 3.4, commit f05e798ad4c0; its contents have been moved into various other headers.

    It's possible that just removing the #include <asm/system.h> might work, but it's much more likely that your driver is simply incompatible with current Linux versions.

    •  问题四:/home/enjoy/vm_disk_dpdk/study/drive/examples/scull/main.c:556:2: error: unknown field ‘ioctl’ specified in initializer

    这个错误网上搜索发现2.6.38版本内核 file_operation结构体已经删除了ioctl函数,取代的是:
    long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
    long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
    file_operation结构体在 include/linux/fs.h定义
    解决方案:
    替换为unlocked_ioctl 即可,注意函数原型,第一个参数不需要(代码中没用到),还有返回值为long类型。

    •  问题五:/home/enjoy/vm_disk_dpdk/study/drive/examples/scull/main.c:652:3: error: implicit declaration of function ‘init_MUTEX’ [-Werror=implicit-function-declaration]

    2.6.25及以后的linux内核版本废除了init_MUTEX函数,新版本使用sema_init函数

    static inline void init_MUTEX (struct semaphore *sem)  
    {  
        sema_init(sem, 1);  
    }  
    •  问题六:include/linux/wait.h:307:31: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)

    增加头文件:#include <linux/sched.h>

    • 问题七:/usr/src/linux-source-3.2.0/drivers/scull/access.c:98:34: error: ‘SPIN_LOCK_UNLOCKED’未声明(不在函数内)

     将:static spinlock_t scull_u_lock = SPIN_LOCK_UNLOCKED;
    改为:static DEFINE_SPINLOCK(scull_u_lock);

    •  问题八:

    /usr/src/linux-source-3.2.0/drivers/scull/access.c:107:29: 错误: 提领指向不完全类型的指针
    解决办法是在access.c中就加入两个头文件 #include<linux/sched.h>

    • 问题九:‘struct task_struct’ has no member named ‘uid’、‘euid’

    /home/enjoy/vm_disk_dpdk/study/drive/examples/scull/access.c:107:29: error: ‘struct task_struct’ has no member named ‘uid’
    /home/enjoy/vm_disk_dpdk/study/drive/examples/scull/access.c:108:29: error: ‘struct task_struct’ has no member named ‘euid’

    current->uid 修改为 current->cred->uid.val
    current->euid 修改为 current->cred->euid.val

    http://blog.csdn.net/zjq_1990/article/details/51684912

  • 相关阅读:
    nginx各版本全自动编译安装脚本
    kubernetes里面有时候centos源用不了
    centons6升级gcc和glibc版本
    容器下载的是centos8的镜像,scp出现packet_write_wait: Connection to **** port 22: Broken pipe 问题解决
    MNIST数据集手写体识别(MLP实现)
    BP 算法手动实现
    Python直接调用C库的printf()函数打印一条消息
    C/C++与Python实现混编(详细注释)
    MNIST数据集手写体数据还原为图片
    TensorFlow初识(MNIST数据集识别手写体)
  • 原文地址:https://www.cnblogs.com/oracleloyal/p/6003073.html
Copyright © 2011-2022 走看看