linux-device-driver

What is the most efficient and elegant way develop/debug linux kernel

早过忘川 提交于 2019-11-28 02:22:13
问题 Recently I start to develop the linux device driver, I face a problem, when I want to debug with kernel code, and add some printk debug message in the kernel file. for example, recently I add some printk() and dump_stack() in the __debug_locks_off() which resides in include/linux/debug_locks.h . Then I do the following steps, which is very time consuming. make clean make bzImage make modules make modules_install mkinitrfmfs -o /boot/initrd.img 3.12.6[my kernel version] cp arch/x86/boot

Content of /proc/iomem

戏子无情 提交于 2019-11-28 02:13:22
问题 1) Is it possible to access a physical address which is not defined in /proc/iomem? 2) If the physical address range of a device does not appear in /proc/iomem, does it mean that the device has not been utilized/initialized yet? 回答1: 1) Is it possible to access a physical address which is not defined in /proc/iomem? Yes. Assuming an ARM processor which memory maps all directly-connected periperals, the driver could perform an ioremap() operation to map the physical memory to virtual memory

Difference between device_register and driver_register

懵懂的女人 提交于 2019-11-28 02:04:58
问题 I am writing a UART driver. I came across the two functions in the chapter 14.Linux Device Model. int device_register(struct device *dev); int driver_register(struct device_driver *drv); Since UART is a char driver I have dynamically created the major number using ( alloc_chrdev_region) and added the device to kernel by using cdevadd() . I came across uart_register_driver() and platform_driver_register() in omap-serial.c. I could map the driver_register with the platform_driver_register() but

The irq in kernel function asm_do_IRQ() is different from the one I request in module

你说的曾经没有我的故事 提交于 2019-11-28 02:02:53
I did some experiment with a cortex-A9 development board. I used gpio_to_irq() to get an irq num and I requested the irq and wrote a small driver with it , it was 196 in syslog . And I added some printks in asm_do_IRQ. When I triggered the gpio interrupt , the driver works fine but the irq num in asm_do_IRQ was 62 .I can't understand. Why the irq number was different from the one I request? The driver is as follow: #include <linux/module.h> #include <linux/interrupt.h> #include <linux/irq.h> #include <linux/gpio.h> #define GPIO_N 36 //gpio number int flag = 0; static irqreturn_t handler(int

How to get the address of a kernel module that was inserted using insmod?

拈花ヽ惹草 提交于 2019-11-28 00:39:32
问题 I would like to know the address of a kernel module. Actually, from stack trace it looks that the crash has been triggered from a kernel module (which have been insmoded after system boots up). There are several modules I insmod manually. So I need to detect which module among these is triggering the crash. Please let me know how to get the address of each modules loaded using insmod. 回答1: cat /proc/modules should give you a rough guide to where things are loaded. You might get more of a clue

I2C device linux driver [closed]

血红的双手。 提交于 2019-11-28 00:26:48
问题 How to make a character device for i2c device, with open, close, ioctl etc. functions? I was looking for information about it last two weeks and couldn't find anything working. I found some information in Essential Linux Device Drivers, but it was written for 2.6 kernel, and i use 3.4.79 (i'm trying to write this driver for cubieboard2 on cubian distr) so this book has many deprecated functions, i tried to write my driver like there, but it still don't work (give me kernel errors while i'm

Injection of touch events using screen driver

旧时模样 提交于 2019-11-27 22:46:49
问题 Using android-event-injector library, I wrote an application to inject a touch event when some event is triggered. The problem is that i need to inject touch at absolute coordinates of a given View , so I do the following to get the location on screen: View v = /* find view*/; int [] coords = new int[2]; v.getLocationOnScreen(coords); This gives me the absolute coordinates on screen. The problem is that touch injection doesn't work. I can inject correctly touches in screen driver, but for

usage of driver_data member of I2C device id table

一个人想着一个人 提交于 2019-11-27 21:31:34
问题 I am trying to understand I2C client drivers. As per my understanding before registering I2C driver we have to define i2c_device_id table and device tree compatible table. I have following doubts. Could please help me to understand. 1) The definition of i2c_device_id structure contains two members ( name , driver_data ). The 1st member ( name ) is used to define the device name which will be used during driver binding, what is the use of the 2nd member ( driver_data ). 2) Driver binding will

Do Kernel pages get swapped out?

安稳与你 提交于 2019-11-27 21:22:31
Pertaining to the Linux kernel, do "Kernel" pages ever get swapped out ? Also, do User space pages ever get to reside in ZONE_NORMAL ? No, kernel memory is unswappable. Kernel pages are not swappable. But it can be freed. UserSpace Pages can reside in ZONE_NORMAL. Linux System Can be configured either to use HIGHMEM or not. If ZONE_HIGHMEM is configured , then the userspace processes will get its memory from the HIGHMEM else userspace processes will get memory from ZONE_NORMAL. Yes, under normal circumstances kernel pages (ie, memory residing in the kernel for kernel usage) are not swappable,

How do you read the mouse button state from /dev/input/mice?

空扰寡人 提交于 2019-11-27 20:18:54
How do you read the mouse button state from /dev/input/mice? I want to detect if the button is pressed down. You can open the device and read from it. Events from /dev/input/mice are 3 bytes long and require some parsing. I think the prefered method now is to use /dev/input/event# instead. However, here is a small example using /dev/input/mice. #include <stdio.h> #include <unistd.h> #include <fcntl.h> int main(int argc, char** argv) { int fd, bytes; unsigned char data[3]; const char *pDevice = "/dev/input/mice"; // Open Mouse fd = open(pDevice, O_RDWR); if(fd == -1) { printf("ERROR Opening %s