linux-device-driver

How nl80211 library & cfg80211 work?

你。 提交于 2019-11-29 18:48:44
I want to learn about how nl80211 and cfg80211 works in detail. Function flow, how nl80211 interact with network tools like wpa_supplicant , iw . Plz suggest me some useful links or books to refer. To be able to control wireless drivers from userspace, some IPC communication processes between kernel and userspace are used. At first ioctl with vendor dependent APIs was used. In 1996, Jean Tourrilhes creates wireless extensions (WE or WEXT). The Wireless Extension (WE) is a generic API allowing a driver to expose to the user space configuration and statistics specific to common Wireless LANs. In

Learning Kernel Programming [closed]

丶灬走出姿态 提交于 2019-11-29 18:34:53
I want to learn lLinux Kernel programming. What would be the starting points for that? What could be some of the simpler problems to target? Try to get hold of Robert Love's book on Linux Kernel Programming. Its very concise and easy to follow. After that or along with that, you may want to take a look at "Understanding the Linux kernel".But I wouldn't recommend it during the early stages. Also, look at the Linux kernel programming guide . Since a lot can be learnt from programing kernel modules, that guide will help you. And yes, for a lot of information, consult the 'documentation' sub

Why doesn't this call to `poll` block correctly on a sysfs device attribute file?

拜拜、爱过 提交于 2019-11-29 18:07:13
问题 I have a simple sysfs device attribute which shows up under my sysfs directory, and on a call to read returns the value of a kernelspace variable. I want to call poll on this attribute to allow my userspace thread to block until the value shown by the attribute changes. My problem is that poll doesn't seem to block on my attribute -- it keeps returning POLLPRI even though the value shown by the attribute does not change. In fact, I have no calls at all to sysfs_notify in the kernel module,

Interrupt handling and user space notification

纵饮孤独 提交于 2019-11-29 16:09:37
问题 I have several registered interrupts assigned to gpios, and application in user space. How to notify application about occurred interrupt and which interrupt there was? Possibly fasync is applicable for this goal, but I can find examples how to send information from interrupt handler to user space application. It will be good if you can present some useful examples. Thanks in advance. 回答1: You don't need fancy kernel to userspace communication. A userspace application has access to GPIOs

Writing memory of the traced process.

假装没事ソ 提交于 2019-11-29 15:15:40
问题 I am playing around with ptrace in linux. I am trying to write the memory of the traced process using /proc/pid/mem interface. the function I ma using for accomplish this task is : void write_proc(pid_t child, unsigned long int addr) { char mem_file_name[100]; char buf[10]="hope"; int mem_fd; memset( (void*)mem_file_name, 0, 100); memset( (void *)buf, 0, 10); sprintf(mem_file_name, "/proc/%d/mem", child); mem_fd = open(mem_file_name, O_RDONLY); lseek(mem_fd, addr , SEEK_SET); if (write(mem_fd

Where to use volatile? [duplicate]

让人想犯罪 __ 提交于 2019-11-29 14:26:03
问题 This question already has an answer here: Why is volatile needed in C? 17 answers I read about volatile keyword, but I don't know in what situations I should use it. When the memory (variable) is getting updated and process is not aware of that? In what cases should drivers use volatile variables? 回答1: The most common case in my world is when you are programming microcontrollers that use memory-mapped I/O. The value in a register could change due to external digital inputs, but if you don't

call to request_mem_region() fails

情到浓时终转凉″ 提交于 2019-11-29 12:30:00
The start address 0x4806E000 (UART4 base address) is already present in /proc/iomem with the name omap4-uart. How to disable the memory regions already allocated ?. Edit : Even though request_mem_region is successful the console during booting shows this messages. [ 0.758514] Serial: 8250/16550 driver, 3 ports, IRQ sharing enabled [ 0.760040] omap_uart.0: ttyO0 at MMIO 0x4806a000 (irq = 104) is a OMAP UART0 [ 0.760498] omap_uart.1: ttyO1 at MMIO 0x4806c000 (irq = 105) is a OMAP UART1 [ 0.760955] omap_uart.2: ttyO2 at MMIO 0x48020000 (irq = 106) is a OMAP UART2 [ 1.778808] console [ttyO2]

How to establish adb connection over USB between two PCs [closed]

…衆ロ難τιáo~ 提交于 2019-11-29 09:20:26
Summary (What we've done, what we've tried): Basically, the aim is to establish an adb protocol via usb between two linux computers by using adb source codes. Envinronment is Ubuntu 16.0.4. There's android-tools-adbd (adb daemon) package ready for use in the pool with its source available. There is also a source on this link (adbd) compilable with gcc option -stc=c++14 which is supported in 16.0.4 by default (or gcc 5.2 ). We are able to build the package from source or use already-built one successfully by using adb connect (TCP/IP dependent). There's no problem on adb connection via TCP/IP

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

不打扰是莪最后的温柔 提交于 2019-11-29 09:00:31
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/bzImage /boot update-grub Then reboot and choose my new kernel version. I don't know if there are some

Content of /proc/iomem

懵懂的女人 提交于 2019-11-29 08:55:01
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) 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 for access. But a properly written driver would first call request_mem_region() to ensure that it can use (and