• <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 墨…… 閱讀(916) 評論(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 © 墨……

            久久精品亚洲日本波多野结衣| 97超级碰碰碰碰久久久久| 久久人人爽人人爽人人片av麻烦| 久久久久久无码Av成人影院| 国产精品久久久久天天影视| 一本大道久久东京热无码AV | 久久国产精品无码HDAV | 欧美久久久久久| 久久国产高清一区二区三区| 久久久一本精品99久久精品88| 国产亚洲色婷婷久久99精品91| 人妻精品久久久久中文字幕69 | 婷婷五月深深久久精品| 久久狠狠爱亚洲综合影院 | 久久精品亚洲日本波多野结衣| 亚洲中文字幕伊人久久无码| 色综合久久天天综线观看| 久久精品国产精品亜洲毛片| 亚洲欧美久久久久9999| 一日本道伊人久久综合影| 漂亮人妻被黑人久久精品| 无码国内精品久久人妻蜜桃| 9久久9久久精品| 亚洲国产成人久久综合一区77| 国产精品乱码久久久久久软件 | 色天使久久综合网天天| 91久久精品国产免费直播| 伊人精品久久久久7777| 99re久久精品国产首页2020| 国产精品伊人久久伊人电影| 免费久久人人爽人人爽av| 国产99久久久国产精免费| 久久国产色AV免费观看| 无码人妻少妇久久中文字幕| 国产精品久久久天天影视| 国产精品成人久久久| 国产精品熟女福利久久AV| 色噜噜狠狠先锋影音久久| 亚洲AV无码久久精品狠狠爱浪潮| 久久有码中文字幕| 亚洲精品无码久久毛片|