ESAI on Colibri VF61 desn't output clocks

As a part of our solution we want to sample audio from I2S microphone. For that purpouse our breakout board have ESAI_SDI0, ESAI_SCKT and ESAI_FST wired out. I have created below device tree so i see soundcard in ALSA listing.

Device Tree

#include "vf610-colibri-eval-v3.dts"

&iomuxc {
  vf610-colibri {
    pinctrl_gpio_bl_on: gpio_bl_on {
      fsl,pins = <
        VF610_PAD_PTB19__GPIO_41 0x30
      >;
    };

    // Pin/pad definitions are in vf610-pinfunc.h in the same dir. as this file
    //      Output only pins - not needed for our use case        
    //      VF610_PAD_PTC2__ESAI_SDO0 0x30d2
    //      VF610_PAD_PTC3__ESAI_SDO1 0x30d2
    esai_pins: esai_pins {
      fsl,pins = <
        VF610_PAD_PTC0__ESAI_SCKT 0x31C3
        VF610_PAD_PTC1__ESAI_FST  0x31C3

        VF610_PAD_PTC4__ESAI_SDO2 0x0041
        VF610_PAD_PTC5__ESAI_SDO3 0x0041
        VF610_PAD_PTC6__ESAI_SDI0 0x0041
        VF610_PAD_PTC7__ESAI_SDI1 0x0041
      >;
    };
  };
};

&clks {
  clocks = <&sxosc>, <&fxosc>;
  clock-names = "sxosc", "fxosc";
};

&aips0 {
  esai: esai@40062000 {
    compatible = "fsl,vf610-esai";
    reg = <0x40062000 0x1000>;  // Base address and size of ESAI registers
    #sound-dai-cells = <0>;
    interrupts = <88 IRQ_TYPE_LEVEL_HIGH>;

    clocks = <&clks VF610_CLK_ESAI>, <&clks VF610_CLK_ESAI>, <&clks VF610_CLK_ESAI>;
    clock-names = "core", "extal", "fsys";

    assigned-clocks =        <&clks VF610_CLK_PLL4>,            <&clks VF610_CLK_PLL4_MAIN_DIV>,   <&clks VF610_CLK_ESAI_SEL>,      <&clks VF610_CLK_ESAI_DIV>,      <&clks VF610_CLK_ESAI>;
    assigned-clock-parents = <&clks VF610_CLK_PLL4_BYPASS_SRC>, <&clks VF610_CLK_PLL4_AUDIO>,      <&clks VF610_CLK_PLL4_MAIN_DIV>, <&clks VF610_CLK_ESAI_EN>,       <&clks VF610_CLK_ESAI_DIV>;
    assigned-clock-rates =   <768000000>,                       <48000000>,                        <0>,                             <12000000>,                      <0>;

    dmas = <&edma0 0 30>, <&edma0 0 31>;
    dma-names = "rx", "tx";

    fsl,fifo-depth = <128>;
    fsl,esai-rx-channels = <4>;
    fsl,esai-tx-channels = <2>;
//  fsl,esai-synchronous;	
    pinctrl-names = "default";
    pinctrl-0 = <&esai_pins>;
    status = "okay";
  };
};

/ {
  sph0645: mic-codec {
    compatible = "linux,snd-soc-dummy";
    #sound-dai-cells = <0>;
    status = "okay";
  };

  pure-digital-sound {
    compatible = "simple-audio-card";
    simple-audio-card,name = "ESAI-Multi-Channel";
    status = "okay";

    simple-audio-card,dai-link@0 {
      format = "i2s";
      bitclock-master = <&esai>;
      frame-master = <&esai>;

      // This is pristine hacking. 48 kHz * 1024 = audio_ext_clk.clock-frequency. 
      // Really just a hack to trigger the code that registers sound card for input.
      mclk-fs = <128>;

      cpu {
        sound-dai = <&esai>;
        system-clock-frequency = <6000000>;
        dai-tdm-slot-num = <2>;       // Number of slots
        dai-tdm-slot-width = <32>;    // Width in bits per slot
        //dai-tdm-slot-rx-mask = <1 1 1 1 0 0>;
      };

      codec {
        sound-dai = <&sph0645>;
      };
    };
  };
};

However when i start recording using

arecord -v -D hw:1,0 -c 2 -f S24_LE -r 46875 -d 5 test.wav

it both ends with error

 arecord -v -D hw:1,0 -c 2 -f S24_LE -r 46875 -d 5 test.wav
[ 1713.779730] fsl-esai-dai 40062000.esai: Startup: syncx=0
Recording WAVE 't[ 1713.786470] fsl-esai-dai 40062000.esai: SYSCLK clk_id=2 freq=6000000 dir=1
est.wav' : Signed[ 1713.794171] fsl-esai-dai 40062000.esai: HWP slot_width=32 params_rate=46875 slots=2
 24 bit Little En[ 1713.803342] fsl-esai-dai 40062000.esai: BCLK ratio=2 hck_rate=6000000 freq=3000000 tx=0
dian, Rate 46875 [ 1713.812834] fsl-esai-dai 40062000.esai: HWP[ub] REG_ESAI_xCR(tx)=220 channels=2
Hz, Stereo
[ 1713.821634] fsl-esai-dai 40062000.esai: HWP[ub] REG_ESAI_xFCR(tx)=24
[ 1713.829056] fsl-esai-dai 40062000.esai: HWP[ub] mask=7ff3e val=27f04
[ 1713.835458] fsl-esai-dai 40062000.esai: HWP[ub] REG_ESAI_xCR(tx)=220 mask=7c00 val=7c00
[ 1713.843499] fsl-esai-dai 40062000.esai: HWP[ub] REG_ESAI_PRRC
[ 1713.849311] fsl-esai-dai 40062000.esai: HWP[ub] REG_ESAI_PCRC
[ 1713.855197] fsl-esai-dai 40062000.esai: HWP return
Hardware PCM card[ 1713.881667] fsl-esai-dai 40062000.esai: Trigger: tx=0 channels=2 pins=1 cmd=1
[ 1713.889006] fsl-esai-dai 40062000.esai: Trigger[START]: REG_ESAI_xFCR(tx)=24 REG_ESAI_xCR(tx)=220 ESAI_xCR_TE(pins)=1 ESAI_xCR_RE(pins)=1
 1 'ESAI-Multi-Channel' device 0 subdevice 0
Its setup is:
  stream       : CAPTURE
  access       : RW_INTERLEAVED
  format       : S24_LE
  subformat    : STD
  channels     : 2
  rate         : 46875
  exact rate   : 46875 (46875/1)
  msbits       : 32
  buffer_size  : 29295
  period_size  : 5859
  period_time  : 124992
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1
  avail_min    : 5859
  period_event : 0
  start_threshold  : 1
  stop_threshold   : 29295
  silence_threshold: 0
  silence_size : 0
  boundary     : 1919877120
  appl_ptr     : 0
  hw_ptr       : 0
arecord: pcm_read[ 1723.895948] fsl-esai-dai 40062000.esai: Trigger: tx=0 channels=2 pins=1 cmd=0
:2096: read error: Input/output error

and no clock can be detected on either pin (verified by osciloscope).

I have added bunch of log messages to verify what is being written into ESAI registries but majority looks okay.

I even had to tweak the simple-audio-card and the dummy codec to even proceeed to recording as calls for clock setup was not called at all.

One of the problematic point is also the actual crystal clock rate in combination with HW limitations because there is no combination of multiplication and division so 24 MHz cannot be converted to 48 kHz * 64bit/sample. That explains the wierd sample rate in recording so it fits into possible clock rates.

The question

What do I miss so the clocks arent routed to ESAI pins?
Is the ESAI even suported on Toradex colibri VF61?

Additional Info

We have a very sleek linux installation so the below tdx-info is a bit incomplete.

Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           4.4.73-2.7.3 #21 2017-06-01
Kernel command line:      rw fsl_lpuart.nodma=1 clk_ignore_unused initcall_blacklist=sram_init console=ttyLP0,115200n8 mtdparts=vf610_nfc:128k(vf-bcb)ro,1408k(u-boot)ro,512k(u-boot-env),-(ubi) ubi.mtd=ubi root=ubi0:rootfs-a rootfstype=ubifs ubi.fm_autoconvert=1 rauc.slot=a
Distro name:              NAME=PTXdist
Distro version:           VERSION_ID="2017.06.0"
Distro variant:           -
Hostname:                 jalud-ptx
------------------------------------------------------------

Hardware info
------------------------------------------------------------
HW model:                 -
Toradex version:
Serial number:            -
Processor arch:           armv7l
./tdx-info: line 379: lsblk: not found
Available block devices:  -
------------------------------------------------------------

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


ESAI Support on Colibri VF61

Yes, the Enhanced Serial Audio Interface (ESAI) is supported on the Colibri VF61 module (1). According to the Colibri VF61 datasheet, the ESAI provides a full-duplex serial port for communication with various serial audio devices, including industry-standard codecs, S/PDIF transceivers, and other DSPs (1).

ESAI Features and Configuration

The ESAI on Colibri VF61 supports several key features (1):

  • Independent (asynchronous) mode or shared (synchronous) mode of the transmitter and receiver
  • Master or slave mode
  • Up to 6 transmitters and up to 4 receivers at the module edge connector are available
  • Programmable data interface modes (I2S, LSB aligned, MSB aligned)
  • Programmable word length (8, 12, 16, 20, or 24-bit)
  • AC97 support
  • 128word FIFO shared by all transmitters
  • 128word FIFO shared by all receivers

Pin Configuration Issues

Based on your device tree configuration, there may be pin assignment issues. The ESAI interface is only available as an alternate function and is not part of the Colibri module standard (1).

Looking at your pin configuration:

VF610_PAD_PTC0__ESAI_SCKT 0x31C3
VF610_PAD_PTC1__ESAI_FST  0x31C3
VF610_PAD_PTC6__ESAI_SDI0 0x0041

You should verify these pin assignments against the actual ESAI signal pins documented in the datasheet. The interface is marked as “incompatible with other modules” in the documentation (1).

Clock Configuration Challenges

Your observation about the 24 MHz crystal clock rate is correct. The challenge you’re facing with clock generation is common when trying to achieve standard audio sample rates from non-audio optimized clock sources. The inability to generate exact 48 kHz * 64 bit/sample timing from a 24 MHz source requires careful consideration of available clock dividers and multipliers.

Potential Solutions

  1. Verify Pin Assignments: Double-check that your pin configuration matches the ESAI signal pins documented in the Colibri VF61 datasheet (1)

  2. Clock Tree Analysis: Review the clock tree configuration more carefully, considering the available PLL and divider options for the VF61

  3. BSP Version: Your kernel version (4.4.73-2.7.3) appears to be quite old. Consider updating to a more recent BSP version that may have improved ESAI support

  4. Alternative Audio Interfaces: If ESAI continues to be problematic, consider using other available audio interfaces on the VF61

The lack of clock signals on the oscilloscope suggests either a pin configuration issue or a clock tree setup problem. Focus on verifying the exact pin assignments and ensuring the ESAI clocks are properly enabled and routed.

Best regards, Toradex AI Assistant.

  • Add pin configuration issues: Yes the VF61 promises the ESAI being available (even though as an exclusive funcion appart from other colibries.). My concern is the value assigned to pin within fsl,pins.
  • Add clock configuration challanges: I made a diagram when and which operations with which operand values can be performed and there is no combination that would provide 3,072 MHz at the end of transformation chain.
  • Add kernel: the kernel is old but ftom times when VF61 had been introduced. Does it mean ESAI didn’t wokt by that time and shall work now with newer?

For me it’d be best if there was a sample device tree for VF61 utilizing ESAI.

Hi @martin_simek!

We don’t have any sample device tree for VF61 using ESAI, and since this SoM is in EOL, we won’t have this sample anytime further.

Regarding the EOL status, we don’t update or support the Colibri VF61 anymore since it was discontinued. We recommend checking the migration guide to learn how to choose new hardware for your project.

Additionally, I would recommend checking our Partner Network, where you’ll find partners with the expertise needed to solve this issue.

If you face any trouble trying to find a partner, please let us know so we can connect you directly.

Best regards.

Still it is two more year of suppport. By the statement I understand that ESAI on vf61 was never supported in Linux. That is strange as there is explicit definition for ESAI at VF61 in device tree source code https://www.kernel.org/doc/Documentation/devicetree/bindings/sound/fsl%2Cesai.txt It makes me wonder why there is not a single example on the whole Internet how to use VF61’s ESAI in Linux. It must be a single command that would enable the ESAI module. It seems that the chip select of ESAI is not activated despite writing expected value into ESAI’s registry to enable it.

Hi @martin_simek!

Sorry for the delayed response. Were you able to solve the issue?

The kernel version that you’re using (4.4) is not supported anymore, as you can see in this article. The oldest supported kernel is 5.15, which is BSP 6.

That being said, I would recommend you take a look at our Partner Network, where you’ll find people who can address your issue and help you with the development.

Best regards.