Troubleshooting pops and clicks with usb DACS

 Note: This fix is not needed anymore by default! Try it only if you get weird sound behavior with your USB Dac!

Many of you who have some experience with the Raspberry Pi, you have already noticed that with many usb dacs there are noticeable problems in music reproduction. Some of you experience the problems in high resolution files and some of you experience it with all files.

The situation at the moment is by far better comparing with some months ago. The new usb driver is not beta anymore and with many dacs music reproduction will be perfect without you needing to do anyhting

However you may use the two fixes below if you notice any pops and clicks.

 

Unbind the usb dac from usbhid (you will have to apply it only if you notice any problem in music reproduction)

The first step is to find the id of your usb dac. For this step you will use dmesg or dmesg |grep USB. You are looking for a line similar to:

[ 3.659293] input: HiFimeDIY Audio SA9023 USB Audio as /devices/platform/bcm2708_usb/usb1/1-1/1-1.3/1-1.3:1.0/input/input0

the only thing we need from this line is

1-1.3:1.0 (your number may be different!!)

The command you will need to apply this fix is:

echo -n “1-1.3:1.0” > /sys/bus/usb/drivers/usbhid/unbind

 

In order to make this permanent, you need to edit the following file

/usr/bin/archphile-optimize

The file should be like the one below:

#!/bin/bash

# this command is used in order to unmute dac and set the volume to 100% during boot
#
/usr/bin/unmute

#!/bin/bash
# this command is used in order to unmute dac and set the volume to 100% during boot
#
/usr/bin/unmute

# please replace x with the id of your device
# for further information visit http://archphile.org/howto/troubleshooting-pops-and-clicks
#echo -n “x-x.x:x.x” > /sys/bus/usb/drivers/usbhid/unbind

# this command sets noop scheduler during boot
echo noop > /sys/block/mmcblk0/queue/scheduler

# enable the command below in order to set swappiness to 0
#echo 0 > /proc/sys/vm/swappiness

# commands to change various kernel parameters (Based on Runeaudio default RPI profile)
#echo 1500000 > /proc/sys/kernel/sched_latency_ns
#echo 1000000 > /proc/sys/kernel/sched_rt_period_us
#echo 950000 > /proc/sys/kernel/sched_rt_runtime_us
#echo 1 > /proc/sys/kernel/sched_autogroup_enabled
#echo 10 > /proc/sys/kernel/sched_rr_timeslice_ms
#echo 750000 > /proc/sys/kernel/sched_min_granularity_ns
#echo 1000000 > /proc/sys/kernel/sched_wakeup_granularity_ns

# wireless connection tweaks
#iwconfig wlan0 power off
#iwconfig wlan0 frag 2346
#iwconfig wlan0 rts 2347
#iw reg set GR

# local cover art support
#
# uncomment below if you use Mpdroid. The path to music is http://xxx.xxx.xxx.xxx:8080/music/
#mongoose -listening_port 8080 -document_root /var/www/covers
#
# uncomment below if you use Mpod or Mpad. Please change the cover server address to http://xxx.xxx.xxx.xxx:8080
#mongoose -listening_port 8080 -document_root /var/www/Music

 

The section of you interest is:

# please replace x with the id of your device

# for further information visit http://archphile.org/howto/troubleshooting-pops-and-clicks
#echo -n “x-x.x:x.x” > /sys/bus/usb/drivers/usbhid/unbind

According to the example given above, these lines should change to:

# please replace x with the id of your device

# for further information visit http://archphile.org/howto/troubleshooting-pops-and-clicks
echo -n “1-1.3:1.0” > /sys/bus/usb/drivers/usbhid/unbind

The command above will always be executed  during boot.

This fix was suggested by the developer of the new USB driver and in many cases it solves the issues with the “FIQ Reported NYET” errors.  At the moment (version 0.99 Beta) the usb driver included in the kernel used  has very much improved. This fix is not mandatory. Although it was one of the first steps I did in every installations, I don’t need it any more with my two dacs. Please try this only if you experience issues with pops and clicks.