Zybo Z7–20 ADI “axi_i2s_adi.vhd” Master/Slave I2S Configuration Memorandum

Jun OKAMURA
4 min readMar 2, 2021

--

This is the Hardware/Software design (Vivado/Petalinux) part of the Zybo Z7–20 audio system project. I would show how to configure both HW/SW for Master/Slave I2S operation with the ADI’s HDL code which I described in previous memorandums.

The tool environments and preparation

Before starting this project, I have confirmed a LINUX boot on the Zybo Z7–20 Rev. B board with following the tool environments as an initial preparation.

OS: Ubuntu 18.04 LTS on VirtualMachine 6.1 on MacBook Pro
HW: Xilinx Vivado/Vitis 2020.2
SW: Petalinux 2020.2

HW design for Master/Slave operation.

I would like to confirm the I2S loopback operation with Master/Slave mode operation, then import the audio data from the Pmod port on Zybo as RX/Slave and export the audio data to SSM2602 as TX/Master. Put two I2S interfaces one for TX and Master mode, and the other for RX and Slave mode as following;

Synthesize

Synthesize it and make an XSA file for the Petalinux project.

Configure the new Petalinux project

% petalinux-create --type project --template zynq --name Zybo_MS
% cd Zybo_MS
% petalinux-config --get-hw-description ../project_1/<file name>.xsa

Follow Petalinux setup as I described for Zybo Z7–20 in my previous Medium memorandum.

% petalinux-config -c kernel
% petalinux-config -c rootfs

Edit the device-tree file

Edit project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi as following;

There are two axi_i2s_adi IPs on as I2S DAI platforms and need a phantom RX codec for the Pmod port and the SSM2602 as for the TX codec.

/include/ "system-conf.dtsi"
/ {
// https://www.kernel.org/doc/Documentation/devicetree/bindings/sound/simple-card.txt
bt_sco: bt_sco {
#sound-dai-cells = <0>; // only single DAI
compatible = "linux,bt-sco";
status = "okay";
};
sound0 { // sound/soc/generic/simple-card.c
compatible = "simple-audio-card";
status = "okay";
simple-audio-card,name = "Zybo-Sound-Card-TX";
simple-audio-card,format = "i2s";
simple-audio-card,bitclock-master = <&cpu_dai0>;
simple-audio-card,frame-master = <&cpu_dai0>;
cpu_dai0: simple-audio-card,cpu {
sound-dai = <&axi_i2s_adi_0>;
clocks = <&misc_clk_0>;
};
codec_dai0: simple-audio-card,codec {
sound-dai = <&ssm2603>;
clocks = <&misc_clk_0>;
};
};
sound1 { // sound/soc/generic/simple-card.c
compatible = "simple-audio-card";
status = "okay";
simple-audio-card,name = "Zybo-Sound-Card-RX";
simple-audio-card,format = "i2s";
simple-audio-card,bitclock-master = <&codec_dai1>;
simple-audio-card,frame-master = <&codec_dai1>;
//
cpu_dai1: simple-audio-card,cpu {
sound-dai = <&axi_i2s_adi_1>;
clocks = <&misc_clk_0>;
};
//
codec_dai1: simple-audio-card,codec {
sound-dai = <&bt_sco>;
clocks = <&misc_clk_0>;
};
};
};
&misc_clk_0 {
clock-frequency = <12288000>;
};
&axi_i2s_adi_0 {
#sound-dai-cells = <0>; // only single DAI
clock-names = "ref", "axi";
clocks = <&misc_clk_0>, <&clkc 15>;
compatible = "adi,axi-i2s-1.00.a";
dmas = <&dmac_s 0>;
dma-names = "tx";
};
&axi_i2s_adi_1 {
#sound-dai-cells = <0>; // only single DAI
clock-names = "ref", "axi";
clocks = <&misc_clk_0>, <&clkc 15>;
compatible = "adi,axi-i2s-1.00.a";
dmas = <&dmac_s 1>;
dma-names = "rx";
};
&i2c0 {
status = "okay";
ssm2603: ssm2603@1a {
#sound-dai-cells = <0>; // only single DAI
compatible = "adi,ssm2603";
reg = <0x1a>;
};
};

Cannot map a single port on DAI Platform to dual ports on the Codec side then got error messages as following;

So, we need to modify ssm2602.c and bt_sco.c by comment out “.capture” and “.playback” capabilities of both device-driver to only have a single port DAI on the Codec side as well.

Boot LINUX and login

Build the Linux and BOOT.BIN and copy all Kernel images to SD-card, then boot LINUX again and login. Successfully recognized the I2S and Codec, and both Playback and Capture devices are mapped properly.

Connect the USB-I2S board to the Pmod connector then try loopback operation with the following command. Successfully got audio from PC/USB to the Speaker/HPout through Zybo board.

arecord -D hw:1 -c 2 -r 48000 -f S32_LE | aplay
Loopback test

To be continue

--

--