Zybo Z7–20 I2S Slave-Mode Software Reconfiguration Memorandum

Jun OKAMURA
3 min readFeb 26, 2021

--

This is the Software Designing (Petalinux) part of the Zybo Z7–20 audio system project and I have edited the device driver and DTS file to support the I2S slave mode function.

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

Configure the new Petalinux project

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

Follow Petalinux setup as I described for Zybo Z7–20 in my 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;

We need to change BCLK/LRCK master to &codec_dai, then the LINUX sound driver will switch to SND_SOC_DAIFMT_CBM_CFM through SSM2602.c codec driver.

/include/ "system-conf.dtsi"
/ {
// https://www.kernel.org/doc/Documentation/devicetree/bindings/sound/simple-card.txtsound { // sound/soc/generic/simple-card.c
compatible = "simple-audio-card";
simple-audio-card,name = "Zybo-Sound-Card";
simple-audio-card,format = "i2s";
simple-audio-card,bitclock-master = <&codec_dai>;
simple-audio-card,frame-master = <&codec_dai>;
cpu_dai: simple-audio-card,cpu {
sound-dai = <&axi_i2s_adi_0>;
clocks = <&misc_clk_0>; // 12288000
};
codec_dai: simple-audio-card,codec {
sound-dai = <&ssm2603>;
clocks = <&misc_clk_0>; // 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 &dmac_s 1>;
dma-names = "tx", "rx";
};
&i2c0 {
status = "okay";
ssm2603: ssm2603@1a {
#sound-dai-cells = <0>; // only single DAI
compatible = "adi,ssm2603";
reg = <0x1a>;
};
};

Build the Linux and BOOT.BIN

% petalinlsux-build 
% petalinux-package --boot --force --fsbl images/linux/zynq_fsbl.elf --fpga images/linux/system.bit --u-boot

Copy image and rootfs to SD-card

% cd images/linux
% sudo cp BOOT.BIN boot.scr image.ub /media/sdcard/boot/
% sudo tar xf rootfs.tar.gz -C /media/sdcard/root/
% sudo sync

Boot LINUX and login

We could confirm axi_i2s_adi mapped to ssm2602-hifi OK and SSM2602 have properly configured MASTER mode on its reg07 (D6=1).

Now we can play the WAV file with “aplay” or speaker-test” command, I have confirmed the proper I2S signal and format as following.

BCLK/LRCK/DATA at SSM2603 pins.

Note: 32bit wide and Slave-Mode support successfully integrated with both FPGA IP and LINUX sound driver sides. LINUX sound driver can only support only a single L/R channel currently. I may try to increase the channel number for both HDL and LINUX device-driver later.

--

--