PulseAudio cannot see working USB sound card - audio

I have a Raspberry Pi, running Raspbian, with a cheap SoundBlaster USB card plugged into it. The card is visible to ALSA:
# aplay -l | grep card
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 IEC958/HDMI [bcm2835 IEC958/HDMI]
card 0: ALSA [bcm2835 ALSA], device 2: bcm2835 IEC958/HDMI1 [bcm2835 IEC958/HDMI1]
card 1: S3 [Sound Blaster Play! 3], device 0: USB Audio [USB Audio]
And I can play sound through this card:
$ speaker-test -Dhw:1,0 -c2 -twav
does output "front left" and "front right" in a woman's voice through the connected speakers.
However, PulseAudio does not recognize the card:
$ pacmd list-sinks|egrep -i 'index:|name:'
* index: 0
name: <auto_null>
I'm not even sure how to select this card in alsamixer; hitting "F2" and looking at /proc/asound/cards does show this, but then "F6" only shows the default card and trying to enter another value, like "S3" (the name of the card) or "1" or "hw1" or "hw:1,0" just returns "Cannot open mixer device [whatever]. No such file or directory."
I've tried a variety of solutions I've found; none of them work. For example, adding load-module module-alsa-sink device=hw:1,0 to /etc/pulse/default.pa does not trigger an error, but it also does not change the output of pacmd list-sinks, and does not give me any sound.
Adding an ALSA configuration file consisting of:
pcm.!default {
type hw
card 1
}
ctl.!default {
type hw
card 1
}
does make the USB card available to alsamixer, and I can then play things directly through ALSA, e.g. $ aplay test.wav, but it's still invisible to Pulse via list-sinks, and if I try to play anything through Pulse, I get errors or no sound, e.g. with mocp sample.mp3 there's no sound.
I can't imagine this should be so hard, so I assume I'm missing something obvious. Could someone tell me what it is?
[EDIT:]
The output of ls -l /dev/snd is:
$ ls -l /dev/snd
total 0
drwxr-xr-x 2 root root 60 Jan 12 17:01 by-id
drwxr-xr-x 2 root root 80 Jan 12 17:01 by-path
crw-rw---- 1 root audio 116, 0 Jan 12 17:01 controlC0
crw-rw---- 1 root audio 116, 32 Jan 12 17:01 controlC1
crw-rw---- 1 root audio 116, 16 Jan 12 17:01 pcmC0D0p
crw-rw---- 1 root audio 116, 17 Jan 12 17:01 pcmC0D1p
crw-rw---- 1 root audio 116, 18 Jan 12 17:01 pcmC0D2p
crw-rw---- 1 root audio 116, 56 Jan 12 17:01 pcmC1D0c
crw-rw---- 1 root audio 116, 48 Jan 12 17:01 pcmC1D0p
crw-rw---- 1 root audio 116, 1 Jan 12 17:01 seq
crw-rw---- 1 root audio 116, 33 Jan 12 17:01 timer

Related

USB CDC ACM firmware compatilibities in different Linux

Due to development of IoT, I need a stable USB CDC ACM firmware in certain microcontroller. However I find the same device/firmware are not working well in all Linux OS.
I have tested the following boards/firmware:
STM32F103C8T6_USBSerial from mbed community
STM32F40X from mbed OS
Keil USB stack for STM32F103
STLinkV2 VCP from NUCLEO
NXP LPC54114 CMSIS-DAP VCP
STM32F103 CubeMX HAL (to be tested)
Maple STM32F103 USB driver (to be tested)
And I tried to connect these boards to:
OpenWRT
Ubuntu 12.04 desktop/server
Ubuntu 14.04 desktop/server
Ubuntu 15.04 desktop
And firmware #1 doesn't work for #1/2/3 OS, while some other hardware may work with most of the OS. I have tried different tools, including gtkterm/echo/cat/stty/minicom/usbmon, python serial and lua.io. The result is same.
It seems both firmware and OS have issues. However, in some cases, we can not change too much in OS. But how to identify the root cause and get it fixed.
Update
I pasted my tracking record here.
dmesg
[ 217.735609] usb 1-2: new full-speed USB device number 3 using ohci_hcd
[ 218.232189] usb 1-2: New USB device found, idVendor=1f00, idProduct=2012
[ 218.232195] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 218.232199] usb 1-2: Product: CDC DEVICE
[ 218.232202] usb 1-2: Manufacturer: mbed.org
[ 218.232205] usb 1-2: SerialNumber: 0123456789
[ 218.298612] cdc_acm 1-2:1.0: ttyACM0: USB ACM device
[ 218.320171] usbcore: registered new interface driver cdc_acm
[ 218.320179] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
lsusb
Bus 001 Device 002: ID 80ee:0021 VirtualBox USB Tablet
Bus 001 Device 003: ID 1f00:2012
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
lsbusb -v
Bus 001 Device 003: ID 1f00:2012
Couldn't open device, some information will be missing
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 2 Communications
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x1f00
idProduct 0x2012
bcdDevice 1.00
iManufacturer 1
iProduct 2
iSerial 3
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 75
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 100mA
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 2 Communications
bFunctionSubClass 2 Abstract (modem)
bFunctionProtocol 0 None
iFunction 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 2 Communications
bInterfaceSubClass 2 Abstract (modem)
bInterfaceProtocol 1 AT-commands (v.25ter)
iInterface 0
CDC Header:
bcdCDC 1.10
CDC Call Management:
bmCapabilities 0x03
call management
use DataInterface
bDataInterface 1
CDC ACM:
bmCapabilities 0x06
sends break
line coding and serial state
CDC Union:
bMasterInterface 0
bSlaveInterface 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 16
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 10 CDC Data
bInterfaceSubClass 0 Unused
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
find /dev/bus
/dev/bus
/dev/bus/usb
/dev/bus/usb/001
/dev/bus/usb/001/003
/dev/bus/usb/001/002
/dev/bus/usb/001/001
USB devices info
ll /sys/bus/usb/devices
总用量 0
drwxr-xr-x 2 root root 0 1月 26 19:34 ./
drwxr-xr-x 4 root root 0 1月 26 19:34 ../
lrwxrwxrwx 1 root root 0 1月 26 19:34 1-0:1.0 -> ../../../devices/pci0000:00/0000:00:06.0/usb1/1-0:1.0/
lrwxrwxrwx 1 root root 0 1月 26 19:34 1-1 -> ../../../devices/pci0000:00/0000:00:06.0/usb1/1-1/
lrwxrwxrwx 1 root root 0 1月 26 19:34 1-1:1.0 -> ../../../devices/pci0000:00/0000:00:06.0/usb1/1-1/1-1:1.0/
lrwxrwxrwx 1 root root 0 1月 26 19:38 1-2 -> ../../../devices/pci0000:00/0000:00:06.0/usb1/1-2/
lrwxrwxrwx 1 root root 0 1月 26 19:41 1-2:1.0 -> ../../../devices/pci0000:00/0000:00:06.0/usb1/1-2/1-2:1.0/
lrwxrwxrwx 1 root root 0 1月 26 19:41 1-2:1.1 -> ../../../devices/pci0000:00/0000:00:06.0/usb1/1-2/1-2:1.1/
lrwxrwxrwx 1 root root 0 1月 26 19:34 usb1 -> ../../../devices/pci0000:00/0000:00:06.0/usb1/
cd /sys/bus/usb/devices/1-2
ll
ll
总用量 0
drwxr-xr-x 6 root root 0 1月 26 19:38 ./
drwxr-xr-x 7 root root 0 1月 26 19:34 ../
drwxr-xr-x 5 root root 0 1月 26 19:38 1-2:1.0/
drwxr-xr-x 5 root root 0 1月 26 19:38 1-2:1.1/
-rw-r--r-- 1 root root 4096 1月 26 19:54 authorized
-rw-r--r-- 1 root root 4096 1月 26 19:54 avoid_reset_quirk
-r--r--r-- 1 root root 4096 1月 26 19:38 bcdDevice
-rw-r--r-- 1 root root 4096 1月 26 19:54 bConfigurationValue
-r--r--r-- 1 root root 4096 1月 26 19:38 bDeviceClass
-r--r--r-- 1 root root 4096 1月 26 19:54 bDeviceProtocol
-r--r--r-- 1 root root 4096 1月 26 19:54 bDeviceSubClass
-r--r--r-- 1 root root 4096 1月 26 19:54 bmAttributes
-r--r--r-- 1 root root 4096 1月 26 19:54 bMaxPacketSize0
-r--r--r-- 1 root root 4096 1月 26 19:54 bMaxPower
-r--r--r-- 1 root root 4096 1月 26 19:54 bNumConfigurations
-r--r--r-- 1 root root 4096 1月 26 19:54 bNumInterfaces
-r--r--r-- 1 root root 4096 1月 26 19:38 busnum
-r--r--r-- 1 root root 4096 1月 26 19:54 configuration
-r--r--r-- 1 root root 65553 1月 26 19:38 descriptors
-r--r--r-- 1 root root 4096 1月 26 19:54 dev
-r--r--r-- 1 root root 4096 1月 26 19:38 devnum
-r--r--r-- 1 root root 4096 1月 26 19:54 devpath
lrwxrwxrwx 1 root root 0 1月 26 19:38 driver -> ../../../../../bus/usb/drivers/usb/
drwxr-xr-x 3 root root 0 1月 26 19:54 ep_00/
-r--r--r-- 1 root root 4096 1月 26 19:38 idProduct
-r--r--r-- 1 root root 4096 1月 26 19:38 idVendor
-r--r--r-- 1 root root 4096 1月 26 19:54 ltm_capable
-r--r--r-- 1 root root 4096 1月 26 19:38 manufacturer
-r--r--r-- 1 root root 4096 1月 26 19:54 maxchild
lrwxrwxrwx 1 root root 0 1月 26 19:54 port -> ../1-0:1.0/port2/
drwxr-xr-x 2 root root 0 1月 26 19:54 power/
-r--r--r-- 1 root root 4096 1月 26 19:38 product
-r--r--r-- 1 root root 4096 1月 26 19:54 quirks
-r--r--r-- 1 root root 4096 1月 26 19:38 removable
--w------- 1 root root 4096 1月 26 19:54 remove
-r--r--r-- 1 root root 4096 1月 26 19:38 serial
-r--r--r-- 1 root root 4096 1月 26 19:38 speed
lrwxrwxrwx 1 root root 0 1月 26 19:38 subsystem -> ../../../../../bus/usb/
-rw-r--r-- 1 root root 4096 1月 26 19:38 uevent
-r--r--r-- 1 root root 4096 1月 26 19:54 urbnum
-r--r--r-- 1 root root 4096 1月 26 19:54 version
cat virutal files
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat authorized
1
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat avoid_reset_quirk
0
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat bcdDevice
0100
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat bConfigurationValue
1
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat bDeviceClass
02
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat bDeviceProtocol
00
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat bDeviceSubClass
00
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat bmAttributes
80
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat bMaxPacketSize0
64
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat bMaxPower
100mA
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat bNumConfigurations
1
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat bNumInterfaces
2
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat busnum
1
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat configuration
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat descriptors
# K�2
$$$$�#
�##allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat dev
189:2
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat devnum
3
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat devpath
2
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat idProduct
2012
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat idVendor
1f00
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat ltm_capable
no
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat manufacturer
mbed.org
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat maxchild
0
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat product
CDC DEVICE
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat quirks
0x0
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat removable
unknown
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat remove
cat: remove: 权限不够
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat serial
0123456789
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat speed
12
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat uevent
MAJOR=189
MINOR=2
DEVNAME=bus/usb/001/003
DEVTYPE=usb_device
DRIVER=usb
PRODUCT=1f00/2012/100
TYPE=2/0/0
BUSNUM=001
DEVNUM=003
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat urbnum
138
allankliu#allankliu-VirtualBox:/sys/bus/usb/devices/1-2$ cat version
1.10
Check /dev/ttyACM0
crw-rw---- 1 root dialout 166, 0 1月 26 19:38 ttyACM0
usbmon
sudo ls /sys/kernel/debug/usb/usbmon
[sudo] password for allankliu:
0s 0u 1s 1t 1u
sudo cat /sys/kernel/debug/usb/devices
...
T: Bus=01 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 3 Spd=12 MxCh= 0
D: Ver= 1.10 Cls=02(comm.) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1f00 ProdID=2012 Rev= 1.00
S: Manufacturer=mbed.org
S: Product=CDC DEVICE
S: SerialNumber=0123456789
C:* #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=100mA
A: FirstIf#= 0 IfCount= 2 Cls=02(comm.) Sub=02 Prot=00
I:* If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=02 Prot=01 Driver=cdc_acm
E: Ad=81(I) Atr=03(Int.) MxPS= 64 Ivl=16ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_acm
E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms
E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms
device file system
/dev/ttyACM0 is generated as soon as the device is plugged in.
gtkterm
The device can be opened, but not output, regardless the baudrate.
Observation
In lsusb, no product name is printed out, but working CDC devices also have same issue;
In lsusb -v, error of Couldn't open device, some information will be missing, however even Linux hub has same problem.
When cat /sys/bus/usb/devices/1-2/descriptor, it returns binary data, but other USB devices are same, it seems a binary file, anyway.
So far, based upon data, I can not find big differences or error from OS, but it has no output anyway, but it has output in Windows/Ubuntu 15 or later.
Next step, I will use wireshark/tcpdump to find out.
Update
After some labs, I found actually this STM32F103C8 (so-called bluepill) has already successfully emuerated. And the USB dongle has been supported in OpenWRT/Ubuntu12.04/14.04/16.04/18.04, but sometimes the device stalls for a while. After such pause, the communication is back to normal.
Pure firmware issue.
I would recommend getting a nice USB protocol analyzer like the Beagle USB 12 so you can look at the communication going between the device and the OS. You can study both the working case and the non-working case.
You should also run dmesg and look for messages from Linux's cdc-acm driver when you plug the device in. You can find out what kernel version you are running with uname -a and then look at the source code of the cdc-acm module in that kernel version.
You can see the USB descriptors of you device using lsusb -v and make sure they are valid.
You should also make sure you get a clear understanding of what symptoms your system has when it's not working, and use that to narrow your search for the problem. For example, if the /dev entry was not being created, that is a different type of problem than if your reads and writes to the port were failing.
Using the above methods you should be able to figure out what is wrong and fix it. This is almost certainly a firmware problem, not a hardware problem. I suspect there is something wrong with your USB descriptors so I'd start looking there first.

BeagleBone Black UART1 enabled, but does not send or receive data

I have (finally) managed to get UART1 going on my BBB using the instructions here:
http://tenderlovemaking.com/2014/01/19/enabling-ttyo1-on-beaglebone.html
Doing ls -la /dev/ttyO* gives
crw--w---- 1 root tty 248, 0 Sep 22 14:50 /dev/ttyO0
crw-rw---- 1 root dialout 248, 1 Sep 22 14:50 /dev/ttyO1
but I cannot seem to write or read anything.
echo "wibble" > /dev/ttyO1
does nothing (I ran screen /dev/ttyO1 115200 in another terminal window). Is there a further step to actually get data flowing through the serial port?
Note: Beaglebone revision is B6.

Apple HLS with ffmpeg and mediastreamsegmenter and vlc

I'm trying to stream using a ffmpeg stream from a windows box. Here is the command I'm running on the windows box
ffmpeg -f dshow -i audio=”Wave In 2 32130101 (Orban Optim” -acodec libmp3lame -ab 64k -f mpegts udp://172.30.16.181:2222?pkt_size=188?buffer_size=128000
This part works and I'm able to listen to it on my mac via VLC and I'm streaming it out from VLC to port 20103
but when I use mediasegmenter
mediastreamsegmenter -s 3 -f /Users/vickkrish/ 127.0.0.1:2222
This is what happens
Mar 6 2014 04:11:02.926: audio pid set at 44
Mar 6 2014 04:11:03.165: audio pid change to 44
Mar 6 2014 04:11:03.328: audio pid change to 44
Mar 6 2014 04:11:03.583: audio pid change to 44
Mar 6 2014 04:11:03.745: audio pid change to 44
Mar 6 2014 04:11:03.989: audio pid change to 44
Mar 6 2014 04:11:04.151: audio pid change to 44
Mar 6 2014 04:11:04.316: audio pid change to 44
Mar 6 2014 04:11:04.492: audio pid change to 44
Mar 6 2014 04:11:04.740: audio pid change to 44
Mar 6 2014 04:11:04.887: audio pid change to 44
Mar 6 2014 04:11:05.175: audio pid change to 44
Mar 6 2014 04:11:05.338: audio pid change to 44
Mar 6 2014 04:11:05.582: audio pid change to 44
and no .ts files are created.
Try to pipe FFmpeg's output to mediastreamsegmenter instead of making mediastreamsegmenter listen to a UDP port.
Something along the lines of
ffmpeg -i {video} -b:a {audio_bitrate} -b:v {video_bitrate} -vcodec libx264 -acodec aac -strict -2 - | mediastreamsegmenter -b {url_for_manifest} -f {directory_to_dump_ts} -D
Wouldn't it be easier to use VLC for transcoding AND segmenting? Something along lines of
ip=$1
port=$2
name=$3
host=$4
mkdir -p /wwwroot/$name
rm /wwwroot/$name/$name*.*
voptions="threads=4,width=720,height=576,fps=25,vcodec=h264,vb=2048,venc=x264{aud,profile=baseline,level=30,keyint=25,bframes=0,ref=1,nocabac},acodec=mp4a,ab=192,channels=2" # 2 mpbs Full D1
index="/wwwroot/$name/$name.m3u8"
idxurl="http://$host/$name/$name-########.ts"
dst="/wwwroot/$name/$name-########.ts"
vlc-wrapper -I dummy udp://#$ip:$port vlc://quit --sout="#transcode{$voptions}:duplicate{dst=std{access=livehttp{seglen=60,numsegs=60,index=$index,index-url=$idxurl},mux=ts{use-key-frames},dst=$dst}}" -vvv

Linux Userspace GPIO Interrupts using sysfs

I would like to use interrupts with GPIO on userspace using sysfs.
I use these commands :
[root#at91]:gpio109 > echo 109 > export
[root#at91]:gpio109 > cd gpio109/
[root#at91]:gpio109 > ll
-rw-r--r-- 1 root 0 4096 Jan 1 00:17 direction
drwxr-xr-x 2 root 0 0 Jan 1 00:17 power
lrwxrwxrwx 1 root 0 0 Jan 1 00:17 subsystem -> ../../gpio
-rw-r--r-- 1 root 0 4096 Jan 1 00:17 uevent
-rw-r--r-- 1 root 0 4096 Jan 1 00:17 value
The gpio works well but I can't use interrupts.
I read everywhere i must have an edge file to poll this file. But on my system this file doesn't exist.
I made a lot of tries to find a solution but remain unsuccessfull.
My target is an AT91SAM9263 on linux kernel 2.6.30.
At the boot of my board I got this message on interrupts :
AT91: 160 gpio irqs in 5 banks
which show that the function at91_gpio_irq_setup() is well executed.
Have you any idea ?
The "edge" file only exists if that GPIO pin can be configured as a an interrupt generting pin. See: http://www.mjmwired.net/kernel/Documentation/gpio.txt#634.
Since you don't see it, it means the driver and possibly the hardware do not support using that GPIO pin for interrupt source.

knowing a device special file major and minor numbers in linux

All files in /dev are special files... they represent devices of the computer.
They were created with the mknod syscall. My question is: How can I know the minor and
major numbers that were used to create this special file?
The list is called the LANANA Linux Device List, and it is administered by Alan Cox.
You can find the latest copy online (direct link), or in the Linux source. Its filename in the kernel tree is Documentation/devices.txt.
To see the major and minor numbers that created a node in /dev (or any device node for that matter), simply use ls with the -l option:
22:26 jsmith#undertow% ls -l /dev/xvd?
brw-rw---- 1 root disk 202, 0 Nov 1 20:31 /dev/xvda
brw-rw---- 1 root disk 202, 16 Nov 1 20:31 /dev/xvdb
brw-rw---- 1 root disk 202, 32 Nov 1 20:31 /dev/xvdc
In this example, 202 is the three devices' major number, and 0, 16, and 32 are minors. The b at left indicates that the node is a block device. The alternative is c, a character device:
crw-rw-rw- 1 root tty 5, 0 Nov 22 00:29 /dev/tty
$ ls -l /dev/fd0 /dev/null
brw-rw---- 1 root floppy 2, 0 Nov 22 19:48 /dev/fd0
crw-rw-rw- 1 root root 1, 3 Nov 22 19:48 /dev/null
$ stat -c '%n: %F, major %t minor %T' /dev/fd0 /dev/null
/dev/fd0: block special file, major 2 minor 0
/dev/null: character special file, major 1 minor 3
Most device numbers are fixed (i.e. /dev/null will always be character device 1:3) but on Linux, some are dynamically allocated.
$ cat /proc/devices
Character devices:
...
10 misc
...
Block devices:
...
253 mdp
254 device-mapper
$ cat /proc/misc
...
57 device-mapper
...
For example, on this system, it just so happens that /dev/mapper/control will be c:10:57 while the rest of /dev/mapper/* will be b:254:*, and this could differ from one boot cycle to another -- or even as modules are loaded/unloaded and devices are added/removed.
You can explore these device registrations further in /sys.
$ readlink /sys/dev/block/2:0
../../devices/platform/floppy.0/block/fd0
$ cat /sys/devices/platform/floppy.0/block/fd0/dev
2:0
$ readlink /sys/dev/char/1:3
../../devices/virtual/mem/null
$ cat /sys/devices/virtual/mem/null/dev
1:3
You can also use stat.
$ stat -c 'major: %t minor: %T' <file>
Especially for block devices:
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 90G 0 disk
├─sda1 8:1 0 4G 0 part [SWAP]
├─sda2 8:2 0 4G 0 part /
Alternative that doesn't depend on stat:
$ cat /sys/class/*/random/dev
1:8

Resources