博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LDDR3中scull编译问题
阅读量:4052 次
发布时间:2019-05-25

本文共 2697 字,大约阅读时间需要 8 分钟。

于实验室需要,要学习Linux下的驱动开发,正好自己也好好学习linux下的驱动开发,但是书本的代码编写碰到一个问题,就是在Ubuntu下不能编译,经过网上的搜索后,找到如下一篇博客,非常不错,如下: 
编译LDD3-scull
1、提示scripts/Makefile.build:46:*** CFLAGS was changed in "/home/chenfang/scull/Makefile",Fix it use EXTRA_CFLAGS.Stop.:
 
由于LDD3使用的是2.6.10内核,很多东西已经发生了变化,这里提示我们修改Makefile中的CFLAGS,用EXTRA_CFLAGS代替,照它说的做就可以。
2、提示找不到文件linux/config.h:
 
 
在2.6.19开始的内核中删除了config.h文件,因此只要在mian.c中注释掉#include<linux/config.h>即可。
3、提示access.c中存在:dereferencing pointer to incomplete type 错误:
在 源码中发现只能是current存在错误,current应该是一个task_struct类型的全局变量,查找task_struct存在于 linux/sched.h中,因此在access.c中加入#include<linux/sched.h>,重新make即可。
顺便看下current这个全局变量是在哪里定义的:
在source ininsight中查找得到的current类似于以下的定义:
static inline struct task_struct *get_current(void) __attribute_const__;
static inline struct task_struct *get_current(void)
{
 
return current_thread_info()->task;
}
#define current (get_current())
可 见,current其实是一个“伪全局变量”,是函数get_current()的宏定义。当access.c中使用current->uid时, 就调用了get_current()函数,从而返回task_struct结构的task,因此current->uid就相当于 task->uid。
之前在Ubuntu里编译scull时有错误,还好有网友提供了解决办法,即删除config.h文件和增加#include 两个头文件:capability.h和sched.h
最近将Ubuntu升级到9.10版本后,重新生成了2.6.31版本的内核树,没想到编译scull模块时出现新的
/home/dengwei/eclipse_workspace/scull/access.c:108: error: ‘struct task_struct’ has no member named ‘uid’
/home/dengwei/eclipse_workspace/scull/access.c:109: error: ‘struct task_struct’ has no member named ‘euid’
/home/dengwei/eclipse_workspace/scull/access.c:116: error: ‘struct task_struct’ has no member named ‘uid’
/home/dengwei/eclipse_workspace/scull/access.c: In function ‘scull_w_available’:
/home/dengwei/eclipse_workspace/scull/access.c:167: error: ‘struct task_struct’ has no member named ‘uid’
/home/dengwei/eclipse_workspace/scull/access.c:168: error: ‘struct task_struct’ has no member named ‘euid’
/home/dengwei/eclipse_workspace/scull/access.c: In function ‘scull_w_open’:
/home/dengwei/eclipse_workspace/scull/access.c:186: error: ‘struct task_struct’ has no member named ‘uid’
原因:
 
 
struct task_struct定义在include/linux/sched.h中,原来task_struct结构体定义有所改动,将uid和euid等挪到 cred中,见include/linux/sched.h和include/linux/cred.h。
解决方法:
只需要将报error的代码做如下修改
current->uid 修改为 current->cred->uid
current->euid 修改为 current->cred->euid
make success
结果:
root@dw:/home/dengwei/eclipse_workspace/scull# ls
access.c  
 
 
main.o  
 
 
 
 
Module.symvers  
scull.init  
scull.mod.o
access.o  
 
 
Makefile  
 
 
 
pipe.c  
 
 
 
 
scull.ko  
 
scull.o
_desktop.ini  
Module.markers  
pipe.o  
 
 
 
 
scull_load  
scull_unload
main.c  
 
 
 
modules.order  
scull.h  
 
 
 
scull.mod.c
root@dw:/home/dengwei/eclipse_workspace/scull# insmod scull.ko
按照上面提示,就可以顺利编译成ko文件,其中include/linux在我的Linux中绝对路径名是
/usr/src/linux-headers-2.6.32-21/include/linux
本篇文章来源于 Linux公社网站(www.linuxidc.com)  
原文链接:file:///D:/Src/Ubuntu下编译LDD3-scull例子时遇到的一些问题.mht

转载地址:http://nlsci.baihongyu.com/

你可能感兴趣的文章
yuv420 还原为RGB图像
查看>>
LED恒流驱动芯片
查看>>
驱动TFT要SDRAM做为显示缓存
查看>>
使用file查看可执行文件的平台性,x86 or arm ?
查看>>
qt5 everywhere 编译summary
查看>>
qt 创建异形窗体
查看>>
简单Linux C线程池
查看>>
内存池
查看>>
输入设备节点自动生成
查看>>
GNU hello代码分析
查看>>
Qt继电器控制板代码
查看>>
wpa_supplicant控制脚本
查看>>
gstreamer相关工具集合
查看>>
RS232 四入四出模块控制代码
查看>>
linux 驱动开发 头文件
查看>>
container_of()传入结构体中的成员,返回该结构体的首地址
查看>>
ipconfig,ifconfig,iwconfig
查看>>
opensuse12.2 PL2303 minicom
查看>>
网络视频服务器移植
查看>>
Encoding Schemes
查看>>