I am new to Linux Kernel Development and I want to implement a Char device driver which handles Port expansion using a MCP23017 with a RaspberryPi (Raspbian Wheezy) using C.
A control for port expansion (MCP23017) is required. A less of a driver in the true sense, but more with porting functions in a driver.
The module is addressed via I2C. I need to implement the following functions in the driver:
· Configuration of the I2C address
· Configuration of the IOs
· Configuration of Pull-Ups
· Configuration of interrupts
· Read / write the IOs
It is important that up to 8 modules can be opened/operated simultaneously (8 is the max. possible number of addresses of the block).
I have seen a number of examples in the internet and implemented a simple char device driver with init, open, read and write functions and also tested I2C operations for MCP23017. I have got a brief idea about a device driver but don't know how to further implement the functions.
I would like to know/clarified about the following:
How does the dev_open work? How can I try to open a device through a linux command and check if the device is opened/ the number of times the device is opened through dmesg command?
I want 8 different modules to be opened simultaneously using the device driver and the Configuration of the MCP23017 IOs, Pullups and Interrupts. How is it done?
Errors:
/home/pi/i2c_gpio/mcp23017.c: In function ‘mcp23s08_direction_input’:
/home/pi/i2c_gpio/mcp23017.c:269:9: error: implicit declaration of function
‘gpiochip_get_data’ [-Werror=implicit-function-declaration]
struct mcp23s08 *mcp = gpiochip_get_data(chip);
/home/pi/i2c_gpio/mcp23017.c: In function ‘mcp23s08_probe_one’:
/home/pi/i2c_gpio/mcp23017.c:615:11: error: ‘struct gpio_chip’ has no
member named ‘parent’
mcp->chip.parent = dev;
/home/pi/i2c_gpio/mcp23017.c:681:2: error: implicit declaration of
function ‘gpiochip_add_data’ [-Werror=implicit-function-declaration]
status = gpiochip_add_data(&mcp->chip, mcp);
^
Related
I have an STM32 lorawan discovery board with an attached x_nucleo_iks02a1 shield. I'm trying to run the microphone sample, and I get an error at line 52
const struct device *mic_dev = device_get_binding(DT_LABEL(DT_INST(0, st_mpxxdtyy)));
// identifier "DT_N_INST_0_st_mpxxdtyy_P_label" is undefined
I looked at the zephyr.dts file and noticed that there is no compat listed with the string st_mpxxdtyy so I suppose that is the reason for the failure. The board I am using is not a nucleo but does have the same arduino compatible headers. Do I need to port this shield to this board?
Copy the overlay file x_nucleo_iks02a1_mic.overlay from /zephyrproject/zephyr/boards/shields/x_nucleo_iks02a1 to the root of your projectfolder.
Now you should be able to retrieve the device structure with:
const struct device *mic_dev = device_get_binding("MP34DT05");
I can perform normal scan using ioctl SIOCSIWSCAN and SIOCGIWSCAN and get list of AP, but when I set card into monitor mode i get errno = Operation not supported.
Is there a different ioctl call for passive scans??
I know the wifi card is not the issue, because I get results with airodump-ng and I checked two different cards.
First, on the command line type:
iw phy <phy> info
and see if new_interface is listed under supported commands. You can get the phy for your cards by:
iw dev
Second, I have found that it's easier to set a card in monitor mode if I delete all interfaces on the phy first. Some cards don't play well if there are interfaces active.
Use ioctl to bring cards up or down and to get the card's hw addr. Otherwise you should be using netlink - You're looking for NL80211_CMD_NEW_INTERFACE in nl80211.h
I'm working with MDK-Pro and the File System library.
In my application, I require an SPI interface to the SD card. I've managed to setup the project properly, except that in the RTE_Components.h file that Keil generates the line #define RTE_Drivers_MCI0 which subsequently triggers a preprocessor error ("SDIO not configured in RTE_Device.h").
Although I can manually comment out this line in RTE_Components.h, every so often Keil updates this file and I get the above problem. Does anyone know what exactly generates this file, and how I can stop it from adding the SDIO-related definitions into the project?
The RTE_Components.h is not supposed to be modified and will always be automatically generated. That the stack tries to connect via MCI interface is related to your configuration made in the "FS_Config_MC_0.h".
// <o>Connect to hardware via Driver_MCI# <0-255>
// <i>Select driver control block for hardware interface
#define MC0_MCI_DRIVER 0
// <o>Connect to hardware via Driver_SPI# <0-255>
// <i>Select driver control block for hardware interface when in SPI mode
#define MC0_SPI_DRIVER 0
// <o>Memory Card Interface Mode <0=>Native <1=>SPI
// <i>Native uses a SD Bus with up to 8 data lines, CLK, and CMD
// <i>SPI uses 2 data lines (MOSI and MISO), SCLK and CS
// <i>When using SPI both Driver_SPI# and Driver_MCI# must be specified
// <i>since the MCI driver provides the control interface lines.
#define MC0_SPI 1
I have written a simple Uart driver for uart4 instance for omap-4460 panda board with just open,close,read and write functions.How will it be different from omap-serial.c.
Should I include platform_driver_register in the init?
Since this is also a class of character devices how will it be different ?
I thought I would try out SDP on our infiniband hardware.
However, when I try to add AF_INET_SDP as the first argument to socket() I get the following error:
"Address family not supported by protocol".
Originally I had:
#define AF_INET_SDP 26
But after doing some reading, noticed a patch applied some time back to change this value to 27.
When set to 26 I get the error:
"Error binding socket: No such device"
Has anyone managed to get SDP working on Ubuntu 12.04? what did you do to get it up and running?
I have installed libsdp1 and libsdpa-dev
Using the LD_PRELOAD method on iperf I also get the first error:
LD_PRELOAD=libsdp.so iperf -s
dir: /tmp/libsdp.log.1000 file: /tmp/libsdp.log.1000/log
socket failed: Address family not supported by protocol
bind failed: Bad file descriptor
Therefore I assume 27 is the correct domain number.
SDP hasn't been accepted on the mainline linux kernel. On recent fedora, they don't ship it, neither the user space libsdp.
If you still want to experiment, Matt is right, the module in question is 'ib_sdp'.
try modprobe ib_sdp and run your example again.