UPDATE: It turned out my hardware was faulty and the seller replaced it. The method I described most likely won’t help you 😔. I still loved the journey and will keep the post here.
If you are only here for the resolution, click here to scroll there.
I have a Bose Lifestyle 28 Series III home theatre system. It is pre-2008, so more than 15 years old. Honestly, I can’t remember how often I heard it in the 5.1 setup. Back in the day, I didn’t care; later, I didn’t have a compatible system. A large part of not using it was laziness. In recent years, I committed to finally setting it up with my media center (a rPi4 running Kodi and LibreElec without an SD card using network boot). This is the story of a short debugging session and some lessons.
The setup
My sound system doesn’t have HDMI; there are two ways to get 5.1 input. Via optical cable (toslink) or a digital RCA. rPi4 lacks both of these options. My Samsung TV comes to the rescue; it has an optical output and HDMI input (it’s only ~10 years old). The plan was great. rPi4 outputs HDMI with Dolby Digital or DTS; the TV decodes/passes through the sound via the optical output to my Bose system.
The above setup doesn’t work. My TV downgrades the beautifully sounding Dolby Digital 5.1 to a 2-channel PCM. I spent a few hours debugging the TV to get this working. These few hours of debugging were spread over 3 years, to be honest 😅. I gave up multiple times. My results ranged from no sound to a re-encoded 2.0 DTS that missed the center channel (movies without voice). 🫤
The light
And then, I found tinyToslink.
After reading the description, this is too good to be true.
- …Optical Audio Output for Raspberry Pi (1A+/1B+/2B/3B/3B+/4B/Zero)…
- …Most TVs can’t forward Dolby Digital/DTS 5.1 streams from HDMI to the optical output…
- …So I wanted an optical output for my Raspberry Pi media center (OpenElec/LibreElec) to get the 5.1 streams directly to my 5.1 surround system…
I ordered one immediately. It took a while, but I finally had it in my hands.
And that’s where the fun began.
The journey
The setup was a piece of cake. Plug it in on the board, add dtoverlay=hifiberry-digi
to config.txt
, and reboot.
Alright, rPi4 booted … and … no sound card was detected, only the old card over HDMI. As I said, too good to be true.
Sound card isn’t recognized
Let’s start digging. First, check out the recognized sound cards using ALSA:
quartz:~ # aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: vc4hdmi0 [vc4-hdmi-0], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: vc4hdmi1 [vc4-hdmi-1], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
Okay, it’s definitely missing. Did the overlay load correctly?
quartz:~ # dtoverlay -l
No overlays loaded
After reading a bit, it seems this command only lists overlays loaded at runtime. Let’s check the boot log.
quartz:~ # vcdbg log msg
...
011385.183: brfs: File read: 3913 bytes
011398.732: brfs: File read: /MFS/sd/overlays/hifiberry-digi.dtbo
011436.065: Loaded overlay 'hifiberry-digi'
011514.910: brfs: File read: 959 bytes
...
Hm, yes, it did. Back to the web again. It seems like setting another config parameter might help: force_eeprom_read=0
And voila, after reboot, it worked. This was a bit strange as tinyToslink is not a HifiBerry board, so the EEPROM correction wasn’t guaranteed to work, but it did. At least, it seemed that way until the next reboot. After the restart, there was no sound card again. I also disabled the built-in card. That didn’t change anything.
This option had nothing to do with the card working. I only got lucky, but I didn’t know this back then.
This is probably the end of many debugging sessions, as one might feel there isn’t anything else to do or try. It would have been the same for me had I not found this thread about a rPi4 not recognizing a HifiBerry board. It is a fascinating thread, that shows how much length people are willing to go to uncover an issue. It took ~6 months in this case. After reading through the posts, I found these lines interesting.
...
[ 7.536831] wm8804 1-003b: Failed to read device ID: -121
[ 7.537110] wm8804: probe of 1-003b failed with error -121
...
This is in the output of dmesg
. The wm8804 is also the chip used on tinyToslink. I wasn’t alone. The HifiBerry team obtained the hardware and ran their analysis on it. Kudos to them. The root cause was unclean voltage rampup upon boot.
Here is their claim:
The good news: We could reproduce the problem and identify the root cause. The bad news: There is no simply software-based fix. The new Pi release uses a new power management circuit that doesn’t ramp up the voltages as clean as all previous versions.
I don’t know why they claim no software fix, as it seems trivial. Load the overlay after boot when the voltage is already up.
The solution
Here is a quick test after a clean boot.
##############################################
# LibreELEC #
# https://libreelec.tv #
##############################################
LibreELEC (official): 11.0.1 (RPi4.arm)
quartz:~ # aplay -l
aplay: device_list:274: no soundcards found...
quartz:~ # dtoverlay -l
No overlays loaded
quartz:~ # dtoverlay hifiberry-digi
quartz:~ # dtoverlay -l
Overlays (in load order):
0: hifiberry-digi
quartz:~ # aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_digi], device 0: HifiBerry Digi HiFi wm8804-spdif-0 [HifiBerry Digi HiFi wm8804-spdif-0]
Subdevices: 0/1
Subdevice #0: subdevice #0
Of course, I removed loading this overlay from config.txt
.
This brings us to the end of this journey. You could write a one-shot service that does this after boot. I don’t reboot often; running this command every time is okay.
Closing
It is fascinating how some people disassemble problems to reach their root causes. I am truly grateful for sharing your journey if you are such a person. With this post, I am aspiring to do the same.
Updates
2023-10-31 – Sadly, I am back to square one. The solution proposed above does not seem to work reliably. In fact, the sound card disappeared some time ago and I could not get it back since. I’ll try other rPi’s and narrow down the cause of the flakiness.
2023-11-15 – I contacted Benjamin, the seller and he sent me a new one. It worked out-of-the box. I sent him back the broken one so he can take a look. I’ll update the post if that happens.
Leave a Reply