MCUXpresso SDK Documentation

sai_low_power_audio_rtos_imx95

sai_low_power_audio_rtos_imx95#

Overview#

In this demo, A core decoded music data and put it to DDR buffer and informs M core with the related information. Then M core will take the ownership of consuming the buffer, it will copy buffer from DDR to TCM, manipulating EDMA4 to transfer the data to SAI and codec for playback. It gives DDR and A core opportunity to do power saving for rather long time frame. M core will also take ownership of codec initialization. SRTM(Simplified Real Time Messaging) protocol is used to communicate between A core and M core. The protocol provides various commands for A core and M core to communicate with each other. If there is no audio palyback, M core will enter the STOP mode, and the whole SOC system would enter deep sleep mode(DSM) once A core enter low power status.

Supported Boards#

IMX95LPD5EVK-19
Hardware requirements
  • USB Type-C cable

  • IMX95LPD5-EVK board

  • J-Link Debug Probe

  • 12V~20V power supply

  • Personal Computer

  • Headphone

Board settings

No special settings are required.

Note!

  1. This case does not support ddr and flash target.

Prepare the Demo
  1. Connect 12V~20V power supply and J-Link Debug Probe to the board, switch SW301 to power on the board.

  2. Connect a USB Type-C cable between the host PC and the J1401 USB port on the target board.

  3. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Load flash.bin file with sm as rpmsg config before starting the demo to ensure that the permissions of M7 involved in the demo are allowed. Build in imx-sm repo: make SOC=iMX95 flash_a55 LPDDR_TYPE=lpddr5 OEI=YES MSEL=1.

  5. Make sure the FDT file and key bootargs are correctly set before booting the linux kernel. Following is the example commands on A core U-Boot console: =>setenv fdtfile imx95-19x19-evk-rpmsg.dtb =>setenv mmcargs ‘setenv bootargs ${jh_clk} console=${console} root=${mmcroot} snd_pcm.max_alloc_per_card=134217728 pd_ignore_unused clk_ignore_unused’ =>saveenv

  6. Boot Linux BSP to u-boot, and load M core image from SD card to run. (Put the image into SD card device before) load mmc 1:1 0x90400000 imx95-19x19-evk_m7_TCM_sai_low_power_audio.bin; cp.b 0x90400000 0x203c0000 0x40000; bootaux 0x00000000 1;


NOTE


  1. The 16/24/32bits for PCM Music stream are supported.

  2. Since the music files are typically large, users could create a new large size partition in the SD card to place the music files.

  3. Please make sure audio file (such as xxx.wav) in any filesystem that Linux can access.


Playback command


Note:

  1. Please use the command “cat /proc/asound/cards” to check the wm8962 sound card number (on A core Linux console). E.g: Type command: ~# cat /proc/asound/cards The available sound cards can be shown: 0 [wm8962audio ]: wm8962-audio - wm8962-audio wm8962-audio 1 [micfilaudio ]: micfil-audio - micfil-audio micfil-audio

Then the wm8962 sound card number is 0.

When playback the .wav file (on A Core Linux console):

  1. If you want to playback with pause/resume command, below command can be used: “aplay -Dhw:0 xxx.wav -N”; press space key on the keyboard to pause, and press the space key again to resume.

  2. 95 board supports audio format of S16/S24/S32, and sample rates could be 32kHz, 48kHz, 96kHz and 44.1kHz.

  3. If want to playback with low power mode and specified period-size, could use command: “aplay -Dhw:0 –buffer-size=xxx –period-size=xxx xxx.wav -N &” or “aplay -Dhw:0 –buffer-time=xxx –period-time=xxx xxx.wav -N &”. E.g: “aplay -Dhw:0 –period-time=500000 –buffer-time=10000000 xxx.wav -N &” Now please use “echo mem > /sys/power/state” command to make A core enter suspend mode and the playback work normally. Note, make sure the A core has enough time to fill the audio buffer before going into suspend mode.

When recording sound, could use command: arecord -Dhw:0,0 -c2 -r48000 -fS32_LE test.wav 4. you can use below command to run record and play at the same time. arecord -Dhw:1 -r16000 -c2 -fS32_LE -traw | aplay -Dplughw:wm8962audio -r16000 –period-size=4096 -c2 -fS32_LE -traw

Running the demo

#################### LOW POWER AUDIO TASK ####################

Build Time: Apr 19 2024--15:11:38

Start SRTM communication


Wait the Linux kernel boot up to create the link between M core and A core.


Handle Peer Core Linkup The rpmsg channel between M core and A core created!


Task A is working now.

IMX952-EVK
Hardware requirements
  • USB Type-C cable

  • IMX952-EVK board

  • J-Link Debug Probe

  • 12V~20V power supply

  • Personal Computer

  • Headphone

Board settings

No special settings are required.

Note!
  1. This case does not support ddr and flash target.

Prepare the Demo
  1. Connect 12V~20V power supply and J-Link Debug Probe to the board, switch SW301 to power on the board.

  2. Connect a USB Type-C cable between the host PC and the J1401 USB port on the target board.

  3. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Load flash.bin file with sm rpmsg config before starting the demo to ensure that the permissions of M7 involved in the demo are allowed.

  5. Make sure the FDT file and key bootargs are correctly set before booting the linux kernel. Following is the example commands on A core U-Boot console: =>setenv fdtfile imx952-evk-rpmsg.dtb =>setenv mmcargs ‘setenv bootargs ${jh_clk} console=${console} root=${mmcroot} snd_pcm.max_alloc_per_card=134217728 pd_ignore_unused clk_ignore_unused’ =>saveenv

  6. Boot Linux BSP to u-boot, and load M core image from SD card to run. (Put the image into SD card device before) load mmc 1:1 0x90400000 imx952-19x19-evk_m7_TCM_sai_low_power_audio.bin; cp.b 0x90400000 0x203c0000 0x40000; bootaux 0x00000000 1;


NOTE


  1. The 16/24/32bits for PCM Music stream are supported.

  2. Since the music files are typically large, users could create a new large size partition in the SD card to place the music files.

  3. Please make sure audio file (such as xxx.wav) in any filesystem that Linux can access.


Playback command


Note:

  1. Please use the command “cat /proc/asound/cards” to check the wm8962 sound card number (on A core Linux console). E.g: Type command: ~# cat /proc/asound/cards The available sound cards can be shown: 0 [wm8962audio ]: wm8962-audio - wm8962-audio wm8962-audio 1 [micfilaudio ]: micfil-audio - micfil-audio micfil-audio

Then the wm8962 sound card number is 0.

When playback the .wav file (on A Core Linux console):

  1. If you want to playback with pause/resume command, below command can be used: “aplay -Dhw:0 xxx.wav -N”; press space key on the keyboard to pause, and press the space key again to resume.

  2. 95 board supports audio format of S16/S24/S32, and sample rates could be 32kHz, 48kHz, 96kHz and 44.1kHz.

  3. If want to playback with low power mode and specified period-size, could use command: “aplay -Dhw:0 –buffer-size=xxx –period-size=xxx xxx.wav -N &” or “aplay -Dhw:0 –buffer-time=xxx –period-time=xxx xxx.wav -N &”. E.g: “aplay -Dhw:0 –period-time=500000 –buffer-time=10000000 xxx.wav -N &” Now please use “echo mem > /sys/power/state” command to make A core enter suspend mode and the playback work normally. Note, make sure the A core has enough time to fill the audio buffer before going into suspend mode.

When recording sound, could use command: arecord -Dhw:0,0 -c2 -r48000 -fS32_LE test.wav 4. you can use below command to run record and play at the same time. arecord -Dhw:1 -r16000 -c2 -fS32_LE -traw | aplay -Dplughw:wm8962audio -r16000 –period-size=4096 -c2 -fS32_LE -traw

Running the demo

#################### LOW POWER AUDIO TASK ####################

Build Time: Apr 19 2024--15:11:38

Start SRTM communication


Wait the Linux kernel boot up to create the link between M core and A core.


Handle Peer Core Linkup The rpmsg channel between M core and A core created!


Task A is working now.