Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is2mic - Add Raspberry Pi 5 Support #276

Open
danic85 opened this issue Dec 13, 2023 · 6 comments
Open

is2mic - Add Raspberry Pi 5 Support #276

danic85 opened this issue Dec 13, 2023 · 6 comments

Comments

@danic85
Copy link

danic85 commented Dec 13, 2023

Script Command

cd ~
sudo pip3 install --upgrade adafruit-python-shell
wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/i2smic.py
sudo python3 i2smic.py

Operating System

64 bit Raspberry Pi OS

Hardware

Raspberry Pi 5

Behavior

Board is rejected as it is not explicitly accepted in the installer script. Once added alongside the Pi 4 boards, this is the error:


Cloning into 'Raspberry-Pi-Installer-Scripts'...
make -C /lib/modules/6.1.58-v8_16k+/build M=/home/archie/Raspberry-Pi-Installer-Scripts/i2s_mic_module clean
make[1]: *** /lib/modules/6.1.58-v8_16k+/build: No such file or directory.  Stop.
make: *** [Makefile:38: clean] Error 2
make -C /lib/modules/6.1.58-v8_16k+/build M=/home/archie/Raspberry-Pi-Installer-Scripts/i2s_mic_module modules
make[1]: *** /lib/modules/6.1.58-v8_16k+/build: No such file or directory.  Stop.
make: *** [Makefile:35: all] Error 2
make: *** No rule to make target 'snd-i2smic-rpi.ko', needed by 'install'.  Stop.
DONE.

Description

Following (failed) install, the mic is not available with arecord -l.

Additional information

No response

@danic85 danic85 added the bug label Dec 13, 2023
@danic85 danic85 changed the title Raspberry Pi 5 Support is2mic - Raspberry Pi 5 Support Dec 14, 2023
@makermelissa
Copy link
Contributor

I was able to get it to compile fine, but it still doesn't function. Looking deeper into this, the values in this section (

// Set platform
switch (rpi_platform_generation) {
case 0:
// Pi Zero
card_platform = "20203000.i2s";
break;
case 1:
// Pi 2 and 3
card_platform = "3f203000.i2s";
break;
case 2:
default:
// Pi 4
card_platform = "fe203000.i2s";
break;
}
) were originally obtained by running:
sudo cat /sys/kernel/debug/asoc/dais

However, for the Pi 5, only snd-soc-dummy-dai is returned, so it does not appear that this will run on the Pi 5 without some significant modifications.

@makermelissa makermelissa changed the title is2mic - Raspberry Pi 5 Support is2mic - Add Raspberry Pi 5 Support Dec 26, 2023
@torimos
Copy link

torimos commented Jan 19, 2024

I was able to get it to compile fine, but it still doesn't function. Looking deeper into this, the values in this section (

// Set platform
switch (rpi_platform_generation) {
case 0:
// Pi Zero
card_platform = "20203000.i2s";
break;
case 1:
// Pi 2 and 3
card_platform = "3f203000.i2s";
break;
case 2:
default:
// Pi 4
card_platform = "fe203000.i2s";
break;
}

) were originally obtained by running:
sudo cat /sys/kernel/debug/asoc/dais
However, for the Pi 5, only snd-soc-dummy-dai is returned, so it does not appear that this will run on the Pi 5 without some significant modifications.

I did try to update the i2smic.py with PI5 support:

 elif pi_model in ("RASPBERRY_PI_5"):
        pimodel_select = 3

And snd-i2smic-rpi.c with according initialization:

  // Set platform
  switch (rpi_platform_generation) {
    case 0:
      // Pi Zero
      card_platform = "20203000.i2s";
      break;
    case 1:
      // Pi 2 and 3
      card_platform = "3f203000.i2s";
      break;
    case 2:
      // Pi 4
      card_platform = "fe203000.i2s";
      break;
    case 3:
    default:
      // Pi 5
      card_platform = "1f000a4000.i2s";
      dmaengine = "snd_pcm_dmaengine";
  }

The 1f000a4000.i2s I was able to get using:

sudo cat /sys/kernel/debug/asoc/dais 

before running the i2smic.py script

But after making and installing module I got:
[ 4.237997] snd_i2smic_rpi: loading out-of-tree module taints kernel.
[ 4.245310] snd-i2smic-rpi: Version 0.1.0
[ 4.245315] snd-i2smic-rpi: Setting platform to 1f000a4000.i2s
...
[ 4.305790] request module load 'snd_pcm_dmaengine': 0
[ 4.311105] register platform device 'asoc-simple-card': 0

I also tried default bcm2708-dmaengine with same result

arecord -l
Does not return any recording devices

Not sure where to look next and why registration does not workl

@makermelissa
Copy link
Contributor

It likely doesn't work because they changed the hardware quite a bit. Also, when I run the same command on my Pi 5, I get:

i2s-hifi
107c706400.hdmi
i2s-hifi
107c701400.hdmi
snd-soc-dummy-dai

This is more than before, but still not seeing a consistent value.

@torimos
Copy link

torimos commented Jan 19, 2024

yes, it looks like RPI team is currently focused on core0 (main core) and in the near future there will be not much news in regards to RP1 (core1) used to communicate with I2S peripheral
More details is here: https://forums.raspberrypi.com/viewtopic.php?t=363644

@jerbzz
Copy link

jerbzz commented Jul 1, 2024

Hi @makermelissa - trying to get this to run on a Pi Zero 2 W running Bookworm. May I ask what your solution was to get it to compile?

Compiler output with a whole litany of chaos
make -C /lib/modules/6.6.20+rpt-rpi-v8/build M=/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module clean
make[1]: Entering directory '/usr/src/linux-headers-6.6.20+rpt-rpi-v8'
make[1]: Leaving directory '/usr/src/linux-headers-6.6.20+rpt-rpi-v8'
make -C /lib/modules/6.6.20+rpt-rpi-v8/build M=/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module modules
make[1]: Entering directory '/usr/src/linux-headers-6.6.20+rpt-rpi-v8'
CC [M]  /home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.o
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:59:15: error: variable ‘default_card_info’ has initializer but incomplete type
   59 | static struct simple_card_info default_card_info = {
      |               ^~~~~~~~~~~~~~~~
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:60:4: error: ‘struct simple_card_info’ has no member named ‘card’
   60 |   .card = "snd_rpi_i2s_card",       // -> snd_soc_card.name
      |    ^~~~
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:60:11: warning: excess elements in struct initializer
   60 |   .card = "snd_rpi_i2s_card",       // -> snd_soc_card.name
      |           ^~~~~~~~~~~~~~~~~~
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:60:11: note: (near initialization for ‘default_card_info’)
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:61:4: error: ‘struct simple_card_info’ has no member named ‘name’
   61 |   .name = "simple-card_codec_link", // -> snd_soc_dai_link.name
      |    ^~~~
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:61:11: warning: excess elements in struct initializer
   61 |   .name = "simple-card_codec_link", // -> snd_soc_dai_link.name
      |           ^~~~~~~~~~~~~~~~~~~~~~~~
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:61:11: note: (near initialization for ‘default_card_info’)
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:62:4: error: ‘struct simple_card_info’ has no member named ‘codec’
   62 |   .codec = "snd-soc-dummy",         // "dmic-codec", // -> snd_soc_dai_link.codec_name
      |    ^~~~~
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:62:12: warning: excess elements in struct initializer
   62 |   .codec = "snd-soc-dummy",         // "dmic-codec", // -> snd_soc_dai_link.codec_name
      |            ^~~~~~~~~~~~~~~
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:62:12: note: (near initialization for ‘default_card_info’)
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:63:4: error: ‘struct simple_card_info’ has no member named ‘platform’
   63 |   .platform = "not-set.i2s",
      |    ^~~~~~~~
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:63:15: warning: excess elements in struct initializer
   63 |   .platform = "not-set.i2s",
      |               ^~~~~~~~~~~~~
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:63:15: note: (near initialization for ‘default_card_info’)
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:64:4: error: ‘struct simple_card_info’ has no member named ‘daifmt’
   64 |   .daifmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS,
      |    ^~~~~~
In file included from /usr/src/linux-headers-6.6.20+rpt-common-rpi/include/sound/soc-topology.h:15,
                 from /usr/src/linux-headers-6.6.20+rpt-common-rpi/include/sound/soc-dapm.h:15,
                 from /usr/src/linux-headers-6.6.20+rpt-common-rpi/include/sound/soc.h:417,
                 from /usr/src/linux-headers-6.6.20+rpt-common-rpi/include/sound/simple_card.h:12,
                 from /home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:23:
/usr/src/linux-headers-6.6.20+rpt-common-rpi/include/uapi/sound/asoc.h:150:41: warning: excess elements in struct initializer
  150 | #define SND_SOC_DAI_FORMAT_I2S          1 /* I2S mode */
      |                                         ^
/usr/src/linux-headers-6.6.20+rpt-common-rpi/include/sound/soc-dai.h:27:41: note: in expansion of macro ‘SND_SOC_DAI_FORMAT_I2S’
   27 | #define SND_SOC_DAIFMT_I2S              SND_SOC_DAI_FORMAT_I2S
      |                                         ^~~~~~~~~~~~~~~~~~~~~~
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:64:13: note: in expansion of macro ‘SND_SOC_DAIFMT_I2S’
   64 |   .daifmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS,
      |             ^~~~~~~~~~~~~~~~~~
/usr/src/linux-headers-6.6.20+rpt-common-rpi/include/uapi/sound/asoc.h:150:41: note: (near initialization for ‘default_card_info’)
  150 | #define SND_SOC_DAI_FORMAT_I2S          1 /* I2S mode */
      |                                         ^
/usr/src/linux-headers-6.6.20+rpt-common-rpi/include/sound/soc-dai.h:27:41: note: in expansion of macro ‘SND_SOC_DAI_FORMAT_I2S’
   27 | #define SND_SOC_DAIFMT_I2S              SND_SOC_DAI_FORMAT_I2S
      |                                         ^~~~~~~~~~~~~~~~~~~~~~
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:64:13: note: in expansion of macro ‘SND_SOC_DAIFMT_I2S’
   64 |   .daifmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS,
      |             ^~~~~~~~~~~~~~~~~~
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:65:4: error: ‘struct simple_card_info’ has no member named ‘cpu_dai’
   65 |   .cpu_dai = {
      |    ^~~~~~~
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:65:14: error: extra brace group at end of initializer
   65 |   .cpu_dai = {
      |              ^
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:65:14: note: (near initialization for ‘default_card_info’)
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:65:14: warning: excess elements in struct initializer
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:65:14: note: (near initialization for ‘default_card_info’)
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:69:4: error: ‘struct simple_card_info’ has no member named ‘codec_dai’
   69 |   .codec_dai = {
      |    ^~~~~~~~~
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:69:16: error: extra brace group at end of initializer
   69 |   .codec_dai = {
      |                ^
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:69:16: note: (near initialization for ‘default_card_info’)
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:69:16: warning: excess elements in struct initializer
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:69:16: note: (near initialization for ‘default_card_info’)
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c: In function ‘i2s_mic_rpi_init’:
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:123:15: error: ‘default_card_info’ has an incomplete type ‘struct simple_card_info’
  123 |   card_info = default_card_info;
      |               ^~~~~~~~~~~~~~~~~
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:123:13: error: ‘card_info’ has an incomplete type ‘struct simple_card_info’
  123 |   card_info = default_card_info;
      |             ^
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:124:12: error: invalid use of undefined type ‘struct simple_card_info’
  124 |   card_info.platform = card_platform;
      |            ^
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:125:12: error: invalid use of undefined type ‘struct simple_card_info’
  125 |   card_info.cpu_dai.name = card_platform;
      |            ^
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c: At top level:
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:41:32: error: storage size of ‘card_info’ isn’t known
   41 | static struct simple_card_info card_info;
      |                                ^~~~~~~~~
/home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c:59:32: error: storage size of ‘default_card_info’ isn’t known
   59 | static struct simple_card_info default_card_info = {
      |                                ^~~~~~~~~~~~~~~~~
make[3]: *** [/usr/src/linux-headers-6.6.20+rpt-common-rpi/scripts/Makefile.build:248: /home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.o] Error 1
make[2]: *** [/usr/src/linux-headers-6.6.20+rpt-common-rpi/Makefile:1938: /home/james/Raspberry-Pi-Installer-Scripts/i2s_mic_module] Error 2
make[1]: *** [/usr/src/linux-headers-6.6.20+rpt-common-rpi/Makefile:246: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.6.20+rpt-rpi-v8'
make: *** [Makefile:35: all] Error 2
make: *** No rule to make target 'snd-i2smic-rpi.ko', needed by 'install'.  Stop.
DONE.

@makermelissa
Copy link
Contributor

makermelissa commented Jul 2, 2024

@jerbzz I don't remember exactly what I did at this point, but I likely just followed the instructions at https://learn.adafruit.com/adafruit-i2s-mems-microphone-breakout/raspberry-pi-wiring-test#installer-script-3061600. I think I may have been using a Pi 4 as well. ...No, it was on a Pi 5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants