Raspberry Pi 2/3: How to use config.txt

I’ll admit this is my first post, even though I’ve been using Fedora for over a decade. I’ve come to my first challenge I can’t fix by myself…

I’m trying the armhf image for the first time on my RPi2 and RPi3 units. I’ve got the installation completed easily, it’s updated and displaying nicely on my very picky 8.8" super-wide TFT. However, now I need to try and get a HAT working and I need to add a device tree overlay.

I’ve run the following steps with no success:

rm /boot/dtb
echo "DTFirmware=True" > /etc/u-boot.conf

After this, the system seems to be loading the firmware device tree, as the following line appears in the kernel output during boot:
[ 0.000000] OF: fdt: Machine model: Raspberry Pi 2 Model B

So I then added the following into /boot/efi/config.txt

dtparams=audio=off
dtoverlay=hifiberry-dac

I know the DAC support is experimental/supported (depending on which pages you look at), but I can’t see any attempt to use it in dmesg and the built-in sound devices are still active:

$ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
default
    Default Audio Device
sysdefault
    Default Audio Device
iec958
    IEC958 (S/PDIF) Digital Audio Output
default:CARD=vc4hdmi
    vc4-hdmi, MAI PCM vc4-hdmi-hifi-0
    Default Audio Device
sysdefault:CARD=vc4hdmi
    vc4-hdmi, MAI PCM vc4-hdmi-hifi-0
    Default Audio Device
front:CARD=vc4hdmi,DEV=0
    vc4-hdmi, MAI PCM vc4-hdmi-hifi-0
    Front output / input
iec958:CARD=vc4hdmi,DEV=0
    vc4-hdmi, MAI PCM vc4-hdmi-hifi-0
    IEC958 (S/PDIF) Digital Audio Output
default:CARD=ALSA
    bcm2835 ALSA, bcm2835 ALSA
    Default Audio Device
sysdefault:CARD=ALSA
    bcm2835 ALSA, bcm2835 ALSA
    Default Audio Device

It’s possible that Fedora doesn’t (yet?) use the dtparams= configuration options. Documentation is a little light on this part. Although functionality is untested for most HATs, it appears that the dtoverlay= options are supported: HATs and I can see the dtb files in /boot/dtb-5.10.15-200.fc33.armv7hl and the dtbo files in /boot/efi/overlays

Any pointers? Thanks!

Welcome to the forum :slightly_smiling_face:

I admit avoiding dtoverlays for now since it opens up a gigantic can of worms regarding troubelshooting and using a non-raspi kernel a lot of things work just as well using kernel-modules the way it used to do.

just out of curiosity did you try the HiFiBerry software configuration before entering the void of firmware overlays?

It looks pretty old-fashioned to me and for instance dtparams=audio=off has the same effect as blacklist snd_bcm2835.

Edit:

…or in your case it doesn’t…

It is written for an old kernel and could need some adaptation. Also I didn’t check if all the modules are available, but you might wan’t to give it a try.

Thanks for the advice.

I’ve tried it, it seems that when I blacklist snd_bcm2835, ac97 is jumping in instead:

$ lsmod|grep snd
snd_soc_core          241664  1 vc4
ac97_bus               16384  1 snd_soc_core
snd_pcm_dmaengine      16384  1 snd_soc_core
snd_pcm               102400  3 vc4,snd_pcm_dmaengine,snd_soc_core
snd_timer              36864  1 snd_pcm
snd                    73728  5 snd_timer,snd_soc_core,snd_pcm
soundcore              16384  1 snd
$ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
sysdefault
    Default Audio Device
iec958
    IEC958 (S/PDIF) Digital Audio Output
sysdefault:CARD=vc4hdmi
    vc4-hdmi, MAI PCM vc4-hdmi-hifi-0
    Default Audio Device
front:CARD=vc4hdmi,DEV=0
    vc4-hdmi, MAI PCM vc4-hdmi-hifi-0
    Front output / input
iec958:CARD=vc4hdmi,DEV=0
    vc4-hdmi, MAI PCM vc4-hdmi-hifi-0
    IEC958 (S/PDIF) Digital Audio Output

…and no luck from the DAC. On closer inspection, several kernel modules are missing:

  • bcm2708_dmaengine
  • snd_soc_bcm2708
  • snd_soc_hifiberry_dacplus
  • i2c-bcm2708

Are all missing. While F33 has i2c-bcm2835, it’s not clear that the hifiberry-dacplus module will use it; even if it does, the dacplus module isn’t present anyway. A quick hunt has turned up nothing in the Fedora repos for any of them either.

A

According to here technically 2708 is the family, and 2835 is a specific implementation.

So it comes down to snd_soc_hifiberry_dacplus.

According to here the vendor never mainlined its driver(s) it seems, so the driver is only available in the Raspberry Pi kernel tree…
So you could try to port the drivers or use the original raspi kernel :frowning:

RPMFusion maintains a rpi repo including userspace and kernels, but I never used it since the packages I tested were not signed. …which might be perfectly ok…

Edit:

The packages provided by RPM Fusion (case/space sensitive btw :wink: are signed including the rpmfusion-rpi repository. (that are signed by the rpmfusion-free-2020 GPG key).

Well, what can I say …

 Package                          Architecture        Version                                Repository                 Size
=============================================================================================================================
Installieren:
 raspberrypi-vc-libs              aarch64             20201130-1.git093b30b.fc33             rpmfusion-rpi             106 k
 raspberrypi-vc-utils             aarch64             20201130-1.git093b30b.fc33             rpmfusion-rpi              75 k

Transaktionsübersicht
=============================================================================================================================
Installieren  2 Pakete

Pakete werden heruntergeladen:
(1/2): raspberrypi-vc-utils-20201130-1.git093b30b.fc33.aarch64.rpm                           416 kB/s |  75 kB     00:00    
(2/2): raspberrypi-vc-libs-20201130-1.git093b30b.fc33.aarch64.rpm                            535 kB/s | 106 kB     00:00    
-----------------------------------------------------------------------------------------------------------------------------
Gesamt                                                                                        93 kB/s | 182 kB     00:01     
Paket raspberrypi-vc-libs-20201130-1.git093b30b.fc33.aarch64.rpm ist nicht signiert
Paket raspberrypi-vc-utils-20201130-1.git093b30b.fc33.aarch64.rpm ist nicht signiert
Die heruntergeladenen Pakete wurden bis zur nächsten erfolgreichen Transaktion im Zwischenspeicher abgelegt.
Sie können zwischengespeicherte Pakete mit dem Befehl »dnf clean packages« entfernen.
Fehler: GPG-Überprüfung fehlgeschlagen

Might be I am missing something appart from the whitespace :wink: I didn’t bother investigating since I’m used to compiling the userland anyway…

And of course I’m using RPM Fusion for years now - apart from the rpi repo, and don’t recal ever getting this kind of error. Althou the key is installed.

-rw-r--r--.  1 root root  1704 16. Okt 10:52 RPM-GPG-KEY-rpmfusion-free-fedora-2020

Thanks for the report.

I’ve found what was the issue, the packages are signed internally. It should be fixed on the next push in a day or two…

1 Like

I tried the raspberrrypi kernel and all sorts of strange things happened - including my wifi not connecting, a complaint about missing secrets and it was hanging on boot (even after I manually copied over the missing realtek firmware from another machine). I checked the image was written correctly and still no luck.

Back to the mainline kernel:
I tried configuring what seemed to be a generic i2s dac driver by adding the following into /etc/modules-load.d/audio.conf:

snd-soc-bcm2835
snd-soc-bcm2835-i2s
bcm2835-dma
snd-soc-pcm512x-i2c
snd-soc-pcm512x

…but still no luck.

I’d love to port the hifiberry driver but while I have some reasonable skills in many languages, C is not one I’m strong on and kernel development is way outside of my comfort zone :frowning:

Realistically, I don’t need the exact hifiberry-dac driver - almost any i2s DAC driver will work, but there don’t seem to be any in the mainline kernel at all, so perhaps I’m out of luck for now.

The drivers can be found in the raspberrypi linux tree and the relevant part of Kconfig seems to be

config SND_BCM2708_SOC_HIFIBERRY_DACPLUS
        tristate "Support for HifiBerry DAC+"
        depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
        select SND_SOC_PCM512x
        select SND_SOC_TPA6130A2
        select COMMON_CLK_HIFIBERRY_DACPRO
        help
         Say Y or M if you want to add support for HifiBerry DAC+.

You could copy the files needed to the fedora tree, add the relevant part to the Kconfig and give it a try :wink:

git clone --depth 1 --branch kernel-5.10.15-200.fc33 git://git.kernel.org/pub/scm/linux/kernel/git/jwboyer/fedora.git fedora_tree

cd fedora_tree

cp /boot/config-5.10.15-200.fc33.armv7hl .config

...add / edit files...

make oldconfig

make menuconfig

make -j3 zImage modules

All you can loose is some time…

Edit:
Of course this may or may not work and you’re trying this at your own risk :grin: Maybe someone with a litte more experience in kernel hacking is willing to help out. I’m pretty much done at this point…

Thanks, that was very helpful. After hours of compiling the kernel, I found a shorter way, of course, but now I have hifiberry_dacplus.ko built and inserted… and still nothing.

It seems that the vc4 driver is now hogging ALSA and it seems the only way to disable it is with an overlay (Is it possible to disable VC4 sound? · Issue #2489 · raspberrypi/linux · GitHub).

Now that I have a loadable kernel module I feel like I’m getting closer but I’m back to square one as I need to be able to load the overlays - something that doesn’t seem to work in F33. I’ve rm’d /boot/dtb and inserted the FirmwareDT=True text into /etc/u-boot.conf and from what I can tell /boot/efi/config.txt is still being ignored - it seems that the kernel is still loading it’s native device tree.

In case you’re wondering about the “short” version of building the kernel module:
You’ll need a few packages before you begin.

sudo dnf install kernel-devel gcc g++ make git alsa-utils alsa-lib fedpkg fedora-packager rpmdevtools ncurses-devel pesign grubby flex bison elfutils-libelf-devel elfutils-lubelf

Make sure you’ve downloaded the appropriate c file for the module you want from the raspberrypi tree. I’m using hifiberry_dacplus.c and I’ve put it in /home/<name>/hifiberry_dacplus.c. Copying the config isn’t strictly required, but if you do decide to build your own kernel it’s nice to have it ready :slight_smile:

git clone --depth 1 --branch kernel-5.10.15-200.fc33 git://git.kernel.org/pub/scm/linux/kernel/git/jwboyer/fedora.git fedora_tree
cd fedora_tree
cp /boot/config-5.10.15-200.fc33.armv7hl .config
cd sound/soc/bcm/
cp /home/<name>/hifiberry_dacplus.c .

Now create a Makefile with this content, replacing [TAB] with an actual tab key press:

obj-m := hifiberry_dacplus.o

KDIR  := /lib/modules/$(shell uname -r)/build
PWD   := $(shell pwd)

default:
[TAB]$(MAKE) -C $(KDIR) M=$(PWD) modules

Finally,

make -C /lib/modules/`uname -r`/build M=`pwd` modules
sudo make -C /lib/modules/`uname -r`/build M=`pwd` modules_install
sudo modprobe hifiberry_dacplus
lsmod

This will build and install only hifiberry_dacplus.ko rather than the entire kernel/modules.

1 Like

Kudos on that :grin:
To get fedora running on my ASUS Tinker board, I have to apply 3 tiney patches and recompile the kernel every time. So I just copied the relevant part of my scripts to get you started :wink:

just for testing you can try blacklisting vc4. You will be set back to the fb driver and loose hwaccel, but at least for testing this should be ok. I have to do this on my pi4 since vc4_hdmi seems to be broken, at least for the pi4.
Remember to blacklist snd_bcm2835 too, to turn off the firmware audio driver.