Port 2mic respeaker to Armbian on RockPi 4b

This commit is contained in:
Paul van der Linden 2022-06-09 18:33:16 +09:30
parent c52606626d
commit f7ed8905fe
7 changed files with 137 additions and 386 deletions

View File

@ -1,67 +1,25 @@
# seeed-voicecard
# seeed-voicecard-rockpi-armbian
The drivers for [ReSpeaker Mic Hat](https://www.seeedstudio.com/ReSpeaker-2-Mics-Pi-HAT-p-2874.html), [ReSpeaker 4 Mic Array](https://www.seeedstudio.com/ReSpeaker-4-Mic-Array-for-Raspberry-Pi-p-2941.html), [6-Mics Circular Array Kit](), and [4-Mics Linear Array Kit]() for Raspberry Pi.
This is a fork of https://github.com/respeaker/seeed-voicecard to support Armbian runnong on RockPi 4b.
Requirements:
- Armbian RockPi linux version 21.05.4 (linux kernel 5.10.43-rockchip64)
Note that only the ReSpeaker Mic Hat (2-mic) is correct at this stage.
The original provides drivers for [ReSpeaker Mic Hat](https://www.seeedstudio.com/ReSpeaker-2-Mics-Pi-HAT-p-2874.html), [ReSpeaker 4 Mic Array](https://www.seeedstudio.com/ReSpeaker-4-Mic-Array-for-Raspberry-Pi-p-2941.html), [6-Mics Circular Array Kit](), and [4-Mics Linear Array Kit]() for Raspberry Pi.
Only the driver for the ReSpeaker Mic Hat has been ported correctly at this stage.
### Install seeed-voicecard
Get the seeed voice card source code and install all linux kernel drivers
```bash
git clone https://github.com/respeaker/seeed-voicecard
cd seeed-voicecard
sudo ./install.sh
sudo ./install_arm64.sh
sudo reboot
```
**Note** If you have 64-bit version of Rasperry Pi OS, use install_arm64.sh script for driver installation.
## ReSpeaker Documentation
Up to date documentation for reSpeaker products can be found in [Seeed Studio Wiki](https://wiki.seeedstudio.com/ReSpeaker/)!
![](https://files.seeedstudio.com/wiki/ReSpeakerProductGuide/img/Raspberry_Pi_Mic_Array_Solutions.png)
### Coherence
Estimate the magnitude squared coherence using Welchs method.
![4-mics-linear-array-kit coherence](https://user-images.githubusercontent.com/3901856/37277486-beb1dd96-261f-11e8-898b-84405bfc7cea.png)
Note: 'CO 1-2' means the coherence between channel 1 and channel 2.
```bash
# How to get the coherence of the captured audio(a.wav for example).
sudo apt install python-numpy python-scipy python-matplotlib
python tools/coherence.py a.wav
# Requirement of the input audio file:
- format: WAV(Microsoft) signed 16-bit PCM
- channels: >=2
```
### uninstall seeed-voicecard
If you want to upgrade the driver , you need uninstall the driver first.
```
pi@raspberrypi:~/seeed-voicecard $ sudo ./uninstall.sh
...
------------------------------------------------------
Please reboot your raspberry pi to apply all settings
Thank you!
------------------------------------------------------
```
Enjoy !
### Technical support
For hardware testing purposes we made a Rasperry Pi OS 5.10.17-v7l+ 32-bit image with reSpeaker drivers pre-installed, which you can download by clicking on [this link](https://files.seeedstudio.com/linux/Raspberry%20Pi%204%20reSpeaker/2021-05-07-raspios-buster-armhf-lite-respeaker.img.xz).
We provide official support for using reSpeaker with the following OS:
- 32-bit Raspberry Pi OS
- 64-bit Raspberry Pi OS (experimental support)
And following hardware platforms:
- Raspberry Pi 3 (all models), Raspberry Pi 4 (all models), Raspberry Pi Zero and Zero W
Anything beyond the scope of official support is considered to be community supported. Support for other OS/hardware platforms can be added, provided MOQ requirements can be met.
If you have a technical problem when using reSpeaker with one of the officially supported platforms/OS, feel free to create an issue on Github. For general questions or suggestions, please use [Seeed forum](https://forum.seeedstudio.com/c/products/respeaker/15).
See [Original seeed-voicecard](https://github.com/respeaker/seeed-voicecard) for additional information.

View File

@ -1,232 +0,0 @@
#!/bin/bash
# Color
RED='\033[0;31m'
NC='\033[0m' # No Color
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root (use sudo)" 1>&2
exit 1
fi
# Check for enough space on /boot volume
boot_line=$(df -h | grep /boot | head -n 1)
if [ "x${boot_line}" = "x" ]; then
echo "Warning: /boot volume not found .."
else
boot_space=$(echo $boot_line | awk '{print $4;}')
free_space=$(echo "${boot_space%?}")
unit="${boot_space: -1}"
if [[ "$unit" = "K" ]]; then
echo "Error: Not enough space left ($boot_space) on /boot"
exit 1
elif [[ "$unit" = "M" ]]; then
if [ "$free_space" -lt "25" ]; then
echo "Error: Not enough space left ($boot_space) on /boot"
exit 1
fi
fi
fi
#
# make sure that we are on something ARM/Raspberry related
# either a bare metal Raspberry or a qemu session with
# Raspberry stuff available
# - check for /boot/overlays
# - dtparam and dtoverlay is available
errorFound=0
OVERLAYS=/boot/overlays
[ -d /boot/firmware/overlays ] && OVERLAYS=/boot/firmware/overlays
if [ ! -d $OVERLAYS ] ; then
echo "$OVERLAYS not found or not a directory" 1>&2
errorFound=1
fi
# should we also check for alsactl and amixer used in seeed-voicecard?
PATH=$PATH:/opt/vc/bin
for cmd in dtparam dtoverlay ; do
if ! which $cmd &>/dev/null ; then
echo "$cmd not found" 1>&2
echo "You may need to run ./ubuntu-prerequisite.sh"
errorFound=1
fi
done
if [ $errorFound = 1 ] ; then
echo "Errors found, exiting." 1>&2
exit 1
fi
ver="0.3"
uname_r=$(uname -r)
# we create a dir with this version to ensure that 'dkms remove' won't delete
# the sources during kernel updates
marker="0.0.0"
_VER_RUN=
function get_kernel_version() {
local ZIMAGE IMG_OFFSET
_VER_RUN=""
[ -z "$_VER_RUN" ] && {
ZIMAGE=/boot/kernel.img
[ -f /boot/firmware/vmlinuz ] && ZIMAGE=/boot/firmware/vmlinuz
IMG_OFFSET=$(LC_ALL=C grep -abo $'\x1f\x8b\x08\x00' $ZIMAGE | head -n 1 | cut -d ':' -f 1)
_VER_RUN=$(dd if=$ZIMAGE obs=64K ibs=4 skip=$(( IMG_OFFSET / 4)) 2>/dev/null | zcat | grep -a -m1 "Linux version" | strings | awk '{ print $3; }')
}
echo "$_VER_RUN"
return 0
}
function check_kernel_headers() {
VER_RUN=$(get_kernel_version)
VER_HDR=$(dpkg -L raspberrypi-kernel-headers | egrep -m1 "/lib/modules/[^-]+/build" | awk -F'/' '{ print $4; }')
[ "X$VER_RUN" == "X$VER_HDR" ] && {
return 0
}
VER_HDR=$(dpkg -L linux-headers-$VER_RUN | egrep -m1 "/lib/modules/[[:print:]]+/build" | awk -F'/' '{ print $4; }')
[ "X$VER_RUN" == "X$VER_HDR" ] && {
return 0
}
# echo RUN=$VER_RUN HDR=$VER_HDR
echo " !!! Your kernel version is $VER_RUN"
echo " Not found *** corresponding *** kernel headers with apt-get."
echo " This may occur if you have ran 'rpi-update'."
echo " Choose *** y *** will revert the kernel to version $VER_HDR then continue."
echo " Choose *** N *** will exit without this driver support, by default."
read -p "Would you like to proceed? (y/N)" -n 1 -r -s
echo
if ! [[ $REPLY =~ ^[Yy]$ ]]; then
exit 1;
fi
apt-get -y --reinstall install raspberrypi-kernel
}
# update and install required packages
which apt &>/dev/null
if [[ $? -eq 0 ]]; then
apt update -y
# Raspbian kernel packages
apt-get -y install raspberrypi-kernel-headers raspberrypi-kernel
# Ubuntu kernel packages
apt-get -y install linux-raspi linux-headers-raspi linux-image-raspi
apt-get -y install dkms git i2c-tools libasound2-plugins
# rpi-update checker
check_kernel_headers
fi
# Arch Linux
which pacman &>/dev/null
if [[ $? -eq 0 ]]; then
pacman -Syu --needed git gcc automake make dkms linux-raspberrypi-headers i2c-tools
fi
# locate currently installed kernels (may be different to running kernel if
# it's just been updated)
base_ver=$(get_kernel_version)
base_ver=${base_ver%%[-+]*}
#kernels="${base_ver}+ ${base_ver}-v7+ ${base_ver}-v7l+"
kernels=$(uname -r)
kernel_base_ver=${kernels%%[-+]*}
if [[ "$base_ver" != "$kernel_base_ver" ]] ; then
echo "------------------------------------------------------"
echo -e " ${RED}WARNING${NC} Your loaded kernel version is $kernel_base_ver"
echo " Not matching the updated version $base_ver."
echo " Kernel was updated, but new kernel was not loaded yet"
echo -e " Please ${RED}reboot${NC} your machine AND THEN run this script ${RED}again"
exit 1;
fi
function install_module {
local _i
src=$1
mod=$2
if [[ -d /var/lib/dkms/$mod/$ver/$marker ]]; then
rmdir /var/lib/dkms/$mod/$ver/$marker
fi
if [[ -e /usr/src/$mod-$ver || -e /var/lib/dkms/$mod/$ver ]]; then
dkms remove --force -m $mod -v $ver --all
rm -rf /usr/src/$mod-$ver
fi
mkdir -p /usr/src/$mod-$ver
cp -a $src/* /usr/src/$mod-$ver/
dkms add -m $mod -v $ver
for _i in $kernels; do
dkms build -k $_i -m $mod -v $ver && {
dkms install --force -k $_i -m $mod -v $ver
}
done
mkdir -p /var/lib/dkms/$mod/$ver/$marker
}
install_module "./" "seeed-voicecard"
# install dtbos
cp seeed-2mic-voicecard.dtbo $OVERLAYS
cp seeed-4mic-voicecard.dtbo $OVERLAYS
cp seeed-8mic-voicecard.dtbo $OVERLAYS
#install alsa plugins
# no need this plugin now
# install -D ac108_plugin/libasound_module_pcm_ac108.so /usr/lib/arm-linux-gnueabihf/alsa-lib/
rm -f /usr/lib/arm-linux-gnueabihf/alsa-lib/libasound_module_pcm_ac108.so
#set kernel modules
grep -q "^snd-soc-seeed-voicecard$" /etc/modules || \
echo "snd-soc-seeed-voicecard" >> /etc/modules
grep -q "^snd-soc-ac108$" /etc/modules || \
echo "snd-soc-ac108" >> /etc/modules
grep -q "^snd-soc-wm8960$" /etc/modules || \
echo "snd-soc-wm8960" >> /etc/modules
#set dtoverlays
CONFIG=/boot/config.txt
[ -f /boot/firmware/usercfg.txt ] && CONFIG=/boot/firmware/usercfg.txt
sed -i -e 's:#dtparam=i2c_arm=on:dtparam=i2c_arm=on:g' $CONFIG || true
grep -q "^dtoverlay=i2s-mmap$" $CONFIG || \
echo "dtoverlay=i2s-mmap" >> $CONFIG
grep -q "^dtparam=i2s=on$" $CONFIG || \
echo "dtparam=i2s=on" >> $CONFIG
#install config files
mkdir /etc/voicecard || true
cp *.conf /etc/voicecard
cp *.state /etc/voicecard
#create git repo
git_email=$(git config --global --get user.email)
git_name=$(git config --global --get user.name)
if [ "x${git_email}" == "x" ] || [ "x${git_name}" == "x" ] ; then
echo "setup git config"
git config --global user.email "respeaker@seeed.cc"
git config --global user.name "respeaker"
fi
echo "git init"
git --git-dir=/etc/voicecard/.git init
echo "git add --all"
git --git-dir=/etc/voicecard/.git --work-tree=/etc/voicecard/ add --all
echo "git commit -m \"origin configures\""
git --git-dir=/etc/voicecard/.git --work-tree=/etc/voicecard/ commit -m "origin configures"
cp seeed-voicecard /usr/bin/
cp seeed-voicecard.service /lib/systemd/system/
systemctl enable seeed-voicecard.service
systemctl start seeed-voicecard
echo "------------------------------------------------------"
echo "Please reboot your raspberry pi to apply all settings"
echo "Enjoy!"
echo "------------------------------------------------------"

View File

@ -9,8 +9,8 @@ if [[ $EUID -ne 0 ]]; then
exit 1
fi
# Check for enough space on /boot volume
boot_line=$(df -h | grep /boot | head -n 1)
# Check for enough space on / volume
boot_line=$(df -h | grep / | head -n 1)
if [ "x${boot_line}" = "x" ]; then
echo "Warning: /boot volume not found .."
else
@ -29,13 +29,12 @@ else
fi
#
# make sure that we are on something ARM/Raspberry related
# either a bare metal Raspberry or a qemu session with
# Raspberry stuff available
# - check for /boot/overlays
# make sure that we are on something Armbian/RockPi related
# Armbian/RockPi stuff available
# - check for /boot/overlay-user
# - dtparam and dtoverlay is available
errorFound=0
OVERLAYS=/boot/overlays
OVERLAYS=/boot/overlay-user
[ -d /boot/firmware/overlays ] && OVERLAYS=/boot/firmware/overlays
if [ ! -d $OVERLAYS ] ; then
@ -44,7 +43,7 @@ if [ ! -d $OVERLAYS ] ; then
fi
# should we also check for alsactl and amixer used in seeed-voicecard?
PATH=$PATH:/opt/vc/bin
for cmd in dtparam dtoverlay ; do
for cmd in alsactl amixer ; do
if ! which $cmd &>/dev/null ; then
echo "$cmd not found" 1>&2
echo "You may need to run ./ubuntu-prerequisite.sh"
@ -64,68 +63,53 @@ uname_r=$(uname -r)
# the sources during kernel updates
marker="0.0.0"
COMPAT_KERNEL_VER="5.10.43"
COMPAT_PACKAGE_VER="21.05.4"
_VER_RUN=
function get_kernel_version() {
local ZIMAGE IMG_OFFSET
_VER_RUN=""
[ -z "$_VER_RUN" ] && {
ZIMAGE=/boot/kernel8.img
[ -f /boot/firmware/vmlinuz ] && ZIMAGE=/boot/firmware/vmlinuz
IMG_OFFSET=$(LC_ALL=C grep -abo $'\x1f\x8b\x08\x00' $ZIMAGE | head -n 1 | cut -d ':' -f 1)
_VER_RUN=$(dd if=$ZIMAGE obs=64K ibs=4 skip=$(( IMG_OFFSET / 4)) 2>/dev/null | zcat | grep -a -m1 "Linux version" | strings | awk '{ print $3; }')
}
_VER_RUN=`uname -r`
echo "$_VER_RUN"
return 0
}
function check_kernel_headers() {
VER_RUN=$(get_kernel_version)
VER_HDR=$(dpkg -L raspberrypi-kernel-headers | egrep -m1 "/lib/modules/[[:print:]]+/build" | awk -F'/' '{ print $4; }')
echo $VER_RUN
echo $VER_HDR
[ "X$VER_RUN" == "X$VER_HDR" ] && {
return 0
}
VER_HDR=$(dpkg -L linux-headers-$VER_RUN | egrep -m1 "/lib/modules/[[:print:]]+/build" | awk -F'/' '{ print $4; }')
VER_HDR=$(dpkg -L linux-headers-current-rockchip64 | egrep -m1 "/lib/modules/[[:print:]]+/build" | awk -F'/' '{ print $4; }')
echo $VER_RUN
echo $VER_HDR
[ "X$VER_RUN" == "X$VER_HDR" ] && {
return 0
}
# echo RUN=$VER_RUN HDR=$VER_HDR
echo " !!! Your kernel version is $VER_RUN"
echo " Not found *** corresponding *** kernel headers with apt-get."
echo " This may occur if you have ran 'rpi-update'."
echo " Choose *** y *** will revert the kernel to version $VER_HDR then continue."
echo " Choose *** N *** will exit without this driver support, by default."
read -p "Would you like to proceed? (y/N)" -n 1 -r -s
echo
if ! [[ $REPLY =~ ^[Yy]$ ]]; then
exit 1;
fi
# Only compatible with kernel version
[ "X$VER_RuN" == "X${COMPAT_KERNEL_VER}"] && {
return 0
}
apt-get -y --reinstall install raspberrypi-kernel
apt-get -y --reinstall install linux-headers-current-rockchip64=$(COMPAT_PACKAGE_VER) linux-image-current-rockchip64=$(COMPAT_PACKAGE_VER)
echo 'Please reboot to load new kernel and re-run this script'
}
# update and install required packages
which apt &>/dev/null
if [[ $? -eq 0 ]]; then
# apt update -y
# Raspbian kernel packages
apt-get -y install raspberrypi-kernel-headers raspberrypi-kernel
# Ubuntu kernel packages
apt-get -y install linux-raspi linux-headers-raspi linux-image-raspi
# Armbian RockPi kernel packages
apt-get -y install linux-headers-current-rockchip64=21.05.4 linux-image-current-rockchip64=21.05.4
apt-get -y install dkms git i2c-tools libasound2-plugins
# rpi-update checker
# update checker
check_kernel_headers
fi
# Arch Linux
which pacman &>/dev/null
if [[ $? -eq 0 ]]; then
pacman -Syu --needed git gcc automake make dkms linux-raspberrypi-headers i2c-tools
pacman -Syu --needed git gcc automake make dkms linux-headers-current-rockchip64 i2c-tools
fi
# locate currently installed kernels (may be different to running kernel if
@ -175,10 +159,10 @@ function install_module {
install_module "./" "seeed-voicecard"
# install dtbos
cp seeed-2mic-voicecard.dtbo $OVERLAYS
cp seeed-4mic-voicecard.dtbo $OVERLAYS
cp seeed-8mic-voicecard.dtbo $OVERLAYS
# install dts overlays
armbian-add-overlay seeed-2mic-voicecard-overlay.dts
# armbian-add-overlay seeed-4mic-voicecard-overlay.dts
# armbian-add-overlay seeed-8mic-voicecard-overlay.dts
#install alsa plugins
# no need this plugin now
@ -194,17 +178,29 @@ grep -q "^snd-soc-wm8960$" /etc/modules || \
echo "snd-soc-wm8960" >> /etc/modules
#set dtoverlays
CONFIG=/boot/config.txt
CONFIG=/boot/armbianEnv.txt
[ -f /boot/firmware/usercfg.txt ] && CONFIG=/boot/firmware/usercfg.txt
# check that i2c7 is enabled
I2C7=`sed -rn 's/^.*overlays=.*(i2c7).*$/\1/p' $CONFIG`
if [[ -z $I2C7 ]]; then
echo 'i2c7 is not enabled. You may need to enable this in armbian-config?'
exit 1
fi
sed -i -e 's:#dtparam=i2c_arm=on:dtparam=i2c_arm=on:g' $CONFIG || true
grep -q "^dtoverlay=i2s-mmap$" $CONFIG || \
echo "dtoverlay=i2s-mmap" >> $CONFIG
grep -q "^dtparam=i2s=on$" $CONFIG || \
echo "dtparam=i2s=on" >> $CONFIG
grep -q "^param_spidev_spi_bus=1$" $CONFIG || \
echo "param_spidev_spi_bus=1" >> $CONFIG
grep -q "^param_spidev_spi_bus=1$" $CONFIG || \
echo "param_spidev_spi_bus=1" >> $CONFIG
#install config files
mkdir /etc/voicecard || true
cp *.conf /etc/voicecard
@ -225,12 +221,13 @@ git --git-dir=/etc/voicecard/.git --work-tree=/etc/voicecard/ add --all
echo "git commit -m \"origin configures\""
git --git-dir=/etc/voicecard/.git --work-tree=/etc/voicecard/ commit -m "origin configures"
cp seeed-voicecard /usr/bin/
cp seeed-voicecard.service /lib/systemd/system/
systemctl enable seeed-voicecard.service
systemctl start seeed-voicecard
# We don't want a service updating this every time
# cp seeed-voicecard /usr/bin/
# cp seeed-voicecard.service /lib/systemd/system/
# systemctl enable seeed-voicecard.service
# systemctl start seeed-voicecard
echo "------------------------------------------------------"
echo "Please reboot your raspberry pi to apply all settings"
echo "Please reboot your Rock Pi to apply all settings"
echo "Enjoy!"
echo "------------------------------------------------------"

View File

@ -2,27 +2,43 @@
/plugin/;
/ {
compatible = "brcm,bcm2708";
compatible = "rockchip,rk3399";
fragment@0 {
target = <&i2s>;
target = <&i2s0>;
__overlay__ {
status = "disabled";
};
};
fragment@1 {
target = <&i2s1>;
__overlay__ {
status = "okay";
};
};
fragment@1 {
fragment@2 {
target = <&i2s2>;
__overlay__ {
status = "disabled";
};
};
fragment@3 {
target-path="/";
__overlay__ {
wm8960_mclk: wm8960_mclk {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <12288000>;
clock-frequency = <24000000>;
};
};
};
fragment@2 {
target = <&i2c1>;
fragment@4 {
target = <&i2c7>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
@ -32,20 +48,21 @@
compatible = "wlf,wm8960";
reg = <0x1a>;
#sound-dai-cells = <0>;
AVDD-supply = <&vdd_5v0_reg>;
DVDD-supply = <&vdd_3v3_reg>;
AVDD-supply = <&vcc5v0_sys>;
DVDD-supply = <&vcc3v3_sys>;
};
};
};
fragment@3 {
target = <&sound>;
slave_overlay: __overlay__ {
fragment@5 {
target-path = "/";
__overlay__ {
sound_overlay: i2s-sound {
compatible = "simple-audio-card";
simple-audio-card,format = "i2s";
simple-audio-card,name = "seeed-2mic-voicecard";
status = "okay";
simple-audio-card,mclk-fs = <0x100>;
simple-audio-card,widgets =
"Microphone", "Mic Jack",
"Line", "Line In",
@ -62,23 +79,27 @@
"RINPUT1", "Mic Jack",
"RINPUT2", "Mic Jack";
simple-audio-card,cpu {
sound-dai = <&i2s>;
sound-dai = <&i2s1>;
};
dailink0_slave: simple-audio-card,codec {
sound-dai = <&wm8960>;
clocks = <&wm8960_mclk>;
clock-names = "mclk";
};
};
};
};
fragment@6 {
target = <&spi1>;
__overlay__ {
status = "okay";
};
};
__overrides__ {
alsaname = <&slave_overlay>,"simple-audio-card,name";
alsaname = <&sound_overlay>,"simple-audio-card,name";
compatible = <&wm8960>,"compatible";
master = <0>,"=2!3";
};

View File

@ -1,11 +1,15 @@
/dts-v1/;
/plugin/;
/* Not working
Adapted from https://github.com/respeaker/seeed-voicecard/seeed-4mic-voicecard-overlay.dts
*/
/ {
compatible = "brcm,bcm2708";
compatible = "rockchip,rk3399";
fragment@0 {
target = <&i2s>;
target = <&i2s1>;
__overlay__ {
#sound-dai-cells = <0>;
status = "okay";
@ -24,7 +28,7 @@
};
fragment@2 {
target = <&i2c1>;
target = <&i2c7>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
@ -41,7 +45,7 @@
fragment@3 {
target = <&sound>;
target-path = "/sound";
sound_overlay: __overlay__ {
compatible = "seeed-voicecard";
@ -55,7 +59,7 @@
seeed-voice-card,channels-capture-override = <4>;
cpu_dai: seeed-voice-card,cpu {
sound-dai = <&i2s>;
sound-dai = <&i2s1>;
dai-tdm-slot-num = <2>;
dai-tdm-slot-width = <32>;
dai-tdm-slot-tx-mask = <1 1 0 0>;
@ -72,4 +76,3 @@
card-name = <&sound_overlay>,"seeed-voice-card,name";
};
};

View File

@ -1,11 +1,16 @@
/dts-v1/;
/plugin/;
/* Not working
Adapted from https://github.com/respeaker/seeed-voicecard/seeed-8mic-voicecard-overlay.dts
*/
/ {
compatible = "brcm,bcm2708";
compatible = "rockchip,rk3399";
fragment@0 {
target = <&i2s>;
target = <&i2s1>;
__overlay__ {
#sound-dai-cells = <0>;
status = "okay";
@ -24,8 +29,9 @@
};
fragment@2 {
target = <&gpio>;
target = <&gpio1>;
__overlay__ {
status = "okay";
spk_amp_pins: spk_pins {
brcm,pins = <17 22>;
brcm,function = <1 0>; /* out in */
@ -50,8 +56,8 @@
compatible = "x-power,ac101";
pinctrl-names = "default";
pinctrl-0 = <&spk_amp_pins &gpclk0_pins>;
spk-amp-switch-gpios = <&gpio 17 0>;
switch-irq-gpios = <&gpio 22 0>;
spk-amp-switch-gpios = <&gpio1 17 0>;
switch-irq-gpios = <&gpio1 22 0>;
reg = <0x1a>;
#sound-dai-cells = <0>;
};
@ -75,8 +81,7 @@
};
fragment@4 {
target = <&sound>;
target-path = "/sound";
sound_overlay: __overlay__ {
compatible = "seeed-voicecard";
seeed-voice-card,name = "seeed-8mic-voicecard";
@ -95,7 +100,7 @@
reg = <0>;
cpu {
sound-dai = <&i2s>;
sound-dai = <&i2s1>;
dai-tdm-slot-num = <2>;
dai-tdm-slot-width = <32>;
dai-tdm-slot-tx-mask = <1 1 0 0>;

View File

@ -24,8 +24,7 @@ set -x
#exec 1>/var/log/$(basename $0).log 2>&1
export PATH=$PATH:/opt/vc/bin
OVERLAYS=/boot/overlays
[ -d /boot/firmware/overlays ] && OVERLAYS=/boot/firmware/overlays
OVERLAYS=/boot/overlay-user
#enable i2c interface
dtparam -d $OVERLAYS i2c_arm=on
@ -40,7 +39,7 @@ function get_kernel_version() {
_VER_RUN=""
[ -z "$_VER_RUN" ] && {
ZIMAGE=/boot/kernel.img
ZIMAGE=/boot/Image
IMG_OFFSET=$(LC_ALL=C grep -abo $'\x1f\x8b\x08\x00' $ZIMAGE | head -n 1 | cut -d ':' -f 1)
_VER_RUN=$(dd if=$ZIMAGE obs=64K ibs=4 skip=$(( IMG_OFFSET / 4)) | zcat | grep -a -m1 "Linux version" | strings | awk '{ print $3; }')
}
@ -48,8 +47,7 @@ function get_kernel_version() {
return 0
}
CONFIG=/boot/config.txt
[ -f /boot/firmware/usercfg.txt ] && CONFIG=/boot/firmware/usercfg.txt
CONFIG=/boot/armbianEnv.txt
get_overlay() {
ov=$1
@ -86,31 +84,31 @@ do_overlay() {
fi
}
is_1a=$(i2cdetect -y 1 0x1a 0x1a | egrep "(1a|UU)" | awk '{print $2}')
is_35=$(i2cdetect -y 1 0x35 0x35 | egrep "(35|UU)" | awk '{print $2}')
is_3b=$(i2cdetect -y 1 0x3b 0x3b | egrep "(3b|UU)" | awk '{print $2}')
I2C_BUS=7
is_1a=$(i2cdetect -y $I2C_BUS 0x1a 0x1a | egrep "(1a|UU)" | awk '{print $2}')
is_35=$(i2cdetect -y $I2C_BUS 0x35 0x35 | egrep "(35|UU)" | awk '{print $2}')
is_3b=$(i2cdetect -y $I2C_BUS 0x3b 0x3b | egrep "(3b|UU)" | awk '{print $2}')
RPI_HATS="seeed-2mic-voicecard seeed-4mic-voicecard seeed-8mic-voicecard"
overlay=""
if [ "x${is_1a}" != "x" ] && [ "x${is_35}" == "x" ] ; then
echo "install 2mic"
overlay=seeed-2mic-voicecard
overlay=seeed-2mic-voicecard-overlay
asound_conf=/etc/voicecard/asound_2mic.conf
asound_state=/etc/voicecard/wm8960_asound.state
fi
if [ "x${is_3b}" != "x" ] && [ "x${is_35}" == "x" ] ; then
echo "install 4mic"
overlay=seeed-4mic-voicecard
overlay=seeed-4mic-voicecard-overlay
asound_conf=/etc/voicecard/asound_4mic.conf
asound_state=/etc/voicecard/ac108_asound.state
fi
if [ "x${is_3b}" != "x" ] && [ "x${is_35}" != "x" ] ; then
echo "install 6mic"
overlay=seeed-8mic-voicecard
overlay=seeed-8mic-voicecard-overlay
asound_conf=/etc/voicecard/asound_6mic.conf
asound_state=/etc/voicecard/ac108_6mic.state
fi
@ -138,7 +136,8 @@ if [ "$overlay" ]; then
done
fi
#make sure the driver loads correctly
dtoverlay -d $OVERLAYS $overlay || true
# this isn't needed in Armbian, which loads overlays from /boot/armbianEnv.txt
# dtoverlay -d $OVERLAYS $overlay || true
echo "create $overlay asound configure file"