• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            linux 驅動初接觸

            Posted on 2013-04-02 15:36 墨…… 閱讀(912) 評論(0)  編輯 收藏 引用
            編譯 scull

               出現以下錯誤
             Fix it to use ccflags-y.  Stop.
               將 Makefile 中的 CFLAGS 改為 ccflags-y, 重新 make,又出現錯誤
            main.c:15:26: fatal error: linux/config.h: No such file or directory
               將 main.c 中的 #include <linux/config.h> 刪除或注釋掉,重新 make,繼續編譯會遇到如下問題
            main.c:634:2: error: unknown field 'ioctl' specified in initializer
               是因為內核中的 file_operations 結構發生了改變,將 main.c 中 scull_fops 聲明處的 .ioctl 改為 .unlocked_ioctl  即可,繼續編譯還會遇到如下問題
            main.c:652:3: error: implicit declaration of function ‘init_MUTEX’ [-Werror=implicit-function-declaration]
               可在 main.c 的開始處添加以下代碼解決問題
            #include <linux/semaphore.h>
            #define init_MUTEX(a) sema_init(a,1)
            #define init_MUTEX_LOCKED(a) sema_init(a,0)
               到這時還沒完,我開始有點煩燥了...繼續前進時還出現以下錯誤
            pipe.c: In function ‘scull_p_read’:
            pipe.c:131:7: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
            pipe.c:131:7: note: each undeclared identifier is reported only once for each function it appears in
            pipe.c:131:3: error: implicit declaration of function ‘signal_pending’ [-Werror=implicit-function-declaration]
            pipe.c:131:3: error: implicit declaration of function ‘schedule’ [-Werror=implicit-function-declaration]
               該問題可向 pipe.c 和 access.c 中添加 #include <linux/sched.h> 來解決,但后面還會遇到這樣的問題
            access.c:101:34: error: ‘SPIN_LOCK_UNLOCKED’ undeclared here (not in a function)
               在access.c文件中用 static DEFINE_SPINLOCK(scull_w_lock);  來代替 static spinlock_t scull_w_lock = SPIN_LOCK_UNLOCKED;
               繼續進行,遭遇下面問題
            access.c:111:29: error: ‘struct task_struct’ has no member named ‘uid’
            access.c:112:29: error: ‘struct task_struct’ has no member named ‘euid’
            access.c:119:26: error: ‘struct task_struct’ has no member named ‘uid’
               把 access.c 文件中的 
            current->uid 
            current->euid
               全部修對應地改為
            current->cred->uid
            current->cred->euid
               繼續重新 make,終于可以生成 scull.ko 了,OMG......

               還要注意的是,上面的錯誤可能不止發生在一個地方,編譯時需要注意看清錯誤提示,如果有跟上面一樣的錯誤發生,只需參照上面的方法來修改即可。
               驅動不會在虛擬終端上輸出,所以如果在終端上沒看到驅動的輸出,可以看看是不是輸出到日志中了:
            /var/log/syslog


            Contact us

            posts - 8, comments - 0, trackbacks - 0, articles - 0

            Copyright © 墨……

            激情伊人五月天久久综合| 亚洲午夜精品久久久久久app| 久久亚洲高清综合| 亚洲人成网站999久久久综合| 少妇久久久久久被弄到高潮| 久久婷婷国产剧情内射白浆| 国产精品一久久香蕉产线看 | 色综合合久久天天给综看| 最新久久免费视频| 精品久久久久久国产潘金莲| 精品久久久久国产免费| 亚洲国产精品高清久久久| 99久久亚洲综合精品成人| 久久久久波多野结衣高潮| 成人久久免费网站| 久久久噜噜噜久久中文字幕色伊伊| 久久夜色精品国产| 91久久婷婷国产综合精品青草 | 日本WV一本一道久久香蕉| 99久久成人国产精品免费| 99久久香蕉国产线看观香| 国产精品成人99久久久久| 中文字幕无码免费久久| 亚洲国产综合久久天堂| 国产成人无码精品久久久免费| 亚洲中文字幕无码久久精品1| 久久强奷乱码老熟女| 国产日韩久久久精品影院首页| 久久亚洲AV成人无码国产| 丁香色欲久久久久久综合网| 亚洲国产精品综合久久一线 | 合区精品久久久中文字幕一区| 青青热久久综合网伊人| 久久国产高潮流白浆免费观看| 伊人伊成久久人综合网777| 合区精品久久久中文字幕一区| 94久久国产乱子伦精品免费| 国产精品美女久久久久AV福利| 国産精品久久久久久久| 国产精品日韩欧美久久综合| 精品久久久久久无码人妻热|