linux-device-driver

New to Linux Kernel/Driver development

十年热恋 提交于 2019-12-02 14:55:57
Recently, i began developing a driver of an embedded device running linux. Until now i have only read about linux internals. Having no prior experience in driver devlopment, i am finding it a tad difficult to land my first step. I have downloaded the kernel source-code (v2.6.32). I have read (skimped) Linux Device Drivers (3e) I read a few related posts here on StackOverflow. I understand that linux has a "monolithic" approach. I have built kernel (included existing driver in menuconfig etc.) I know the basics of kconfig and makefile files so that should not be a problem. Can someone describe

How to learn the structure of Linux wireless drivers (mac80211)?

烈酒焚心 提交于 2019-12-02 14:19:35
There is so many structures in the Linux wireless driver mac80211. Things like struct net_device , struct ieee80211_hw , struct ieee80211_vif and struct ieee80211_local and so on. So many structures that I don't understand what information they contain and when them were initialized. How can I learn about them and the whole architecture of wireless drivers? eyalsh You may want to check out Johannes Berg's (mac80211 maintainer) slides here: http://wireless.kernel.org/en/developers/Documentation/mac80211?action=AttachFile&do=get&target=mac80211.pdf They may be somewhat outdated but should give

How to make a built-in device driver in linux

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 13:10:35
I know how to make loadable kernel modules in Linux. But i want that loadable kernel module to be a part of the kernel , and after booting that driver should automatically load, like most of the other general driver. How to do that? There are two ways to do for your query 1) building your module as statically compiled along with kernel (your source code should reside in kernel tree ),so while building build it static which come as a part of kernel, so when kernel boots your module will be loaded. 2)Same as above but while building build as dynamic loadable module so that wheneever required you

YOCTO : Modify Linux OS features by editing it's device tree

假装没事ソ 提交于 2019-12-02 12:53:32
I am using YOCTO project SUMO release to Build Linux kernel for my embedded board. I want to customize the features of my board. They told me to edit the device tree file. My question is what is the path of this DT file ? And when i modify it, I must rebuild all the kernel using Bitbake ? Thanks. Create the following tree in your layer meta-custom: recipes-kernel/ └── linux ├── linux-at91 │ ├── 0001-my-custom-dt.patch └── linux-at91_%.bbappend In linux-at91_%.bbappend , put FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" SRC_URI += "file://0001-my-custom-dt.patch" To generate 0001-my-custom-dt

Enabling and testing local loop back for UART

放肆的年华 提交于 2019-12-02 09:30:05
问题 I'm trying to do UART internal loop back testing and come up with below changes #include <fcntl.h> #include <stdio.h> #include <termios.h> #include <unistd.h> #include <sys/ioctl.h> #include <sys/mman.h> #include <sys/errno.h> #include <sys/types.h> #include <unistd.h> #define CCSR_BASE 0xfe000000 #define UART1_BASE 0x11c000 #define UART1_LEN 0x1000 static volatile unsigned long *uartReg = MAP_FAILED; /* Map in registers. */ static unsigned long *initMapMem(int fd, unsigned long addr,

modinfo() equivalent INSIDE kernel?

孤街浪徒 提交于 2019-12-02 08:48:29
I have two modules A, B. A has a function f() that is globally acessible, i.e. the f() symbol is exported. B may want to call f() occasionally. But B should only call f() if module A is loaded. What is the best way for B to tell if A is loaded? Part b to this question is there is a way to check if f() is exported? I'm not sure which method is more effecient. I assume you load module B first, then optionally module A. My strategy would be to have A register a set of functions with B when A first initializes. B keeps a statically allocated function pointer (or a pointer to a struct full of

How to read data from a serial (SPI) connection in C?

时光总嘲笑我的痴心妄想 提交于 2019-12-02 03:28:50
I am trying to write a program that will be installed on a Linux MCU (Raspberry Pi) that will read serial data coming to it from yet another MCU (something homegrown that I will build myself). I have researched how to do this and think I have the "big picture" but still missing a few things. For one, I need to enable the kernel module and give myself access to the device: sudo modprobe spi_bcm2708 sudo chown `id -u`.`id -g` /dev/spidev0.* From there I can use this famous C file to test the SPI connection. So now the connection is there, but I still need to read serial data from it. According

i2c registering macro not found?

若如初见. 提交于 2019-12-01 23:39:22
问题 I ame working on I2C driver on a raspPi: /* register I2C device static */ static const struct i2c_board_info rasp_i2c_devices[] = { { "mbed", mbedID }, }; /* in the init function of my module */ i2c_register_board_info(0,rasp_i2c_devices,ARRAY_SIZE(rasp_i2c_devices)); When i compile i get following error: make[1]: Entering directory `/home/zilleplus/rasp/linux' Building modules, stage 2. MODPOST 1 modules WARNING: "i2c_register_board_info" [/home/zilleplus/LedCube/Module/I2C/I2Crasp.ko]

Linux, spidev: why it shouldn't be directly in devicetree?

五迷三道 提交于 2019-12-01 23:14:30
I want to define a SPI device with usermode access, as explained for example in http://linux-sunxi.org/SPIdev Following these examples, I added in the devicetree this : &ecspi1 { .... other stuff ... mydev@0 { compatible = "spidev"; spi-max-frequency = <5000000>; reg = <2>; /*chipselect*/ }; }; The platform is i.MX6. ecspi1 seems to be their SPI controller. Then I indeed get /dev/spi0.2 and /sys/class/spidev/spidev0.2 But in kernel trace there's a WARNING saying this: spidev spi0.2: buggy DT: spidev listed directly in DT So how else the spidev should be described? What is the right syntax?

How to get details of all modules / drivers that were initialized / probed during the Linux kernel boot?

青春壹個敷衍的年華 提交于 2019-12-01 17:57:14
I need the sequence of modules/drivers that are invoked|initialized|probed during the kernl boot. Can you please let me know if any flash command-line option available to get this sequence ? Passing the option "initcall_debug" on the kernel command line will cause timing information to be printed to the console for each init routine of built-in drivers. The initcalls are used to initialize statically linked kernel drivers and subsystems and contribute a significant amount of time to the Linux boot process. (Loadable modules are not available until after the root filesystem has been mounted.)