uGreen DABBoard & I2S

The Si468x has an I2S output which allows to stream a digital audio signal without loss of quality. This makes it possible to record a DAB+ station with a Raspberry Pi, or to play the sound through the on-board Raspberry Pi HDMI or 3.5 mm sockets.

The I2S is output via a 3 bus wire connection on pins 12, 35 and 38. Pin 12 (DCLK) provides a clock signal, Pin 35 (DFS) provides a frame syncing signal and Pin 38 (DOUT) encodes the audio of one or several channels.

To get the I2S output to the Raspberry Pi, two essential steps are necessary: the Linux Kernel on the Raspberry Pi needs a special driver (overlay file) and the radio_cli API software needs to be run with an IS2 output option set. Please note, the Si468x cannot provide I2S and analog audio output at the same time.

Raspbian Kernel preparation

A recent Raspbian kernel version contains a special ugreen-dabboard overlay file, which is needed to use I2S. Check your kernel version with:

uname -a

This should output at least a version of 5.10.33 or greater. Otherwise a kernel update is needed (with sudo rpi-update and eventually also sudo apt-get update)

Linux raspberrypi 5.10.33-v7l+ #1415 SMP Fri Apr 30 15:50:57 BST 2021 armv7l GNU/Linux

With the right kernel version, the following file should exist:

/boot/overlays/ugreen-dabboard.dtbo

If that is not the case and you do not want to update the kernel, download the overlay file from here and save in /boot/overlays/:

/wp-content/uploads/files/ugreen-dabboard.dtbo

The next step is to edit /boot/config.txt and make sure it contains these lines:

dtparam=i2c_arm=on
dtparam=i2s=on
dtparam=spi=on
dtparam=audio=on

dtoverlay=ugreen-dabboard

A working /boot/config.txt as an example can be found here:

/wp-content/uploads/files/config.txt

It should not contain any additional overlays which use the I2S bus or SPI. Reboot the Raspberry Pi to activate the module.

Please note: the latest Raspbian is not using /boot/config.txt anymore, but instead it is using a new path: /boot/firmware/config.txt. It might still be that the overlay is not loaded automatically upon start. If that is the case, you can load the overlay manually by using

sudo dtoverlay ugreen-dabboard

There should now be a new audio device listed, call

arecord -l

It should output:

**** List of CAPTURE Hardware Devices ****
card 1: dabboard [dabboard], device 0: bcm2835-i2s-dmic-hifi dmic-hifi-0 [bcm2835-i2s-dmic-hifi dmic-hifi-0]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

If that did not work, there are some additional steps which could help debugging. Run the following command:

lsmod

It should output the following kernel modules loaded:

ModuleSizeUsed by
snd_soc_simple_card204803
snd_soc_simple_card_utils245761 snd_soc_simple_card
snd_soc_dmic163841

If that is not the case, your kernel did not manage to load some modules (dmic codec and simple-card) which are required. You can use the command dmesg to check for any errors why this failed.

Start playing

Now, it will be possible to use the radio_cli tool to tune to a station and enable I2S output (adjust the ensemble parameters to match a working radio station in your area). Use the following commands to start the Si468x and to start playback throught the Raspberry Pi audio jack:

sudo ./radio_cli/radio_cli -b D -o 1 -f 8 -e 20240 -c 5 -p

arecord -D sysdefault:CARD=dabboard -c 2 -r 48000 -f S16_LE -vv | aplay -D sysdefault:CARD=Headphones

You can also playback the sound through bluetooth speakers, using this command:

arecord -D sysdefault:CARD=dabboard -c 2 -r 48000 -f S16_LE -vv | aplay -D bluealsa:DEV=[BLUETOOTH_MAC_ADDRESS],PROFILE=a2dp

Please note: add the option -t raw if you want to play for more than 3 hours.

Build the overlay file yourself

If you are familiar with compiling your own Raspbian kernel, it is possible to build (and modify) the overlay file yourself.

Follow the instructions here to build the raspbian kernel:

https://www.raspberrypi.org/documentation/linux/kernel/building.md

The overlay file source code for the 5.10 Raspbian kernel is here:

https://github.com/raspberrypi/linux/blob/rpi-5.10.y/arch/arm/boot/dts/overlays/ugreen-dabboard-overlay.dts

Advanced: use an external amplifier to play the I2S

It is also possible to transmit the I2S digital audio directly to an extra amplifier. This can be, for example, the Hifiberry AMP2.

For this to work, one has to completely disable all the drivers, start the DABBoard using I2S as an I2S master and manually configure the Hifiberry AMP2 to be the I2S slave. The Raspberry Pi is only passively taking part in this I2S configuration.

sudo rmmod snd_soc_hifiberry_dacplus snd_soc_pcm512x_i2c 
sudo rmmod snd_soc_pcm512x snd_soc_bcm2835_i2s

then use the following commands to directly configure the Texas Instruments TAS5756M which is built into the AMP2

sudo i2cset -y 1 0x4d 2 0x10
sudo i2cset -y 1 0x4d 1 0x11
sudo i2cset -y 1 0x4d 40 0x00
sudo i2cset -y 1 0x4d 13 0x10
sudo i2cset -y 1 0x4d 37 0x08
sudo i2cset -y 1 0x4d 61 0x82
sudo i2cset -y 1 0x4d 62 0x82
sudo i2cset -y 1 0x4d 2 0x00

finally:

sudo ./radio_cli -b D -o 1 -f 33 -c 16 -e 17137 -p -l 60

Important: for this to work, one has to connect the I2S output to the input of the Raspberry Pi (or, in other words, connect the Si468x I2S DOUT to the DIN of the Hifiberry AMP2). The pins to connect are the physical pins 38 and 40 of the Raspberry Pi.

Further information and commands for the AMP2 can be found from the TI datasheet: https://www.ti.com/product/TAS5756M

The two registers 61, 62 for example control the volume, and it shoud be possible to use them while playing with the commands above. Set to a different volume for example with:

sudo i2cset -y 1 0x4d 61 0x72
sudo i2cset -y 1 0x4d 62 0x72