2-in, 8-out DSP platform using the Raspberry Pi + HATs

SUCCESS!

speaker-test -c8 -t wave -D hw:0,0,0
gives me output on all 8 channels exactly as shown on the vendor site.

lsmod shows a whole bunch of drivers with bcm2835 in the name, and the sound one is one of them (even though it controls the bcm2711 chip!) so we are still modifying the correct file. But the trick is, it's necessary to modify the 1st struct (without spdif in the name). Here is a diff showing my changes:

Code:
pi@raspberrypi:~/kernel-dev/linux $ git diff
diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
index e4603ba74..cae639133 100644
--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
@@ -18,10 +18,10 @@ static const struct snd_pcm_hardware snd_bcm2835_playback_hw = {
        .rate_min = 8000,
        .rate_max = 192000,
        .channels_min = 1,
-       .channels_max = 2,
-       .buffer_bytes_max = 128 * 1024,
+       .channels_max = 8,
+       .buffer_bytes_max = 512 * 1024,
        .period_bytes_min = 1 * 1024,
-       .period_bytes_max = 128 * 1024,
+       .period_bytes_max = 512 * 1024,
        .periods_min = 1,
        .periods_max = 128,
 };
It's also necessary to put the following in /boot/cmdline.txt - DO NOT add it as a new line, just add it on the end of what is there.

Code:
snd_bcm2835.enable_headphones=1 snd_bcm2835.enable_hdmi=1 snd_bcm2835.enable_compat_alsa=0
To check you did it right, use the command "wc -l /boot/cmdline.txt" and you should get 1 (this tells you the number of lines in the file).

I currently have the following in /boot/config.txt but I will play around to see what is actually required:
Code:
# Definitely required
dtparam=audio=on

# Not sure if these ones are required
#dtoverlay=vc4-fkms-v3d -- commented out, it's on by default
hdmi_force_hotplug=1
hdmi_drive=2
Very happy now, thanks for all the hints... it really helps to have someone asking good questions!




Works like a charm. Thank you very yery much!
 
Hello All,

i have been trying to figure out something that can be headless dsp/ crossover solution for active speakers and stumbled upon this thread. I have an old pi 3b+ and the instructions from Charlie were pretty helpful to get started. With some help - i think i was able to follow the instructions to the tee but the kernel build is been going on for almost 2 days now and is still running....

I didn't realize the overclocking so its running at its default setting and i do get this under voltage warning that might also be throttling it (just guessing)....even though i think i am using the right charger etc...

Just wanted to get some input if there is anything that went wrong or is it normal for it to take this long to build the kernel
 
I suspect there is something else going on here. I don't remember the exact time it took to build the kernel on my Pi 4 but it was somewhere around an hour. The 3B+ is actually pretty powerful, and I would have been surprised if it took 10 times as long. See here for benchmark comparisons.
In your case in seems to be taking 50 times as long! So it sounds like something is wrong.

Can you check the CPU utilisation and disk utilisation using top?

Perhaps your I/O is really slow - are you using some really crappy SD card? I remember once I started a build on a network mapped drive and immediately realised it was a bad idea. Maybe try doing the build on a USB hard drive, it may go faster. I/O issues should be obvious in top with a large IO wait and only sporadic CPU usage.
The other possibility is that there is a hung process (although compilers tend not to hang), are you sure it is still actually making progress? Again this should be obvious in top with very long process runtime.
 
Hi @gordoste, thanks for your suggestions. It is still running....I can see the progress on the monitor so its not hung...i did use an old micro sd card which could also add to the time. I will try to change the card and see how it goes

IIRC compiling the kernel on a Pi 3B+ should only take a couple of hours. I would pull the plug and start over.

Did you enable the flag so that you will use all four cores? Make sure you have an adequate power supply. The throttling alert is NOT what you want to see. You could just end up with a corrupted kernel. Also, make sure you have the Pi in free air with a heat sink on it. It needs to get rid of the heat it is generating.
 
Hello all...i haven't had too much luck in compiling the kernel. Here is what i tried and in all cases its leading to the same results

a) re-did the entire process following the instructions - saw no errors but it did take again 3 days
b) followed the documentation from official Pi website....wasn't too different ...just that each step was discrete vs the how @CharlieLaub had put in one code.

both times i could see the kernel7 img and the config file...I added at the end of the config file to ensure that it boots from Kernel7 but when it start with that...i just see a rainbow colored screen. BTW, i did use the code to use all cores but even then it took 2+ days...

i am going to try to use a different SD card (even though the current one is class 10). Thanks again for your help
 
Hello All,

since i am still stuck with Pi on the kernel build, i wanted to try my hands on another SBC platform. I saw a Rockchip RK3328 (64bit architecture, 1gb ram) on amazon with a 16gb card + power supply for a mere $15 and bought one to tinker around with. I saw there were multiple distros on pine64 that were available . Couple of questions

a) is there a particular/ preferred distro that might also have all the 8 audio channels aviable as default to avoid kernel rebuild
b) assuming the answer to above is yes, can i simply use camilla dsp or another program to build crossover/ dsp

there were plenty of distros some are below
- Armbian Ubuntu Bionic Desktop on mainline Kernel (microSD / eMMC Boot)
- Armbian Debian Buster on mainline Kernel (microSD / eMMC Boot)
-Debian by ayufan or mrfixit2001 (microSD / eMMC Boot)

link to the distro's
ROCK64 - PINE64
 
There may be no need to do anything on another platform and Linux OS. For example, on an Intel box, the HDMI natively supports 8 channels of audio.

It is only with Raspbian that the HDMI audio capabilities are limited. Recompiling the kernel as I have outlined in this thread is a complete hack that does work, but could be made unnecessary if the kernel would come like that "out of the box".

When you get your RK3389 board and get an OS loaded, check out the number of channels supported with the "audio extractor HAT" connected to it. You may need to have it connected at bootup. It might work without any mods.
 
Thanks @CharlieLaub.

This might be another naïve/ dumb question

the HAT (Suptronix 7.1 channel board) fits the RK3328 board like the pi. I know the HAT also has its own 5v power input and if I power the audio extractor HAT, the pi gets powered by it

in the case of the HAT + RK3288 board combo....if i power the RK3288 board, then i am guessing it will be able to power the audio extractor HAT...just wanted to confirm

Thanks
 
Hi All,

been trying to tinker and hopefully i think i have made some progress. On my RK3288 SBC running Armbian Ubuntu desktop with the subtronics HAT (X6000) - ran the following

tdk@rock64:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: rockchiprk3328 [rockchip,rk3328], device 0: ff000000.i2s-i2s-hifi i2s-hifi-0 [ff000000.i2s-i2s-hifi i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: rockchiprk3328 [rockchip,rk3328], device 1: ff010000.i2s-rk3328-hifi ff410000.codec-1 [ff010000.i2s-rk3328-hifi ff410000.codec-1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: rockchiprk3328 [rockchip,rk3328], device 2: ff030000.spdif-dit-hifi dit-hifi-2 [ff030000.spdif-dit-hifi dit-hifi-2]
Subdevices: 1/1
Subdevice #0: subdevice #0

I guessed that hw0,0 might be the HDMI and when i run the dump params i get the following

tdk@rock64:~$ aplay -D hw:0,0 --dump-hw-params /dev/zero
Playing raw data '/dev/zero' : Unsigned 8 bit, Rate 8000 Hz, Mono
HW Params of device "hw:0,0":
--------------------
ACCESS: MMAP_INTERLEAVED RW_INTERLEAVED
FORMAT: S16_LE S24_LE S32_LE
SUBFORMAT: STD
SAMPLE_BITS: [16 32]
FRAME_BITS: [32 256]
CHANNELS: [2 8]
RATE: [32000 192000]
PERIOD_TIME: (41 2048000]
PERIOD_SIZE: [8 65536]
PERIOD_BYTES: [256 1900800]
PERIODS: [2 16384]
BUFFER_TIME: (83 4096000]
BUFFER_SIZE: [16 131072]
BUFFER_BYTES: [256 524288]
TICK_TIME: ALL
--------------------
aplay: set_params:1299: Sample format non available
Available formats:
- S16_LE
- S24_LE
- S32_LE

i see the channels as [2,8]...I am hoping that this is what we were trying to enable on the pi as well i.e get the HAT to play all 8 channels thru HDMI
 
Unfortunately while Model 3 Pi’s now work out of the box, the changes made so far don’t add multichannel HDMI audio support for Model 4 Pi’s, go to page 10 of this thread for the necessary additional changes.
I commented on the commit and the committer replied :) maybe we can get this change into Raspbian.
 
IMO either something like bcm2835-pcm: Fix up multichannel pcm audio by popcornmix * Pull Request #3933 * raspberrypi/linux * GitHub which requires recompiling the kernel, or using the enable_compat_alsa module param the other way than used in stock RPiX config e.g. linux/bcm2711-rpi-cm4.dts at 7fec469409de5a3af543043771f57ab70ddec2a4 * raspberrypi/linux * GitHub . Perhaps removing and loading the snd_bcm2835 module with module params 'enable_compat_alsa=1 enable_hdmi=0 enable_headphones=0' would fix the problem
 
Last edited:
Hello, is anyone running it in a stable conf with raspy 4b?
I'm getting back at it after having just tried it one month ago.

I've modded the kernel and it detects and plays all the 8 channels, but I have a big issue now:
channel positions/mappings are swapping randomly. :confused:

I mean I run speaker-test or ecasound, I mark down the alsa numbers to real speaker mappings, I close it, re run right after and speakers are shuffled in another combination. e.g. 1 is not front left anymore for example etc
sometimes they are offset by one, like what on previous run was on 1, now becomes 2 etc, sometime seems more random?

raspy 4b, 7.1ch board
 
thank you for the answer, I parked/abandoned this project (life got busy), still have the board but not planning to use it really soon.
The issue was happening only on a specific modded distribution (moode), it doesn't happen on vanilla raspbios.
Board works fine on raspbios. I was trying to trace the root of the issue with moode, but ran out of time.
 
Crackling in 3 way xover

My setup: Pi 3b (no+), X6000K-7.1CH, HiFiBarry DAC+ADC.

In 2-way configuration the unit works just fine and clean. With the 3-way setup I hear crackling in all 3 channels, the quieter the program is the less crackling you can hear. No change if I reduce the gain of pre1 to -20db and increase the buffer size to 2048 or set output to -f:16,6,44100.

Ecasound output:

Code:
**************************************************************************
*        ecasound v2.9.1 (C) 1997-2014 Kai Vehmanen and others    
**************************************************************************
(eca-chainsetup-parser) Buffering mode 'rt' selected.
(eca-chainsetup-parser) Setting buffersize to (samples) 2048.
(eca-chainsetup-parser) Disabling extra buffering on realtime devices.
(eca-chainsetup-parser) Enabling 'sum' mixmode.
(eca-chainsetup) Chainsetup "untitled-chainsetup"
(eca-chainsetup) Multitrack-mode enabled.
(eca-chainsetup) "rt" buffering mode selected.
(eca-chainsetup) Opened input "alsa", mode "read". Format: s16_le, channels
... 2, srate 44100, interleaved.
(eca-chainsetup) NOTE: using existing audio parameters -f:f32_le,2,44100
... for object 'loop' (tried to open with -f:s16_le,2,44100).
(eca-chainsetup) Opened input "loop", mode "read". Format: f32_le, channels
... 2, srate 44100, interleaved (locked params).
(eca-chainsetup) NOTE: using existing audio parameters -f:f32_le,2,44100
... for object 'loop' (tried to open with -f:s16_le,2,44100).
(eca-chainsetup) Opened output "loop", mode "write". Format: f32_le,
... channels 2, srate 44100, interleaved (locked params).
(eca-chainsetup) Opened input "loop", mode "read". Format: f32_le, channels
... 2, srate 44100, interleaved (locked params).
(eca-chainsetup) Opened output "loop", mode "write". Format: f32_le,
... channels 2, srate 44100, interleaved (locked params).
(eca-chainsetup) Opened output "alsa", mode "write". Format: s24_le,
... channels 6, srate 44100, interleaved.
- [ Connected chainsetup: "untitled-chainsetup" ] ------------------------
- [ Controller/Starting batch processing ] -------------------------------
- [ Engine - Driver start ] ----------------------------------------------
3-way ecasound chain, with crackling:

Code:
ecasound -B:rt -b:2048 -z:mixmode,sum \
        -a:pre1 -i:alsa,hw:3,1 -pf:/pre1.ecp -o:loop,1 \
        -a:pre2,woofer -i:loop,1 \
        -a:mid,tweeter -i:loop,2 \
        -a:pre2 -pf:/pre2.ecp -o loop,2 \
        -a:woofer -pf:/woofer.ecp -chorder:1,2,0,0,0,0 \
        -a:mid -pf:/mid.ecp -chorder:0,0,1,2,0,0 \
        -a:tweeter -pf:/tweeter.ecp -chorder:0,0,0,0,1,2 \
        -a:woofer,mid,tweeter -f:24,6,96000 -o:alsa,hw:0,0
2-way chain with clean sound:

Code:
ecasound -z:mixmode,sum -B:rt \
         -a:pre -i:alsa,hw:3,1 -pf:/pre.ecp -o:loop,1 \
         -a:woofer,tweeter -i:loop,1 \
         -a:woofer -pf:/woofer.ecp -chorder:1,2,0,0 \
         -a:tweeter -pf:/tweeter.ecp -chorder:0,0,1,2 \
         -a:woofer,tweeter -f:24,4,96000 -o:alsa,hw:0,0
Any ideas? Do I need the 3B+ board??

Regards