[SOLVED] I2S speaker with Matrix Voice

#1

Hi,

How can I use I2S port for my speaker (https://learn.adafruit.com/adafruit-max98357-i2s-class-d-mono-amp/overview) ? I2S use GPIOs 18 19 21. I don’t see these ports on the extension port pinout.

Regards

0 Likes

#2

Hi @Piscenois,

Welcome to the community!

The GPIO pins on MATRIX devices are actually configured through the FPGA and are not the same as the Raspberry Pi’s GPIO pins. Currently, I2S is not a feature of the MATRIX Voice GPIOs.

However, the Raspberry Pi’s GPIO 18, 19, 20, and 21 (I2S pins) are not currently performing any functions in the MATRIX Voice and can be accessed through its FPGA. The FPGA code can be modified to essentially create a “wire” between these RPi pins and some MATRIX Voice GPIOs. We have a tutorial that shows how to do this here. This would allow you to access the the RPi pins and setup I2S using existing RPi libraries.

Since this FPGA code modification is relatively simple to do, we can provide you with a bit file that does this, and provide you with instructions on how to flash that bit file onto your MATRIX Voice FPGA.

I will post the file with instructions here shortly so you can use it if you would like. Then, you could potentially use those MATRIX Voice GPIOs that come from the RPi to setup I2S communication using RPi libraries.

Best,
Samreen

0 Likes

#3

HI Samreen,

That’a a great news ! Thank you ! :heart_eyes:

Regards
Piscenois

0 Likes

#4

Hello,

The FPGA bit file which exposes Raspberry Pi pins 18, 19, 20 and 21 to MATRIX Voice GPIOs is attached below.
system.bit (333.3 KB)

To ensure that you downloaded the file correctly, please run the following terminal command to check if the bit file is the same.

md5sum system.bit

The value should be 4eda9cb48474427886700712cd7c4983.

This is the mapping of the pins
RPi BCM GPIO 18 -> MATRIX Voice GPIO DF12
RPi BCM GPIO 19 -> MATRIX Voice GPIO DF13
RPi BCM GPIO 20 -> MATRIX Voice GPIO DF14
RPi BCM GPIO 21 -> MATRIX Voice GPIO DF15

Follow this guide to flash the new bit file to your MATRIX Voice’s FPGA.

Some tips

  • Before starting the flashing guide, place this system.bit file in the /home/pi folder in your Raspberry Pi. You can do this on the microSD directly or via SFTP from your personal computer.
  • Make sure to run
    cd /usr/share/matrixlabs/matrixio-devices
    before flashing the SPI Flash bootloader onto FPGA using the following line
    xc3sprog -c matrix_voice blob/bscan_spi_s6lx9_ftg256.bit

I tested the new connections after flashing the FPGA using the terminal GPIO utility, and all the pins seem to have been mapped correctly. Keep in mind when programming that these are BCM pin mappings.

We have not tested with I2S or other libraries so let us know how it goes!

Best,
Samreen

1 Like

#5

Hi,

Thank you again ! Please give me time to buy and test the components and I will write the feedback.

Regards
Piscenois

1 Like

#6

Hi !

I can’t test your program. When I install the matrixio-creator-init package, the I2S speaker stop working. Can I ask for help in this thread or is it better to start a new one ?

Regards

0 Likes

#7

Hello @Piscenois,

We can continue on this thread.

When you install the matrixio-creator-init package, the default FPGA bit file will be flashed, so your I2S speaker will temporarily stop working.

Once you flash the FPGA with the bit file I provided using the directions here, make sure to follow all the way through to the part where you run the following.

sudo apt-mark hold matrixio-creator-init

and then power off your device with the following, unplug and replug after your Raspberry Pi indicator light blinks 10 times.

sudo poweroff

This prevents the matrixio-creator-init package from automatically updating so that it does not update and override your custom FPGA bit file. Then you should be able to use the pin mapping in the post above to wire up your I2S speaker and try out some existing Raspberry Pi I2S libraries.

Let me know if this is what you meant!

Best,
Samreen

0 Likes

#8

Hi Samreen,

The matrix voice isn’t plugged, only the speaker through the max98357 I2S ampli. So I think the FPGA isn’t the problem.
I tried to rollback /boot and /etc modifications :

  • removing the /boot/config.txt matrixio configuration
  • blacklisting or not loading the modules (snd_bcm2835, snd-dummy, bcm2835-v4l2)
    but the speaker doesn’t work !
    Then I saw than the link /sys/class/gpio/gpio18 was created by matrixio installation. And this GPIO is used by I2S. I didn’t find which script manage this GPIO. Do you know what it is used for ?

Regards
Piscenois

0 Likes

#9

Hi @Piscenois,

I see what you mean now. We looked into the matrixio-creator-init installation files to see what the problem may be and think we have a quick fix for the gpio18 problem.

The matrixio-creator-init package detects whether the device connected is a MATRIX Creator or a MATRIX Voice and then flashes components and changes GPIOs respectively. However, it attempts to program the FPGA regardless. This is something we will improve in the future.

It seems the issue you are having could be because the fpga-program.bash file attempts to flash the MATRIX Creator’s FPGA and first resets the MATRIX Creator using gpio18.

Our quick fix for you is to navigate to the the following file and comment out the line which is program_creator.

sudo nano /usr/share/matrixlabs/matrixio-devices/fpga-program.bash

Then run

sudo /usr/share/matrixlabs/matrixio-devices/fpga-program.bash

The rest of the init package should be fine as is. Let us know how this goes for you!

Best,
Samreen & Yoel

0 Likes

#10

Hi Samreen & Yoel,

It works ! Thank you. :heart_eyes:
But … during my research I discovered the 2 DF13 speaker outputs. I think it will be more elegant to use them :slight_smile: I’ll test them, just need male DF13.

Could you give me the system.bit source code please ?

Regards

0 Likes