Hello,
I am using a generic USB sound card (Quantum). The card is detected correctly on boot and aplay -l shows it.
But when I try to play a .wav file
aplay -D plughw:1,0 WELCOME.wav
it takes a while and prints out a lot of data about the file and one of the lines is
aplay: set_params:1145: unable to install hw params:
and there is no sound from the usb sound card.
Now if I remove the USB sound card and reinsert it, everything works OK.
This is a problem as the application has to work from power on unattended.
What could be wrong?
My OS Debian Wheezy 16-7-2012 .
I tried
apt-get update
apt-get install alsa-utils -> this says everything is uptodate
Thanks for any help.
Re: usb audio works only after reinserting after boot
Update:
After help from another thread (ALSA on Raspbian) I figured out that the USB sound card works OK with only the keyboard connected. It does not work at boot time if a USB hub to which a keyboard and mouse are connected. Problem seems to be with the usb stack of the OS or something to do with loading of the 5V supply.
After help from another thread (ALSA on Raspbian) I figured out that the USB sound card works OK with only the keyboard connected. It does not work at boot time if a USB hub to which a keyboard and mouse are connected. Problem seems to be with the usb stack of the OS or something to do with loading of the 5V supply.
-
- Posts: 13
- Joined: Mon Aug 13, 2012 4:25 am
Re: usb audio works only after reinserting after boot
I started seeing this issue after rpi-updating to the recent overclock-friendly setup w/ the 'turbo' and 'high' modes.... e.g.
The fix for plugging and unplugging the PS3 Eye camera did indeed enable audio. If using the system after a fresh boot w/ same webcam plugged in, you get
After unplug/plug, I can successfully watch the audio level using:
And even better after setting up ~/.asoundrc,
I can just record a single channel that is summed via alsa's softvol plugin
Which shows the ALSA plugins a summin' (as to whether this is more or less efficient than not summing and just recording 4 channels, TBD):
Code: Select all
rpi3-11-~> vcgencmd version
Sep 23 2012 14:52:55
Copyright (c) 2012 Broadcom
version 338882 (release)
rpi3-12-~> uname -a
Linux rpi3 3.2.27+ #168 PREEMPT Sat Sep 22 19:26:13 BST 2012 armv6l GNU/Linux
Code: Select all
arecord: pcm_read:1801: read error: Input/output error
Code: Select all
arecord -vv /dev/null -r 16000 -f S16_LE -c 4 -D iec958:CARD=CameraB409241,DEV=0 /dev/null < /dev/null
Code: Select all
## Suggested by http://julius.sourceforge.jp/forum/viewtopic.php?f=9&t=66
pcm.array {
type hw
card 1
}
pcm.array_gain {
type softvol
slave {
pcm "array"
}
control {
name "Mic Gain"
count 2
}
min_dB -10.0
max_dB 5.0
}
pcm.cap {
type plug
slave {
pcm "array_gain"
channels 4
}
route_policy sum
}
Code: Select all
## see 'pcm.cap' defined in .asoundrc which sums 4 channels from Sony PS3 Eye camera into one
arecord -vv /dev/null -D cap -r 16000 /dev/null < /dev/null
Code: Select all
Recording WAVE '/dev/null' : Unsigned 8 bit, Rate 16000 Hz, Mono
Plug PCM: Route conversion PCM (sformat=S16_LE)
Transformation table:
0 <- 0*0.25 + 1*0.25 + 2*0.25 + 3*0.25
Its setup is:
stream : CAPTURE
access : RW_INTERLEAVED
format : U8
subformat : STD
channels : 1
rate : 16000
exact rate : 16000 (16000/1)
msbits : 8
buffer_size : 8000
period_size : 2000
period_time : 125000
tstamp_mode : NONE
period_step : 1
avail_min : 2000
period_event : 0
start_threshold : 1
stop_threshold : 8000
silence_threshold: 0
silence_size : 0
boundary : 2097152000
Slave: Soft volume PCM
Control: Mic Gain
min_dB: -10
max_dB: 5
resolution: 256
Its setup is:
stream : CAPTURE
access : MMAP_INTERLEAVED
format : S16_LE
subformat : STD
channels : 4
rate : 16000
exact rate : 16000 (16000/1)
msbits : 16
buffer_size : 8000
period_size : 2000
period_time : 125000
tstamp_mode : NONE
period_step : 1
avail_min : 2000
period_event : 0
start_threshold : 1
stop_threshold : 8000
silence_threshold: 0
silence_size : 0
boundary : 2097152000
Slave: Hardware PCM card 1 'USB Camera-B4.09.24.1' device 0 subdevice 0
Its setup is:
stream : CAPTURE
access : MMAP_INTERLEAVED
format : S16_LE
subformat : STD
channels : 4
rate : 16000
exact rate : 16000 (16000/1)
msbits : 16
buffer_size : 8000
period_size : 2000
period_time : 125000
tstamp_mode : NONE
period_step : 1
avail_min : 2000
period_event : 0
start_threshold : 1
stop_threshold : 8000
silence_threshold: 0
silence_size : 0
boundary : 2097152000
appl_ptr : 0
hw_ptr : 0
##+ | 02%
-
- Posts: 13
- Joined: Mon Aug 13, 2012 4:25 am
Re: usb audio works only after reinserting after boot
When using the arecord-based 'levelmeter' above for the PS3 Eye webcam, the kernel outputs much spew related to recording from device:
From /var/log/kern.log
Code: Select all
rpi3-14-~> arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: CameraB409241 [USB Camera-B4.09.24.1], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
Code: Select all
Sep 23 17:42:14 rpi3 kernel: [13004.461067] retire_capture_urb: 12 callbacks suppressed
Sep 23 17:42:38 rpi3 kernel: [13028.705949] retire_capture_urb: 8 callbacks suppressed
Sep 23 17:42:49 rpi3 kernel: [13040.109209] retire_capture_urb: 9 callbacks suppressed
Sep 23 17:47:08 rpi3 kernel: [13298.822208] retire_capture_urb: 6 callbacks suppressed
Sep 23 17:47:14 rpi3 kernel: [13304.380002] retire_capture_urb: 14 callbacks suppressed
Sep 23 17:47:19 rpi3 kernel: [13309.849672] retire_capture_urb: 4 callbacks suppressed
Sep 23 17:47:25 rpi3 kernel: [13315.359351] retire_capture_urb: 9 callbacks suppressed
Sep 23 17:47:30 rpi3 kernel: [13320.979042] retire_capture_urb: 1 callbacks suppressed
Sep 23 17:47:38 rpi3 kernel: [13328.582980] retire_capture_urb: 8 callbacks suppressed
Sep 23 17:47:44 rpi3 kernel: [13334.661729] retire_capture_urb: 7 callbacks suppressed
Sep 23 17:48:29 rpi3 kernel: [13379.712274] retire_capture_urb: 16 callbacks suppressed
Sep 23 17:48:34 rpi3 kernel: [13384.997928] retire_capture_urb: 4 callbacks suppressed
Sep 23 17:48:40 rpi3 kernel: [13390.761634] retire_capture_urb: 18 callbacks suppressed
-
- Posts: 13
- Joined: Mon Aug 13, 2012 4:25 am
Re: usb audio works only after reinserting after boot
Is the issue perhaps because the USB webcam soundcard ALSA initialization happens before the main ALSA initialization:
Code: Select all
[ 3.529184] usb 1-1.3: new high-speed USB device number 5 using dwc_otg
[ 3.652336] usb 1-1.3: New USB device found, idVendor=1415, idProduct=2000
[ 3.668947] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 3.678678] usb 1-1.3: Product: USB Camera-B4.09.24.1
[ 3.704962] usb 1-1.3: Manufacturer: OmniVision Technologies, Inc.
[ 3.872892] udevd[137]: starting version 175
[ 5.676431] Linux video capture interface: v2.00
[ 5.961164] gspca_main: v2.14.0 registered
[ 5.971003] gspca_main: ov534-2.14.0 probing 1415:2000
[ 6.508209] usbcore: registered new interface driver ov534
[ 6.927957] usbcore: registered new interface driver rtl8192cu
[ 7.300727] usbcore: registered new interface driver snd-usb-audio
[ 9.797805] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[ 10.350296] bcm2835 ALSA card created!
[ 10.356376] bcm2835 ALSA chip created!
[ 10.375779] bcm2835 ALSA chip created!
[ 10.386350] bcm2835 ALSA chip created!
[ 10.394391] bcm2835 ALSA chip created!
[ 10.402380] bcm2835 ALSA chip created!
[ 10.410214] bcm2835 ALSA chip created!
[ 10.417829] bcm2835 ALSA chip created!
Re: usb audio works only after reinserting after boot
I have a similar problem capturing audio with my USB PS3 Eye camera. The camera works fine, but the audio doesn't record unless I unplug the usb connector and plug it back in. Then it magically works.
To be more specific, after a reboot,
arecord -vv -f dat -D plughw:1,0 test.wav makes a 44 byte file every time. No recoding. The -vv option is supposed to dump a lot of info and then shows a little level meter. The info appears, but the level meter never does.
After unplugging and re-plugging in the usb cable, the same command above works great. Level meter appears and works. The dumped info is identical to what I get with the command before the unplug/replug.
I've tried mucking with /etc/modules, /etc/asound.conf, resetting the USB from software, and lots more stuff all to no avail. I can't figure out how to avoid pulling the USB plug and putting it back in again.
Has anyone overcome this problem? Thanks!
To be more specific, after a reboot,
arecord -vv -f dat -D plughw:1,0 test.wav makes a 44 byte file every time. No recoding. The -vv option is supposed to dump a lot of info and then shows a little level meter. The info appears, but the level meter never does.
After unplugging and re-plugging in the usb cable, the same command above works great. Level meter appears and works. The dumped info is identical to what I get with the command before the unplug/replug.
I've tried mucking with /etc/modules, /etc/asound.conf, resetting the USB from software, and lots more stuff all to no avail. I can't figure out how to avoid pulling the USB plug and putting it back in again.
Has anyone overcome this problem? Thanks!
Re: usb audio works only after reinserting after boot
Hey guys! I'm brand new to the Pi scene and just created my account for this specific issue. I'm using a Pi to monitor noise levels using a Samson C01U microphone. I wrote a Perl script that records a second of audio using arecord then uses sox to analyze it for maximum amplitude and stores that into a SQLite database. I'm experiencing this exact issue. Namely, if I boot the device with the microphone attached then I get the error listed by other users. If I unplug/replug it then it suddenly works - but not reliably. After reading from it a few hundred times it suddenly does it again.
Clearly this is a system wide issue, there are very much different audio devices. I wonder what the common ground is between these?
Code: Select all
pi@raspberrypi ~ $ arecord -d 1 -D hw:1 -c 1 -vvvv -f cd --file-type wav > file.wav
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
arecord: set_params:1145: Unable to install hw params:
ACCESS: RW_INTERLEAVED
FORMAT: S16_LE
SUBFORMAT: STD
SAMPLE_BITS: 16
FRAME_BITS: 32
CHANNELS: 2
RATE: 44100
PERIOD_TIME: (125011 125012)
PERIOD_SIZE: 5513
PERIOD_BYTES: 22052
PERIODS: (3 4)
BUFFER_TIME: 500000
BUFFER_SIZE: 22050
BUFFER_BYTES: 88200
TICK_TIME: 0
Re: usb audio works only after reinserting after boot
I'm having this problem with a PlayStation Eye camera as well (with a Raspberry Pi Zero W running Jessie). The mic works fine if plugged in after boot or if plugged in on boot from power off, but if I reboot the Pi with the mic plugged in, it fails (arecord never stops recording, even if a duration is specified) until I unplug and replug it. The mic is reported by alsa as an available device even when it isn't working.
I've tried resetting the USB device using https://gist.github.com/x2q/5124616, but no dice: it reports a successful reset but the mic still doesn't work. I'm tried forcing alsa to reload, but that also doesn't seem to work. Not sure where to go from here :/
I've tried resetting the USB device using https://gist.github.com/x2q/5124616, but no dice: it reports a successful reset but the mic still doesn't work. I'm tried forcing alsa to reload, but that also doesn't seem to work. Not sure where to go from here :/
Re: usb audio works only after reinserting after boot
nobody found any solution after more than a year later ??
if there is a method to unplug and plug using script/software, then might be the solution
if there is a method to unplug and plug using script/software, then might be the solution
Re: usb audio works only after reinserting after boot
Pi Zero W with playstation eye as the only connected USB device
Issue persists on
Works immediately if reinserted after reboot. Is there an open issue tracker for this somewhere?
Issue persists on
Code: Select all
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
Code: Select all
Raspberry Pi reference 2018-10-09
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 7b40fd11bc13d6496bb6bd1bc02f946b7e0ac7cb, stage2
Code: Select all
Linux raspberrypi 4.14.89+ #1182 Tue Dec 18 00:20:30 GMT 2018 armv6l GNU/Linux
Re: usb audio works only after reinserting after boot
I have a similar problem with my USB audio device: unrecognized upon reboot, then recognized if unplugged and plugged back in. The only interesting part is that the problem for me occurs with the Pi Zero W. When I try to do the same with a Pi 3b (same configuration/settings), it works just fine after a reboot.
Was anyone able to find a solution or workaround?
Was anyone able to find a solution or workaround?
-
- Posts: 1
- Joined: Wed Mar 27, 2019 7:37 pm
Re: usb audio works only after reinserting after boot
I'm having similar problem with these speakers: https://www.adafruit.com/product/3369
I'm using a Raspberry Pi Zero W with Raspian Stretch Lite Kernel 4.14
Looks like the root cause is the usb speakers down get autodiscovered after reboot. If I do a reboot and do a lsusb this is what I get:
And after I unplug and replug in the usb cable, then look at the usb devices:
Does anyone know how this auto discover works (assuming the unplugging and replugging is some sort of autodiscovery)? Is there a way to trigger this discovery from a bash file or at startup?
Any help would be appreciated. Thanks.
I'm using a Raspberry Pi Zero W with Raspian Stretch Lite Kernel 4.14
Looks like the root cause is the usb speakers down get autodiscovered after reboot. If I do a reboot and do a lsusb this is what I get:
Code: Select all
XXXX@XXXXXX:~ $ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Code: Select all
XXXX@XXXXXX:~ $ lsusb
Bus 001 Device 002: ID 1908:2070 GEMBIRD
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Any help would be appreciated. Thanks.
Re: usb audio works only after reinserting after boot
I'm also having these problems and it's very hard to identify the cause, it doesn't seem to be an ALSA problem but related to USB.
It happens with the combination of the above Mini speaker: https://www.adafruit.com/product/3369
and respeaker or the playstation eye microphone, I'm getting:
It's a PI 3 stretch lite with Kernel 4.14.79-v7+
I have no idea which of the items causes this, but it might be the Mini Speaker
Can anyone help us?
It happens with the combination of the above Mini speaker: https://www.adafruit.com/product/3369
and respeaker or the playstation eye microphone, I'm getting:
Code: Select all
speaker-test 1.1.3
Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 96 to 262144
Period size range from 48 to 131072
Using max buffer size 262144
Periods = 4
was set period_size = 65536
was set buffer_size = 262144
0 - Front Left
Time per period = 0.197401
0 - Front Left
Write error: -77,File descriptor in bad state
xrun_recovery failed: -77,File descriptor in bad state
Transfer failed: File descriptor in bad state
I have no idea which of the items causes this, but it might be the Mini Speaker
Can anyone help us?
Re: usb audio works only after reinserting after boot
Hi, yes. I tried it and it works. Just run these two commands after start and PS3 camera will work.
Code: Select all
To shut off power on USB ports (this shuts power on ethernet as well):
echo '1-1' | sudo tee /sys/bus/usb/drivers/usb/unbind
To turn power back on
echo '1-1' | sudo tee /sys/bus/usb/drivers/usb/bind
To do so, run:
Code: Select all
sudo nano /etc/rc.local
Code: Select all
echo '1-1' | sudo tee /sys/bus/usb/drivers/usb/unbind
echo '1-1' | sudo tee /sys/bus/usb/drivers/usb/bind
exit 0