USB DAC on Raspbian produces error - usb

I finally got a USB DAC (HiFimeDIY Sabre DAC) for my Raspberry Pi (running on Raspbian Wheezy) today, but of course, just plugging it in doesn't do the trick. I've been messing around for quite some time with ALSA configuration now, but to no avail. Audio playback through the 3.5" headphone jack works just fine, but I can't seem to get the audio to play through USB. aplay -L gives
pi#raspberrypi ~ $ aplay -L
...
pulse
Playback/recording through the PulseAudio sound server
sysdefault:CARD=DAC
HiFimeDIY DAC, USB Audio
Default Audio Device
front:CARD=DAC
HiFimeDIY DAC, USB Audio
Default Audio Device
...
sysdefault:CARD=ALSA
bcm2835 ALSA, bcm2835 ALSA
Default Audio Device
front:CARD=ALSA
bcm2835 ALSA, bcm2835 ALSA
Default Audio Device
I wonder if both cards being marked as "Default Audio Device" is a good thing?
Anyways, testing playback via
pi#raspberrypi ~ $ aplay /usr/share/sounds/alsa/Front_Center.wav -D sysdefault:CARD=ALSA
Playback: WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate: 48000 Hz, mono
works fine, but
pi#raspberrypi ~ $ aplay /usr/share/sounds/alsa/Front_Center.wav -D sysdefault:CARD=DAC
ALSA lib pcm_direct.c:980:(snd1_pcm_direct_initialize_slave) unable to install hw params
ALSA lib pcm_dmix.c:1030:(snd_pcm_dmix_open) unable to initialize slave
aplay: main:682: Fehler beim Öffnen des Gerätes: Datenübergabe unterbrochen (broken pipe)
(Sry for german, it says something like Error while opening device: data stream interrupted)
My /etc/asound.conf looks as follows:
pcm.!default {
type hw
card 0
device 0
}
and /etc/modprobe.d/alsa-base.conf has the following entries:
# Keep snd-usb-audio from beeing loaded as first soundcard
options snd-usb-audio index=0
options snd_bcm2835 index=1
What am I doing wrong? Help would be much appreciated!
Edit:
Systemlog says the following:
Nov 7 18:30:29 raspberrypi kernel: [ 2.534311] usb 1-1: new full-speed USB device number 2 using dwc_otg
Nov 7 18:30:29 raspberrypi kernel: [ 2.546658] Indeed it is in host mode hprt0 = 00021501
Nov 7 18:30:29 raspberrypi kernel: [ 2.752653] usb 1-1: not running at top speed; connect to a high speed hub
Nov 7 18:30:29 raspberrypi kernel: [ 2.765131] usb 1-1: New USB device found, idVendor=0424, idProduct=9514
Nov 7 18:30:29 raspberrypi kernel: [ 2.776874] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber$
Nov 7 18:30:29 raspberrypi kernel: [ 2.790194] hub 1-1:1.0: USB hub found
Nov 7 18:30:29 raspberrypi kernel: [ 2.799746] hub 1-1:1.0: 5 ports detected
Nov 7 18:30:29 raspberrypi kernel: [ 3.082453] usb 1-1.1: new full-speed USB device number 3 using dwc_otg
Nov 7 18:30:29 raspberrypi kernel: [ 3.192745] usb 1-1.1: not running at top speed; connect to a high speed hub
Nov 7 18:30:29 raspberrypi kernel: [ 3.205857] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00
Nov 7 18:30:29 raspberrypi kernel: [ 3.218650] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumb$
Nov 7 18:30:29 raspberrypi kernel: [ 3.239311] smsc95xx v1.0.4
...
Nov 7 18:30:29 raspberrypi kernel: [ 3.308141] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-bcm2708_usb$
Nov 7 18:30:29 raspberrypi kernel: [ 3.432526] usb 1-1.3: new full-speed USB device number 4 using dwc_otg
Nov 7 18:30:29 raspberrypi kernel: [ 3.626813] usb 1-1.3: New USB device found, idVendor=1852, idProduct=7022
Nov 7 18:30:29 raspberrypi kernel: [ 3.647601] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumb$
Nov 7 18:30:29 raspberrypi kernel: [ 3.664695] usb 1-1.3: Product: HiFimeDIY DAC
Nov 7 18:30:29 raspberrypi kernel: [ 3.676431] usb 1-1.3: Manufacturer: HiFimeDIY Audio
Nov 7 18:30:29 raspberrypi kernel: [ 3.703597] input: HiFimeDIY Audio HiFimeDIY DAC as /devices/platform/bcm27$
Nov 7 18:30:29 raspberrypi kernel: [ 3.721606] hid-generic 0003:1852:7022.0001: input,hidraw0: USB HID v1.00 D$
Nov 7 18:30:29 raspberrypi kernel: [ 7.529882] usbcore: registered new interface driver snd-usb-audio
but as soon as the boot process is finished, I get this a jillion times in a row:
Nov 7 18:30:38 raspberrypi kernel: [ 41.221205] INFO:: schedule_periodic: Insufficient periodic bandwidth for p$
Nov 7 18:30:38 raspberrypi kernel: [ 41.221205]
Nov 7 18:30:38 raspberrypi kernel: [ 41.221261] ERROR::dwc_otg_hcd_urb_enqueue:544: DWC OTG HCD URB Enqueue fai$
Nov 7 18:30:38 raspberrypi kernel: [ 41.221261]
Nov 7 18:30:38 raspberrypi kernel: [ 41.221288] cannot submit urb 0, error -1: unknown error
Also:
Nov 7 18:45:21 raspberrypi kernel: [ 861.969647] bcm2835_audio_set_ctls:558 Controls set for stream 0
Nov 7 18:47:58 raspberrypi pulseaudio[2390]: [pulseaudio] module-always-sink.c: Unable to load module-null-sink
and
Nov 7 18:48:46 raspberrypi pulseaudio[2494]: [pulseaudio] module-udev-detect.c: Tried to configure /devices/platform/bcm2708_usb/usb1/1-1/1-1.3/1-1.3:1.1/sound/card0 (alsa_card.usb-HiFimeDIY_Audio_HiFimeDIY_DAC-01-DAC) more often than 5 times in 10 seconds
Edit 2:
Contents of /proc/asound/card0/stream0 are
HiFimeDIY Audio HiFimeDIY DAC at usb-bcm2708_usb-1.3, full speed : USB Audio
Playback:
Status: Stop
Interface 3
Altset 1
Format: S16_LE
Channels: 2
Endpoint: 3 OUT (ADAPTIVE)
Rates: 8000, 16000, 32000, 44100, 48000, 96000
Interface 3
Altset 2
Format: S24_3LE
Channels: 2
Endpoint: 3 OUT (ADAPTIVE)
Rates: 8000, 16000, 32000, 44100, 48000, 96000
Capture:
Status: Stop
Interface 2
Altset 1
Format: S16_LE
Channels: 2
Endpoint: 2 IN (ADAPTIVE)
Rates: 8000, 16000, 32000, 44100, 48000, 96000
Interface 2
Altset 2
Format: S24_3LE
Channels: 2
Endpoint: 2 IN (ADAPTIVE)
Rates: 8000, 16000, 32000, 44100, 48000, 96000
Every time I want to force sound through the USB card (below I set it to be the default audio device in .asoundrc)I get
pi#raspberrypi ~ $ aplay piano2.wav
Wiedergabe: WAVE 'piano2.wav' : Signed 16 bit Little Endian, Rate: 48000 Hz, stereo
aplay: set_params:1145: Fehler beim Setzen der Hardware-Parameter:
ACCESS: RW_INTERLEAVED
FORMAT: S16_LE
SUBFORMAT: STD
SAMPLE_BITS: 16
FRAME_BITS: 32
CHANNELS: 2
RATE: 48000
PERIOD_TIME: 125000
PERIOD_SIZE: 6000
PERIOD_BYTES: 24000
PERIODS: 4
BUFFER_TIME: 500000
BUFFER_SIZE: 24000
BUFFER_BYTES: 96000
TICK_TIME: 0
(the german part says "aplay: set_params:1145: unable to install hw params:).
Additionally, aplay -L still gives me
Karte 0: DAC [HiFimeDIY DAC], Gerät 0: USB Audio [USB Audio]
Sub-Geräte: 1/1
Sub-Gerät #0: subdevice #0
Karte 0: DAC [HiFimeDIY DAC], Gerät 1: USB Audio [USB Audio #1]
Sub-Geräte: 1/1
Sub-Gerät #0: subdevice #0
and when I use aplay -D hw:0,1 sound.wav, playback seems to work (no error message is thrown out), but I can't hear anything at all. Is Card 0,1 the recording device? If I use onboard sound, everything works fine. I'm not using a usb hub (DAC is plugged directly into the pi). Might this be a power issue?
lsusb has
pi#raspberrypi ~ $ lsusb
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 1852:7022 GYROCOM C&C Co., LTD
At the moment, a printer is plugged in (switched off though) and unplugging it changes nothing, lsusb still shows the same devices (I'm wondering why there are 4 and 3 of them different, while the Pi only has 2 ports, in one of which is the DAC). When the pi is starting up and the speakers are plugged into the DAC, I get a couple crackles, just like when they are plugged into the headphone jack.

Even i faced the similar issue.
Possible solution :
Check the kernel configs ( zcat /proc/config.gz | grep 'CONFIG_FW_LOADER' ). If that config is not enabled then try to build a kernel with this config enabled.
I tried similar approach across the different kernel for the same ROOT FILE SYSTEM, then checked for the configs i found out the above solution.
Thanks and Regards,
Sandesh K A
Let me know if this solution worked for you.

A while ago, I was experiencing the same issue. I've manage to fix it by double checking the config files. In my case, I've run alsa mixer after i've configured ~/.asoundrc. By running the alsa mixer / unplugging the usb, alsa automatically updates ~/.asoundrc file. Hence, overwritten my previous config.
Make sure that your changes in conf file are still in place before trying again. I hope this works on you as well.
Set up Raspberry Pi 3 USB mic ( creative sound blaster )

Related

How do I make a free VLM from kemp boot on a physical LoadMaster

I know this isn't the right place to ask this but this site has the most users on it. I recently bought a Kemp LoadMaster LM-2600 Load Balancer for my webservers. However, this unit didn't include an SSD because the previous owner decided to erase it. So, I downloaded the VirtualBox version of free VLM from kemp's website. Then, I used VBoxManage clonehd LMOS.vmdk LMOS.img --format RAW to turn the disk into a raw img file. Then, I used dd if=LMOS.img of=/dev/sdb to flash a USB with the os. Then, I booted my loadmaster with the USB.
The boot process went like normal until it finished booting and then the machine switched to runlevel 0 (Shutdown)
This is the logs I got when I plugged the USB into my computer (The log file was so big that stack overflow won't allow me to paste it here):
https://pastebin.com/5PbKzRi6
I noticed that it said something about eth0 being down so I plugged in an ethernet cable and booted it again. The same thing happened but I got a different error (The log was shorter so I labeled it):
-- BOOT --
2022-08-07T19:50:06+00:00 lb100 syslog-ng: syslog-ng starting up; version='3.25.1'
-- ERROR --
2022-08-07T19:50:07+00:00 lb100 raid_events_handler: RAID controller not detected yet (check # 0)
-- LOGIN --
2022-08-07T19:50:11+00:00 lb100 login: pam_unix(login:session): session opened for user bal by LOGIN(uid=0)
-- ERROR --
2022-08-07T19:50:14+00:00 lb100 raid_events_handler: RAID controller not detected yet (check # 1)
-- SHUTDOWN --
2022-08-07T19:50:15+00:00 lb100 init: Switching to runlevel: 0
2022-08-07T19:50:15+00:00 lb100 kernel: S99final (938): drop_caches: 1
2022-08-07T19:50:17+00:00 lb100 syslog-ng: syslog-ng shutting down; version='3.25.1'
2022-08-07T19:50:17+00:00 lb100 kernel: Kernel logging (proc) stopped.
2022-08-07T19:50:17+00:00 lb100 kernel: Kernel log daemon terminating.
2022-08-07T19:50:17+00:00 lb100 sslproxy: (815) caught signal 15
2022-08-07T19:50:17+00:00 lb100 raid_events_handler: stop
I have no idea what to do right now. I already tried everything I knew. What should I do?
Any help would be great,
Thanks!

Raspberry Pi 4B does not detect USB storage devices

I tried plugging two flash drives into a Raspberry Pi 4B one after another but the Pi does not seem to detect any of the drives. Here is the dmesg output
[ 177.737328] cpu cpu0: dev_pm_opp_set_rate: failed to find current OPP for freq 4294967186 (-34)
[ 180.446246] raspberrypi-clk soc:firmware:clocks: Failed to change fw-clk-arm frequency: -110
[ 181.036364] xhci_hcd 0000:01:00.0: Abort failed to stop command ring: -110
[ 181.052412] xhci_hcd 0000:01:00.0: Host halt failed, -110
[ 181.052421] xhci_hcd 0000:01:00.0: xHCI host controller not responding, assume dead
[ 181.052446] xhci_hcd 0000:01:00.0: HC died; cleaning up [ 181.052645] xhci_hcd 0000:01:00.0: Timeout while waiting for setup device command
[ 181.053349] usb 1-1: USB disconnect, device number 2
[ 181.536432] usb 1-1.3: device not accepting address 5, error -108
[ 181.536608] usb 1-1-port3: couldn't allocate usb_device
Any help is appreciated. Thanks in advance
USB problems in RPi typically happens because of a corrupted kernel, try to update it then give me a feedback.

Raspberry Pi Zero as read write mass storage

I am trying to setup a Raspberry Pi Zero as a mass storage with dwc2 and g_mass_storage (using the last Raspbian image available).
I created the data storage file with dd, made it a FAT32 fs with mkdosfs.
I looked for a lot of things. I spent some time to understand that options should be passed in /etc/modprobe.d/g_mass_storage.conf
It is finally seen in ubuntu. My problem is : it is in read only mode.
I tried to set the ro option to y or n without any impact on the behaviour. I changed permissions on the file (777), it changed nothing.
here is the current content of my /etc/modprobe.d/g_mass_storage.conf file :
options g_mass_storage file=/piusb.bin stall=0 removable=y ro=n
here is the of dmesg from the ubuntu :
[Today and now]usb 1-1.2: new high-speed USB device number 28 using ehci-pci
[ +0,299994] usb 1-1.2: device descriptor read/64, error -71
[ +0,959969] usb 1-1.2: device descriptor read/64, error -71
[ +0,187918] usb 1-1.2: new high-speed USB device number 29 using ehci-pci
[ +0,113925] usb 1-1.2: New USB device found, idVendor=0525, idProduct=a4a5
[ +0,000007] usb 1-1.2: New USB device strings: Mfr=3, Product=4, SerialNumber=0
[ +0,000004] usb 1-1.2: Product: Mass Storage Gadget
[ +0,000003] usb 1-1.2: Manufacturer: Linux 4.19.118+ with 20980000.usb
[ +0,001467] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[ +0,000246] usb-storage 1-1.2:1.0: Quirks match for vid 0525 pid a4a5: 10000
[ +0,000283] scsi host9: usb-storage 1-1.2:1.0
[ +1,009528] scsi 9:0:0:0: Direct-Access Linux File-Stor Gadget 0419 PQ: 0 ANSI: 2
[ +0,001079] sd 9:0:0:0: Attached scsi generic sg5 type 0
[ +0,001699] sd 9:0:0:0: Power-on or device reset occurred
[ +0,001211] sd 9:0:0:0: [sde] 67108864 512-byte logical blocks: (34.4 GB/32.0 GiB)
[ +0,000672] sd 9:0:0:0: [sde] Write Protect is on
[ +0,000016] sd 9:0:0:0: [sde] Mode Sense: 0f 00 80 00
[ +0,000740] sd 9:0:0:0: [sde] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ +0,005478] sde:
[ +0,002735] sd 9:0:0:0: [sde] Attached SCSI removable disk
What to do to get a read/write mass storage ?
I reproduced your problem. I had a similar problem with the module g_acm_ms on Raspberry Pi Zero W. If you configure the module in /etc/modprobe.d/, then the system ignores the parameter ro=0. Perhaps this is due to the order of initialization of kernel modules. I got around this by adding the module to the blacklist and writing the initialization in /etc/rc.local. Thus, I managed to get an emulation of a read/write mass storage.
All steps:
Create and format the file:
# dd bs=1M if=/dev/zero of="/piusb.bin" count=2048
# mkdosfs "/piusb.bin"
Add modules-load=dwc2,g_acm_ms to end of /boot/cmdline.txt (after rootwait)
Add the string dtoverlay=dwc2 in /boot/config.txt
Prevent module initialization at startup:
$ echo "blacklist g_acm_ms" | sudo tee -a "/etc/modprobe.d/blacklist-g_acm_ms.conf"
Add initialization in /etc/rc.local above exit 0:
# nano /etc/rc.local
Add string:
/sbin/modprobe file=/piusb.bin removable=y ro=0 stall=0
Reboot system:
# reboot -h
P.S.: If you don't want to use USB for console output, you can use g_mass_storage instead of g_acm_ms.

ERROR: configuring avrdude for ATmega328P-XMINI (i think the evildoer is)->(avrdude: usbdev_send(): wrote -5 out of 7 bytes, err = Input/output error)

I have an ATmega328P-XMINI microchip (googling gave me a result that its an 8 bit chip).
Im new to embedded programming. And need some help getting on my way. For now im just trying to establish a connection with avrdude (im just trying to get a healthy connection loading code to the chip comes later). But i get this error. I dont know how to fix this or what is going wrong.
What i do know is that there is an usbdev input output error what i think is the culprit.
The other line exclaiming that the usb device is busy is also suspicous.
DISCLAIMER: I use gentoo and cause of this have no access to atmel studio (I have no access to windows programs).
command issued (tried with and without sudo):
sudo avrdude -p m328p -c xplainedmini
Error code:
avrdude: usb_open(): cannot read serial number "Connection timed out"
avrdude: usb_open(): cannot read product name "Connection timed out"
avrdude: usbdev_open(): WARNING: failed to set configuration 1: Device or resource busy
avrdude: usbdev_send(): wrote -5 out of 7 bytes, err = Input/output error
avrdude: jtag3_send(): failed to send command to serial port
avrdude: failed to sync with the JTAGICE3 in ISP mode
Dmesg after connecting:
[ 7704.920695] usb 2-2: new full-speed USB device number 6 using xhci_hcd
[ 7705.048875] usb 2-2: New USB device found, idVendor=03eb, idProduct=2145, bcdDevice=10.00
[ 7705.048877] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 7705.048878] usb 2-2: Product: mEDBG CMSIS-DAP
[ 7705.048880] usb 2-2: Manufacturer: ATMEL
[ 7705.048881] usb 2-2: SerialNumber: ATML2323051800004280
[ 7705.051076] hid-generic 0003:03EB:2145.0003: hiddev97,hidraw1: USB HID v1.11 Device [ATMEL mEDBG CMSIS-DAP] on usb-0000:00:14.0-2/input0
[ 7705.051145] cdc_acm 2-2:1.1: ttyACM0: USB ACM device
microchip documentation and product page
Any tips for debugging this problem in general im thankfull for.
Never mind i spent 20 minutes formulating the question and formatting it. Just to realize that plugging it out and in fixed it.
IM AN IDIOT!

Automount USB flash drive on Raspbian Stretch lite with udev

I'm using a udev rule to automount USB flash drives on my Raspberry Pi. I found this solution few months ago and I worked very well until I start using Raspbian Stretch lite.
KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"
# Import FS infos
IMPORT{program}="/sbin/blkid -o udev -p %N"
# Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"
# Global mount options
ACTION=="add", ENV{mount_options}="relatime"
# Filesystem-specific mount options
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="\$env{mount_options},utf8,gid=100,umask=002"
# Mount the device
ACTION=="add", RUN+="/bin/mkdir -p /media/usbstick", RUN+="/bin/mount -o \$env{mount_options} /dev/%k /media/usbstick"
# Clean up after removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/usbstick", RUN+="/bin/rmdir /media/usbstick"
# Exit
LABEL="media_by_label_auto_mount_end"
And here is what I see in dmesg
[ 524.042731] usb 1-1.4: new high-speed USB device number 6 using dwc_otg
[ 524.174634] usb 1-1.4: New USB device found, idVendor=090c, idProduct=1000
[ 524.174649] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 524.174658] usb 1-1.4: Product: Flash Disk
[ 524.174666] usb 1-1.4: Manufacturer: USB
[ 524.174674] usb 1-1.4: SerialNumber: SCY0000000105542
[ 524.175515] usb-storage 1-1.4:1.0: USB Mass Storage device detected
[ 524.175994] scsi host0: usb-storage 1-1.4:1.0
[ 525.399056] scsi 0:0:0:0: Direct-Access USB Flash Disk 1100 PQ: 0 ANSI: 4
[ 525.399986] sd 0:0:0:0: Attached scsi generic sg0 type 0
[ 525.400243] sd 0:0:0:0: [sda] 15974400 512-byte logical blocks: (8.18 GB/7.62 GiB)
[ 525.401232] sd 0:0:0:0: [sda] Write Protect is off
[ 525.401259] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
[ 525.401948] sd 0:0:0:0: [sda] No Caching mode page found
[ 525.401965] sd 0:0:0:0: [sda] Assuming drive cache: write through
[ 525.415578] sda: sda1
[ 525.418642] sd 0:0:0:0: [sda] Attached SCSI removable disk
Do anybody has a similar solution that works with Raspbian Stretch lite?