Zybo Z7–20 Codec-less I2S Customization Memorandum

Jun OKAMURA
3 min readFeb 18, 2021

--

This is the Codec-less I2S device driver customizing (Petalinux) part of the Zybo Z7–20 audio system project. Appreciated Yuhei Horibe’s literature for Zedboard I2S implementation and many of the Q&A for Zybo+I2S+PL300 DMA on “ADI Engineer Zone”.

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 in MacBook
HW: Xilinx Vivado/Vitis 2020.2
SW: Petalinux 2020.2

Confirm the 32bit I2S out on the Zybo platform

Edit “axi_i2s_adi.vhd” to handle 32bit I2S data on the PL side, then regenerate the “system.bit” file, then rebuild ”BOOT.BIN“ and have confirmed 32bit I2S out data signal, see the last memorandum.

DTS DAI link without SSM2602 codec.

The project needs 32bit I2S in/out on PCOM ports and not expected to use SSM2602 for sound recording and playback, so how to reconfigure “system-user.dtsi” with proper phantom codec driver. Found the article which described to use “bt-sco.c“ generic BT driver as a codec dummy on the Internet and it looks most simple solution.

Add BT-SCO driver from Petalinux menu

petalinux-config -c kernel

Device Driver>Sound card support>Advanced Linux Sound Architecture>ALSA for SoC audio support>CODEC driver

Check Dummy BT SCO codec driver

Edit system-user.dtsi

To register “linux,bt-sco” as codec DAI.

/ {
// 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";
};
sound { // sound/soc/generic/simple-card.c
compatible = "simple-audio-card";
status = "okay";
simple-audio-card,name = "Zybo-Sound-Card";
simple-audio-card,format = "i2s";
simple-audio-card,bitclock-master = <&cpu_dai>;
simple-audio-card,frame-master = <&cpu_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 = <&bt_sco>;
// sound-dai = <&ssm2603>;
clocks = <&misc_clk_0>; // 12288000
};
};
};

Edit bt-sco.c

To handle proper sampling rate and data width.

% diff -c bt-sco.c bt-sco.c_backup 
*** bt-sco.c 2021-02-18 09:46:35.759884946 +0900
--- bt-sco.c_backup 2021-02-18 09:40:22.723862294 +0900
***************
*** 26,41 ****
.playback = {
.stream_name = "Playback",
.channels_min = 1,
! .channels_max = 2,
! .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000,
! .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
},
.capture = {
.stream_name = "Capture",
.channels_min = 1,
! .channels_max = 2,
! .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000,
! .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
},
},
{
--- 26,41 ----
.playback = {
.stream_name = "Playback",
.channels_min = 1,
! .channels_max = 1,
! .rates = SNDRV_PCM_RATE_8000,
! .formats = SNDRV_PCM_FMTBIT_S16_LE,
},
.capture = {
.stream_name = "Capture",
.channels_min = 1,
! .channels_max = 1,
! .rates = SNDRV_PCM_RATE_8000,
! .formats = SNDRV_PCM_FMTBIT_S16_LE,
},
},
{

Build the Linux kernel and BOOT.BIN

% petalinlsux-build -c kernel
% 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 sync

Boot LINUX and login

Confirmed the codec driver mapped to axi_i2s_adi properly and also confirmed 32bit I2S data on the I2S on PMOD port.

--

--

No responses yet