Porting ReSpeaker 2-Mics Pi HAT v2 to BeagleY-AI
Porting ReSpeaker 2-Mics Pi HAT v2 to BeagleY-AI
REVISED MAY 2025
Warning
This wiki is wrote for ReSpeaker 2-Mics Pi HAT v2, to distinguish the v1 and v2 device, please refer to How to Distinguish ReSpeaker 2-Mics Pi HAT Hardware Revisions.
Hardware Overview
1. BeagleY-AI
BeagleY® AI is an open-source single board computer designed to simplify the process of building smart human machine interfaces (HMI), adding cameras and high-speed connectivity to a reliable embedded system. It features a powerful 64-bit, quad-core A53 processor, multiple powerful AI accelerators paired with C7x DSPs, integrated 50 GFLOP GPU supporting up to three concurrent display outputs and modern connectivity including USB3.1, PCIe Gen 3, WiFi6 and Bluetooth® Low Energy 5.4.
The board is compatible with a wide range of existing accessories that expand the system functionality such as power over ethernet (PoE), NVMe storage and 5G connectivity.
With its competitive price and user-friendly design, Beagle Y AI provides a positive development experience using BeagleBoard's tried and tested custom Debian Linux image.
2. ReSpeaker 2-Mics Pi HAT v2
Note
The reSpeaker 2-Mics Pi HAT has been upgraded to version 2.0. The codec chip has been replaced from WM8960 to TLV320AIC3104, enabling support for Raspberry Pi 5 and expanding the sampling rate range from 8 kHz to 96 kHz.
ReSpeaker 2-Mics Pi HAT is a dual-microphone expansion board for Raspberry Pi designed for AI and voice applications. You can build a more powerful and flexible voice product that integrates Amazon Alexa Voice Service, Google Assistant, and so on.
Setup Process
1. Bootable SD Card Preparation
Create a bootable microSD card with latest/recommended OS image for BeagleY-AI. BeagleY-AI Quick Start
2. Kernel Driver Compilation
Note
The BeagleY-AI typically comes with the tlv320aic31xx codec driver. If the snd-soc-tlv320aic31xx.ko.xz file is missing, try updating and upgrading your system using the command: sudo apt update && sudo apt upgrade
If the driver still does not exist after updating, follow the steps below to build it from source. If the file is present, you can skip this step and proceed directly to the “Load Device Tree” section.
# default configuration
# config camera
# -> Device Drivers
# -> Sound card support
# -> Advance Linux Sound Architecture
# -> ALSA for SoC audio support
# -> CODEC drivers
# -> Texas Instruments TLV320AIC31xx CODECs
# Set "TLV320AIC31xx" to module,
# Press "m", save to original name (.config) and exit
Plug in the SD card which burned in” Create a bootable microSD card” to PC.
Install onto the SD card:
# you can use "make kernelversion" to check kernel version
Boot BeagleY-AI with SD card.
Device Tree Configuration
Get compiled Device Tree Source (DTS):
# Download the compiled Device Tree Source (DTS)
# Move the .dtbo file to /boot/firmware/overlays/
Load Device Tree Configuration:
Add the overlay to label microSD (default) and append fdtoverlays /overlays/k3-am67a-beagley-ai-respeaker.dtbo
after the fdt line.
To use the LEDs, you need enable SPI interface first. To enable SPI interface, open the BeagleY-AI /boot/firmware/extlinux/extlinux.conf
> label )
> kernel
> append console=ttyS2,115200n8 root=/dev/mmcblk1p3
> fdtdir
> fdt
> fdtoverlays
> initrd
Restart:
Basic Recording & Playback
Use aplay -l
to list the playback device and arecord -l
to list the recording device.
Record mono audio (16-bit, 16kHz):
Note
Why plughw?The ReSpeaker HAT's hardware
(hw:0,0)
natively supports stereo input only.plughw automatically converts the stereo stream to mono by averaging channels.
Record stereo audio (16-bit, 48kHz):
Playback recorded audio:
Record Sound with Python:
We use PyAudio python library to record sound with Python.First, run the following script to get the device index number of ReSpeaker
To record the sound, open recording_examples/record_stero.py
file with nano, vim or other text editor and change RESPEAKER_INDEX = 1
to index number of ReSpeaker on your system. Then run python script record_stero.py
to make a recording:
On-board User LEDs and Button
Setup
Run python interfaces/pixels.py
to test the LEDs.
Run python interfaces/button.py
to test the button.
Full porting process and documentation
Post on hackster Porting the ReSpeaker 2-Mics Pi HAT v2 to BeagleY-AI with an application example keyword spotting