Progress!
The Hifiberry DAC2 Pro comes as well with RCA as with a headphone jack. Up until now I was using the headphone jack which was not producing sound when using Balena, but is producing sound in HifiberryOS.
I now discovered when using dtoverlay “hifiberry-dacplushd” and connecting the RCA instead of the headphone jack, I do have sound. Therefore, the issue is merely from the headphone jack not being enabled. I can also see that in HifiberryOS that it explicitly enables the headphone jack amp:
From HifiberryOS:
# dmesg | grep snd
[ 0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=0
snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 video=Composite- 1:720x480@60i vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000
root=/dev/mmcblk0p2 rootwait console=tty5 systemd.show_status=0 quiet splash
[ 5.530855] snd-rpi-hifiberry-dacplus soc:sound: activating headphone amplifier
[ 5.531356] snd-rpi-hifiberry-dacplus soc:sound: ASoC: failed to init link HiFiBerry DAC+: -517
[ 5.545522] snd-rpi-hifiberry-dacplus soc:sound: ASoC: failed to init link HiFiBerry DAC+: -517
[ 5.837975] snd-rpi-hifiberry-dacplus soc:sound: ASoC: failed to init link HiFiBerry DAC+: -517
[ 5.867232] snd-rpi-hifiberry-dacplus soc:sound: ASoC: failed to init link HiFiBerry DAC+: -517
[ 6.128636] snd-rpi-hifiberry-dacplus soc:sound: ASoC: failed to init link HiFiBerry DAC+: -517
[ 6.148128] snd-rpi-hifiberry-dacplus soc:sound: ASoC: failed to init link HiFiBerry DAC+: -517
[ 6.187143] snd-rpi-hifiberry-dacplus soc:sound: ASoC: failed to init link HiFiBerry DAC+: -517
[ 6.215708] snd-rpi-hifiberry-dacplus soc:sound: ASoC: failed to init link HiFiBerry DAC+: -517
[ 6.459587] snd-rpi-hifiberry-dacplus soc:sound: pcm512x-hifi <-> 3f203000.i2s mapping ok
Key is in the line:
activating headphone amplifier
I switched to RCA so for me this is solved, but it might be good to know for others.
Kind regards!