Linux 核心變更導致驅動經常出現的錯誤記錄

2021-08-18 04:24:24 字數 3053 閱讀 4639

1: error: cflags was changed in ***. fix it to use ccflags-y。

解決方法: export kbuild_nopedantic=1

解決方法: 修改makefile中的 cflags 為 extra_cflags 或 ccflags-y

2: linux/config.h no found file or folder

解決方法:#include標頭檔案貌似在2.6.19的核心版本後就沒有了, 有此錯誤的話, 則刪除此檔案.

3: error: unknown field 『ioctl』 specified in initializer

解決方法: 所有file_operations結構體中的ioctl函式指標。改為unlocked_ioctl

4: error: implicit declaration of function 『init_mutex』

解決方法: 2.6.25以後就已經不再使用這個巨集了。可以自己手動新增此巨集.

#define init_mutex(sem) sema_init(sem, 1)

#define init_mutex_locked(sem) sema_init(sem, 0)

5: error: 『task_interruptible』 undeclared

解決方法: 新增#include

6: error: current->uid

解決方法: 變更為current->cred->uid.val;

typedef struct  kuid_t;

kuid_t uid;

struct cred ;

struct task_struct ;

7: error: 『create_proc_read_entry』or』create_proc_entry』 [-werror=implicit-function-declaration]

解決方法: 此函式在新核心中已經被proc_create或者proc_create_data取代。函式在標頭檔案#include中。

8: error:#include沒有檔案或目錄

解決方法: 刪除此行.

9: error: implicit declaration of function 『usb_buffer_free』

解決方法: 用usb_free_coherent()替代,

說明:usb: rename usb_buffer_alloc() and usb_buffer_free()

for more clearance what the functions actually do,

usb_buffer_alloc() is renamed to usb_alloc_coherent()

usb_buffer_free() is renamed to usb_free_coherent()

10: error: implicit declaration of function 『lock_kernel』

解決方法: 刪除或者根據**進行對應的替換, 在核心鎖已經從新版本中移除.

11: error : struct tty_struct has no member named 『flip』, flip.count錯誤;

解決方法: 刪除 flip, 直接引用count。在中,struct tty_struct直接包含了 count, flip被刪除.

12: error: tty->termios->c_cflag;

解決方法: 將tty->termios->c_cflag; 變更為 tty->termios.c_cflag;

13: error: 『struct tty_driver』 has no member named 『devfs_name』

解決方法: 刪除此行, devfs_name成員在新核心版本中被刪除.

14: error: 『tty_driver_no_devfs』 undeclared (first use in this function)

解決方法: 刪除, 新版本中此標誌被移除

15:fatal error: asm/system.h : no file or directory#include:

解決方法:

在linux中3.3以後的核心用switch_to.h 替代了 system.h,修改**為:

解決方法:刪除 #include 改用

#include

為了保證code的可移植性,可以使用下面的code:

#include 

#if linux_version_code > kernel_version(3, 3, 0)

#include //版本大於3.3

#else

#include //版本小於3.3

#endif

16、關於linux核心中找不到asm資料夾:

源**中沒有asm這個資料夾,asm是乙個符號連線,只有在你的主makefile的arch 變數賦值,編譯核心的時候根據arch 的配置,

臨時的生成asm資料夾及其下的檔案,然後指向對應的體系結構的檔案,如/include/asm-arm/ ,/include/asm-x86/

驅動核心堆疊不足導致藍屏

核心模式堆疊是乙個有限的儲存區域,經常用於儲存從乙個函式傳遞到另乙個函式的資訊以及用於區域性變數儲存。雖然堆疊被對映到系統空間,但是它被視為原始呼叫例程的執行緒上下文的一部分,而不是驅動程式本身的一部分。這意味著只要呼叫執行緒正在執行,就可以保證存在堆疊,但是它可以隨執行緒一起清除。在任何核心模式執...

linux 核心 驅動

首先 1.建立裝置 分配cdev結構體 if globalmem major 手動分配 ret register chrdev region devno,1,globalmem else globalmem 提供給上層使用 2 建立核心裝置 struct globalmem dev globalme...

新增linux核心驅動

1.將核心驅動.ko放入 lib modules 3.2.0 23 generic kernel drivers 目錄下 2.執行depmod a來解決依賴 掃瞄driver下的驅動依賴關係 命令執行完成後,會自動生成modules.dep 和modules.alias。dep為依賴關係。3.更新當...