linux-device-driver

printk not working for kernel debgugging

℡╲_俬逩灬. 提交于 2019-12-10 21:20:12
问题 I put some debugging messages in the kernel code. have checked /var/log/messages, dmesg and there is no such dump there. syslogd is running on the machine i also changed /proc/sys/kernel/printk to 8 4 1 7 any idea what can be the problem? 回答1: The easiest explanation is your printk() is not being called. Keep it simple and stick to checking dmesg(1) output while you're debugging this problem -- all the syslog(3) /var/log/messages and the console based output are separate from the issue of the

Using work queues within hard_xmit of a network driver

烈酒焚心 提交于 2019-12-10 18:35:53
问题 We have created our own network device driver. There is a situation where we need to wait for the hard ware to become ready before we send any data in the tx function (the one registered with .ndo_start_xmit ). Since we can't sleep/wait in atomic context, we have implemented a workaround by scheduling work queue from within the tx function. The work queue can then wait for the hardware to become ready and send the data. Is there a better way to do this? i.e. return from .ndo_start_xmit()

Linux Kernel: invoke call back function in user space from kernel space

笑着哭i 提交于 2019-12-10 17:10:09
问题 I am writing Linux user space application. where I want to invoke registered callback function in user space area from the kernel space. i.e. interrupt arriving on GPIO pin(switch press event) and registered function getting called in user space. is there any method is available to do this. Thanks 回答1: I found below code after lot of digging and perfectly works for me. Handling interrupts from GPIO In many cases, a GPIO input can be configured to generate an interrupt when it changes state,

How to get name (path) of uinput created device

醉酒当歌 提交于 2019-12-10 16:42:24
问题 I have successfully set up a small program to create a uinput device which I plan to use to automate testing of an application receiving keyboard input events. I have followed both tutorials as found in this very nice answer. When my program creates the uinput device by calling ioctl(fd, UI_DEV_CREATE) a new device appears in the file system so my application under test can attach to it and wait for events. My target system already has a /dev/input/event0 device so the new one gets the path

Which part of process virtual memory layout does mmap() uses?

人走茶凉 提交于 2019-12-10 15:28:09
问题 The mmap() function shall establish a mapping between a process virtual address space and a device file or physical memory region. A process virtual memory layout has the following sections: Which region of Process Virtual Address Space does mmap() use for mapping? 回答1: Mmap uses "unallocated memory". Please note that the picture you drew is unlikely to be used on any UNIX system that is younger than about 30 years. UNIX used do have that memory layout in the early 70s, but the picture is

How to implement a writable proc file by using seq_file in a driver module

ぐ巨炮叔叔 提交于 2019-12-10 15:07:41
问题 In the book of Linux Device Driver 3rd ed , /proc file system is used as a output method to export the running state of a certain device driver. However, in some circumstances, /proc file system is used as one interface to change the internal parameters of a driver module. I googled a lot, and found some implementations on the Internet are too old that they used create_proc_entry() rather than proc_create() . What's more, I'm prefer to implement this by seq_file (actually, I'm not sure is it

How to put a check in the code to ensure the inter kernel module dependency - Linux Kernel?

半世苍凉 提交于 2019-12-10 12:16:41
问题 I have two modules. I want the modules to be interdependent while doing insmod or rmmod. Currently, my module2 is dependent on module1. If I insert module1 then module2, it works fine. On the other hand, the reverse of it doesn't work. This is logical in explanation. However, I want a neat code to avoid such dependencies. If I do insmod of mod2 then mod1 should automatically be insmod, Or some other decent way to tackle this issue. Here are my two modules. static int multiplyMod1(int a, int b

Why does my hrtimer callback return too early after forwarding it?

冷暖自知 提交于 2019-12-10 11:42:04
问题 I want to use a hrtimer to control two hardware gpio pins to do some bus signalling. I set up a hrtimer in a kernel module like this #include <linux/slab.h> #include <linux/delay.h> #include <linux/ktime.h> #include <linux/hrtimer.h> #define PIN_A_HIGH_TO_A_LOW_US 48 /* microseconds */ #define PIN_A_LOW_TO_B_LOW_US 24 /* microseconds */ static struct kt_data { struct hrtimer timer; ktime_t period; } *data; typedef enum { eIdle = 0, eSetPinALow, eSetPinBLow, } teControlState; static enum

Android powered device in USB host mode

僤鯓⒐⒋嵵緔 提交于 2019-12-10 11:37:15
问题 Android has implemented the USB host mode in Android 3.1 and newer. I've gone through documents in the following link: http://developer.android.com/guide/topics/connectivity/usb/index.html http://developer.android.com/guide/topics/connectivity/usb/host.html However, the information provided by Android official website is relatively too high level for me to understand the whole story. I know that OTG is necessary to implement USB host mode. I have some questions listed in the following: How

it is normal for linux to read a block of size more than 4KB (or several blocks of 4KB each) at a time?

不想你离开。 提交于 2019-12-10 11:36:21
问题 I am writing a device driver for a network attached hard drive and my problem is that I can see that Linux is sending requests to my block device that exceed the typical 4KB requests. Actually, the behavior I can notice is that. It sends a request of 4kB first, then the second request is of size 8KB, then 16KB and so on. Is there any way to disable this behavior and limit Linux to send requests of 4KB at a time? or is this something bad in my code? How I calculated the request total size: I