Llseek:
-einval Illegal (invalid) parameter
Current Position File->f_pos
Seek_end Pcdevp->data_len
The defined position is within your location.
how to deal with : Finally make a save File->f_pos = ...
How to drive LED lights: Look at the schematic, if you want to let the led light on the corresponding port output corresponding level if it is led Light one end of the ground, then make it this side high level, If the next transistor is to consider the transistor conduction, and vice versa ...
Programming makes The CPU has the corresponding pin set as the output pin.
Control the PIN output high or low level
Read The CPU manual sets the appropriate registers such as:cpc1con gpc1dat gpc1pud
There are two ways to control the corresponding GPIO pins under Linux
1) Direct operation of the appropriate registers
2) GPIO Operation Library functions provided by the kernel
control in user space in two ways LED Light, off
1) ,dev/led0 dev/led1 ....
Cdev0 cdev1 ....
Fd0 =open ("/dev/led0", O_rdwe)
Ioctl (Fd,cmd,data);
Ioctl (fd0,1,0)
....
2) /dec/led/
Cdev
Fd0 =open ("/dev/led0", O_rdwe)
Ioctl (Fd,cmd,data);
IOCTL (fd0,1,0) or ioctl (fd0,1,1)
....
Include header file
#include <asm/gpio.h>
#include <plat/gpio-cfg.h>
What role does Cdev play in the driver program? Bridge function?
User Space Kernel space
Open Xxx_open
*gpio Application
Gpio_request (,);
Gpio_free (unsigned gpio)
Debugging the Kernel
Printk
PRINTK will print the information to the console or the /var/log/message file
when developing drivers, a large number of PRINTK are often added to the auxiliary mode
when releasing drivers, you should remove the addition of a large number of PRINTK statements
Code See: http://songmao.blog.51cto.com/11700139/1876798
using the PROCFS file system
file System Procfs is also often used by the kernel to bring information to the user, which can be used in device drivers
Output Debugging information
refer to the previous file system and device file system for details on the procfs file System
Oops
Please see: http://songmao.blog.51cto.com/11700139/1877971
Kgdb
kernel collapse value
<8f0000b8>
The code crashes in the kernel or in the xxx.ko file Code
cat/proc/kallsyms > 1.txt
code crashes in xxx. which function of the C file
arm-linux-objump-d Vmlinux >3.txt
as Xxxx_open
PUSH{R4,R5,R6,R7,FP,IP,LR,PC}
F3997b80 0000000 f34eldf4 ....
Chrdev_open->xxx_open
PUSH{R4,R5,R6,R7,FP,IP,LR,PC}
......
modal core file
Ulimit-a
Ulimit-c Unlimited
GDB A.out-c Core
Please see: http://songmao.blog.51cto.com/11700139/1877998
This article is from the "Mao Scattered People" blog, please be sure to keep this source http://songmao.blog.51cto.com/11700139/1878001
Character Devices (iii) and Debugging methods