Homepage Wiki Forum Buy

SpecialDeviceFiles

From GNUBLIN

Contents

Creating missing device files

Generic

In the Gnublin rootfs there are not all special devices created, in the directory /dev, to communicate with some kernel modules. User space programs are using these special device files to communicate with the kernel modules. If some of the special device files you need, are not in the /dev directory, you have to create them manually. You need to know some information about the device (device type: block or character , major and minor number of device) You can get these information by searching in the source code of the used kernel module or by just looking it up in the internet or on a PC/Laptop running Linux. You also need the program "mknod" (preinstalled on GNUBLIN).

These special device files could be useful for example:

crw-r--r-- 1 root root 89, 0 Sep 27 2011 i2c-0
crw-r--r-- 1 root root 89, 1 Sep 27 2011 i2c-1
brw-r--r-- 1 root root 179, 0 Sep 27 2011 mmcblk0
brw-r--r-- 1 root root 179, 1 Sep 27 2011 mmcblk0p1
brw-r--r-- 1 root root 179, 2 Sep 27 2011 mmcblk0p2
brw-r--r-- 1 root root 8, 0 Mar 23 11:17 sda
brw-r--r-- 1 root root 8, 1 Mar 23 11:17 sda1
brw-r--r-- 1 root root 1, 5 Apr 21 00:28 zero

How To

i2c-0 is not connected on the Gnublin and isn't needed. You need i2c-1 if you want to add I2C to your project. The first sign in the list above shows us if the device file is a block (b) or character (c) based deviced.

You can add these device files with the following commands:

root@gnublin:~$ cd /dev
root@gnublin:/dev$ mknod i2c-0 c 89 0
root@gnublin:/dev$ mknod i2c-1 c 89 1
root@gnublin:/dev$ mknod mmcblk0 b 179 0
root@gnublin:/dev$ mknod mmcblk0p1 b 179 1
root@gnublin:/dev$ mknod mmcblk0p2 b 179 2
root@gnublin:/dev$ mknod sda b 8 0
root@gnublin:/dev$ mknod sda b 8 1
root@gnublin:/dev$ mknod zero c 1 5

Result

If the hardware is connected to the board and the programs used are installed, you can communicate with the hardware. The following example shows us with an I2C interface (Temperature sensor LM75) the procedure how you can communicate with the interface if a special device file does not exist for the hardware.

root@gnublin:~$ i2cget -y 1 0x48 0 w Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory root@gnublin:~$ mknod /dev/i2c-1 c 89 1 root@gnublin:~$ i2cget -y 1 0x48 0 w 0xc016

The following fdisk command shows us the result, if the special device file /dev/sda already exists and a USB storage is attached to the Gnublin.

root@gnublin:~$ fdisk -l /dev/sda Disk /dev/sda: 2004 MB, 2004877312 bytes 62 heads, 62 sectors/track, 1018 cylinders Units = cylinders of 3844 * 512 = 1968128 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xc3072e18 Device Boot Start End Blocks Id System /dev/sda1 3 1018 1952752 83 Linux /dev/sda2 1 2 2820 df BootIt Partition table entries are not in disk order root@gnublin:~$
In other languages