Linux Device driver Learning Note one: Debug LDD scull code under Ubuntu 14.04.3 LTS

Source: Internet
Author: User
Tags function prototype

    • Operating system version

[Email protected]:~/vm_disk_dpdk/study/drive/examples/scull# sudo lsb_release-a

No LSB modules is available.

    • Distributor Id:ubuntu

Description: Ubuntu 14.04.3 LTS
release:14.04
Codename:trusty
[Email protected]:~/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 x86_64 x86_64 x86_64 gnu/linux

    • Issue One: 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

    • Question two:/home/enjoy/vm_disk_dpdk/study/drive/examples/scull/main.c:17:26:fatal error: linux/config.h:no such file or directory

Not config.h now, but autoconf.h.

[Email protected]:/usr/src/linux-headers-3.13.0-66-generic/include/linux# ln-s. /generated/autoconf.h config.h
[Email protected]:/usr/src/linux-headers-3.13.0-66-generic/include/linux# ll Config.h
lrwxrwxrwx 1 root root: 01:01 config.h. /generated/autoconf.h

    • Question three:/home/enjoy/vm_disk_dpdk/study/drive/examples/scull/main.c:32:46:fatal error:asm/system.h:no such file or Directory

Direct comment, there is a problem followed by adding another header file

This file is removed in Linux 3.4, commit f05e798ad4c0; Its contents has been moved into various and other headers.

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

    • Question four:/home/enjoy/vm_disk_dpdk/study/drive/examples/scull/main.c:556:2: Error:unknown field ' IOCTL ' specified in Initializer

This error online search found 2.6. Version 38 kernel file_operation The IOCTL function has been removed and replaced by:
Long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
Long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
File_operation structure in INCLUDE/LINUX/FS.H definition
Solution:
Replace with Unlocked_ioctl, pay attention to the function prototype, the first parameter does not need (the code is useless), and the return value is a long type.

    • Question five:/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 and later Linux kernel versions abolished the Init_mutex function, and the new version uses the Sema_init function

Static void Init_mutex (struct semaphore *sem)  {      1);  }  
    • Question six: include/linux/wait.h:307:31:error: ' Task_interruptible ' undeclared (first use of this function)

Add header file: #include <linux/sched.h>

    • Question seven:/usr/src/linux-source-3.2.0/drivers/scull/access.c:98:34:error: ' spin_lock_unlocked ' is not declared (not within the function)

Will: static spinlock_t scull_u_lock = spin_lock_unlocked;
Instead: Static Define_spinlock (Scull_u_lock);

    • Question eight:

/USR/SRC/LINUX-SOURCE-3.2.0/DRIVERS/SCULL/ACCESS.C:107:29: Error: Lift pointer to an incomplete type
The workaround is to add two header files to the ACCESS.C #include <linux/sched.h>

    • Issue nine: ' 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 modified to Current->cred->uid.val
Current->euid modified to Current->cred->euid.val

Compile OK:

[Email protected]:~/vm_disk_dpdk/study/drive/examples/scull# ls
ACCESS.C main.c Makefile module.symvers pipe.o scull.init scull_load scull.mod.o scull_unload
ACCESS.O main.o modules.order pipe.c scull.h scull.ko scull.mod.c SCULL.O

Linux Device driver Learning Note one: Debug LDD scull code under Ubuntu 14.04.3 LTS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.