User Tools

Site Tools


doc:appunti:hardware:qnap_ts-120

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
doc:appunti:hardware:qnap_ts-120 [2022/02/12 08:06] – [The Serial Console] niccolodoc:appunti:hardware:qnap_ts-120 [2025/01/10 11:15] (current) – [USB audio dongle] niccolo
Line 252: Line 252:
  
 Now try to reboot. If the problem is fixed, you may remove the file **/etc/initramfs-tools/conf.d/root** and run **update-initramfs** again: now the proper rootfs will be autodetected. Now try to reboot. If the problem is fixed, you may remove the file **/etc/initramfs-tools/conf.d/root** and run **update-initramfs** again: now the proper rootfs will be autodetected.
 +
 +===== USB audio dongle =====
 +
 +I use the QNAP also as a **media player** because it stores all my audio files. I attached it to my HiFi amplifier through an **USB audio dongle** and an **audio cable** (3.5 mm jack - RCA stereo plugs).
 +
 +I faced a problem with that audio USB interface, because at every reboot the device is not working and it does not show in **lsusb** output. The manual workaround was to unplup and re-plug the device into the USB port.
 +
 +Fortunately it is possibile to force the re-initialization of the USB controller with the following script:
 +
 +<code bash>
 +#!/bin/sh
 +# If the USB audio device is missing, try to reset the USB controller.
 +# USB 2.0 devices may be under /sys/bus/pci/drivers/ehci_hcd instead.
 +PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
 +lsusb | grep -q 'JMTek, LLC. audio controller'
 +RET=$?
 +if [ "$RET" -ne "0" ]; then
 +    echo "USB audio device missing, trying to reset the bus."
 +    cd /sys/bus/pci/drivers/xhci_hcd
 +    echo -n "0000:02:00.0" > unbind
 +    sleep 1
 +    echo -n "0000:02:00.0" > bind
 +fi
 +</code>
 +
 +So I created a systemd service to be run when the host reaches the multi-user target. Create the file **/etc/systemd/system/usb-audio-dongle-reset.service**:
 +
 +<file>
 +# /etc/systemd/system/usb-audio-dongle-reset.service
 +#
 +# Service executed once the system has reached the multi-user status.
 +#
 +#  Type=oneshot         The unit is up after the main process exits.
 +#  RemainAfterExit=yes  The service shall be considered active even
 +#                       when all its processes exited.
 +#
 +# Eanble the service with:
 +#   systemctl enable my-startup.service
 +
 +[Service]
 +Type=oneshot
 +RemainAfterExit=yes
 +ExecStart=/usr/local/sbin/usb-audio-dongle-reset
 +
 +[Install]
 +WantedBy=multi-user.target
 +</file>
 +
 +Enable and start the service with:
 +
 +<code>
 +systemctl --now enable usb-audio-dongle-reset.service
 +</code>
  
doc/appunti/hardware/qnap_ts-120.1644649614.txt.gz · Last modified: 2022/02/12 08:06 by niccolo