Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


  Search this Thread
Old 10-18-2008, 10:59 AM   #1
LQ Newbie
Registered: Oct 2008
Posts: 11

Rep: Reputation: 0
i2c character device file not created in linux 2.6.24 on at91sam9263ek

I am trying to use the i2c /dev user space driver interface for the i2c interface on my at91sam9263ek board. I'm using linux 2.6.24 and the documentation in Documentation/i2c/dev-interface states that a /dev/i2c-x file should exist if the i2c dev interface is enabled.

I have the kernel configured for the i2c dev interface and the at91sam9263 device using the i2c gpio interface. The kernel .config I2C entries are listed below.

# I2C Algorithms
# CONFIG_I2C_ALGOPCF is not set
# CONFIG_I2C_ALGOPCA is not set
# I2C Hardware Bus support
# CONFIG_I2C_OCORES is not set
# CONFIG_I2C_SIMTEC is not set
# CONFIG_I2C_TAOS_EVM is not set
# CONFIG_I2C_STUB is not set
# CONFIG_I2C_TINY_USB is not set
# CONFIG_I2C_PCA is not set
# Miscellaneous I2C Chip support
# CONFIG_I2C_DEBUG_CORE is not set
# CONFIG_I2C_DEBUG_ALGO is not set
# CONFIG_I2C_DEBUG_BUS is not set
# CONFIG_I2C_DEBUG_CHIP is not set
# I2C RTC drivers

The sysfs mounted to /sys shows the interface exists and has a major number of 89 and minor number of 0.

# pwd
# ls
dev device name subsystem uevent
# cat name
# cat uevent

The kernel boot up messages and the contents of sysfs show the device is being set up. I'm wondering if I need to create the /dev/i2c-0 device file manually or if there is some bug in the code.


Old 10-18-2008, 02:21 PM   #2
LQ Newbie
Registered: Oct 2008
Posts: 11

Original Poster
Rep: Reputation: 0
Tried manually created the device file with the following command

mknod i2c-0 c 89 0

The application could open the file but failed during ioctl to set the slave address. So it looks like there is something broken in the driver set up.

I tracked the code down in the i2c driver and I can't seem to locate the section of code that would
create the device file.
Old 10-19-2008, 06:12 PM   #3
LQ Newbie
Registered: Oct 2008
Posts: 11

Original Poster
Rep: Reputation: 0
Creating the device file manually actually works. There was a programming error in my user space code. So if I create the device file manually at /dev/i2c-0 then I can open the file, set the slave address with ioctl and then write to it. I get an EREMOTEIO back the write but that is supposed to be normal if the slave device does not nack. Haven't looked the data lines with the scope yet.

Still wondering why the driver initialization code does not create the device file for me. Why do I have to create it manually?
Old 10-20-2008, 03:05 PM   #4
LQ Newbie
Registered: Oct 2008
Posts: 11

Original Poster
Rep: Reputation: 0
OK. Now I think I've figured it out. A utility named mdev creates all the device files the are registerd during the kernel boot process. Somehow mdev has been left out of the boot sequence. Probably has to go after sysfs is mounted because it scans /sys to find device file registrations.
Old 10-20-2008, 07:01 PM   #5
LQ Newbie
Registered: Oct 2008
Posts: 11

Original Poster
Rep: Reputation: 0
The final part of the solution is to add /sbin/mdev -s to the /etc/inittab file. In buildroot, the template file is located at target/device/Atmel/root/pacakge_skeleton/etc/inittab. Once this was added the system now boots with all device files created. I can access /dev/i2c-0 and read and write from i2c devices.

According to the documentation mdev is a smaller version of udev in the busybox package. If you were using some other package then you might use udev instead of mdev to perform the same operation.

This one is now closed.
Old 05-27-2010, 11:03 AM   #6
LQ Newbie
Registered: May 2010
Posts: 1

Rep: Reputation: 0
I2C driver


I try to use the I2C driver in embedded Linux distribution 2.6.31 (DEBIAN lenny) but I encounter the following problems:

- in the .config file I have set the options :
After a successful kernel compilation (make ARCH=arm CROSS_COMPILE=/usr/armů-gcc) I saw that the directory /sys/class/i2c-dev/i2c-0 is empty so I cannot check with cat name or cat uevent command.
Besides that the /dev/i2c-0 device is not generated.
I have manually tried with mknod i2c-0 c 89 0 and succeed but when I try cat /dev/i2c-0 it cannot open the device.
- I am using a ARM Freescale platform and the supplier of the linux distribution included your i2c driver.

Normally I want to use your driver as a character driver, but as I have mentioned before I cannot found in /dev directory the device and the /sys/calss/i2c-dev/i2c-0 directory is empty.

I would appreciate a lot your help.

Many thanks in advance.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Find if file system is already created on the RAW device g_johnsonsamuel Programming 2 07-16-2007 01:48 PM
I2C device driver mylinuxdna Linux - General 0 10-10-2005 02:16 AM
I2C to external device ojschubert Linux - Hardware 0 02-08-2005 01:00 PM
How to change character device file name? taphos Linux - General 2 03-28-2004 08:12 AM
I have 8 character file name, no extension files being created in my dbaseIII+ folder bonzo Linux - General 2 01-22-2004 06:49 AM > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 03:25 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration