Search code examples
codecalsadevice-treebeagleboardi2s

How to record I2S audio microphone in Beaglebone AI


I am trying to record in a Beaglebone AI from a Circular Microphone Board TIDA-01454. I have checked that the CMB's output is correct with an I2S DAC(I can hear the mics sound). However, I cant record in the Beaglebone AI, this is what happens when I try to arecord:

arecord --device="hw:1,0" -c2 -f S32_LE test.wav

Recording WAVE 'test.wav' : Signed 32 bit Little Endian, Rate 8000 Hz, Stereo

arecord: pcm_read:2145: read error: Input/output error

I think the problem must be somewhere in my DTS file or ALSA configuration. But I dont really know, so if more information is needed, just ask for it.

DTS(not complete):

pcm5102a: pcm5102a {
   #sound-dai-cells = <0>;
   compatible = "ti,pcm5102a";
   status = "okay";
};


sound {compatible = "simple-audio-card";
        simple-audio-card,format = "i2s";
        simple-audio-card,name = "PCM5102a";
        simple-audio-card,bitclock-master = <&sound1_master>;
        simple-audio-card,frame-master = <&sound1_master>;
        simple-audio-card,bitclock-inversion;
        
        
        simple-audio-card,cpu {
                sound-dai = <&mcasp1>;
        };
        sound1_master: simple-audio-card,codec {
            #sound-dai-cells = <0>;
            sound-dai = <&pcm5102a>;
            
        };
      };
};
&mcasp1 {
    #sound-dai-cells = <0>;
    status = "okay";
    pinctrl-names = "default";  
    pinctrl-0 = <&mcasp1_pins>;  
    op-mode = <0>;    /* MCASP_IIS_MODE */
    tdm-slots = <2>;
    num-serializer = <4>;
    /* 16 serializers */
    serial-dir = < /* 1 TX 2 RX 0 unused */
             2 0 0 0
        >;
    rx-num-evt = <1>;
    tx-num-evt = <1>;
};

asound.conf:

pcm.onboard{
    type hw
    card 0
}
ctl.onboard {
    type hw
    card 0
}

### Dsnoop splited channels
pcm.onboard_capture_left {
     type dsnoop
     ipc_key 32
     slave {
         pcm "onboard"
         channels 2
     rate 48000
         format S32_LE
     }
     bindings.0  0
}
pcm.onboard_playback_left {
     type dmix
     ipc_key 33
     slave {
         pcm "onboard"
         channels 2
     }
     bindings.0  0
}


pcm.onboard_capture_right {
     type dsnoop
     ipc_key 32
     slave {
         pcm "onboard"
         channels 2
     rate 48000
     format S32_LE
     }
     bindings.0  1
}
pcm.onboard_playback_right {
     type dmix
     ipc_key 33
     slave {
         pcm "onboard"
         channels 2
     }
     bindings.0  1
}


### PLUGS ##
### used with darkice
### device = plug:plug_onboard_left
pcm.plug_onboard_capture_left{
        type plug
        slave.pcm "onboard_capture_left"
}
pcm.plug_onboard_playback_left{
        type plug
        slave.pcm "onboard_playback_left"
}

pcm.!default {
    type asym
    playback.pcm "plug_onboard_playback_left"
    capture.pcm "plug_onboard_capture_left"
}

Solution

  • Seems like probably you have a mistake in you DTS file. Given its I2S input you should use these 3 pins:

    #define P9_31b (0x3400 + 4 * 169)
    #define P9_29b (0x3400 + 4 * 170)
    #define P9_18b (0x3400 + 4 * 173)
    

    and

    DRA7XX_CORE_IOPAD(P9_29b, PIN_INPUT | MUX_MODE0) // 29b 0  mcasp1_fsx    FRAME SYNC           RCLK
       DRA7XX_CORE_IOPAD(P9_31b, PIN_INPUT | MUX_MODE0) // 31b 0  mcasp1_aclkx  BIT CLOCK            BCLK
       DRA7XX_CORE_IOPAD(P9_18b, PIN_INPUT | MUX_MODE0) // 18b 0  mcasp1_axr0   I2S INPUT            DATA