Last active
May 14, 2020 18:44
-
-
Save richbayliss/aebe3ceca55ac1793e857aaef9710ec4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM balenalib/armv7hf-debian:buster AS kernel-builder | |
RUN apt-get update && apt-get install -y \ | |
build-essential \ | |
i2c-tools \ | |
wget \ | |
alsa-utils \ | |
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | |
ARG HEADERS_URL="https://files.balena-cloud.com/images/raspberrypi3/2.47.0%2Brev1.prod/kernel_modules_headers.tar.gz" | |
ARG HEADERS_PATH=/tmp/kernel_modules_headers | |
ARG MODULE_URL="https://github.com/respeaker/seeed-voicecard/archive/master.tar.gz" | |
ARG MODULE_PATH="/opt/seeed-voicecard" | |
RUN mkdir -p $HEADERS_PATH \ | |
&& cd $HEADERS_PATH \ | |
&& wget $HEADERS_URL \ | |
&& tar -xf kernel_modules_headers.tar.gz --strip 1 | |
RUN mkdir -p $MODULE_PATH \ | |
&& cd $MODULE_PATH \ | |
&& wget $MODULE_URL \ | |
&& tar -xf master.tar.gz --strip 1 \ | |
&& make -C $HEADERS_PATH M=$MODULE_PATH modules \ | |
&& mkdir -p /etc/voicecard \ | |
&& cp *.conf /etc/voicecard \ | |
&& cp *.state /etc/voicecard \ | |
&& cp seeed-voicecard /usr/bin | |
################################################## | |
FROM balenalib/raspberrypi3-alpine:latest | |
RUN apk --no-cache add alsa-utils | |
RUN apk --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community add i2c-tools mpv | |
RUN mkdir -p /app/modules \ | |
&& mkdir -p /etc/voicecard | |
COPY --from=kernel-builder /opt/seeed-voicecard/*.ko /app/modules/ | |
COPY --from=kernel-builder /opt/seeed-voicecard/*.dtbo /etc/voicecard/ | |
COPY --from=kernel-builder /opt/seeed-voicecard/*.dts /etc/voicecard/ | |
COPY --from=kernel-builder /opt/seeed-voicecard/*.conf /etc/voicecard/ | |
COPY --from=kernel-builder /opt/seeed-voicecard/*.state /etc/voicecard/ | |
WORKDIR /app | |
COPY run.sh . | |
CMD [ "/app/run.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#enable i2c interface | |
modprobe i2c-dev | |
sleep 1 | |
mod_dir="/app/modules" | |
modprobe snd-soc-simple-card-utils | |
insmod $mod_dir/snd-soc-seeed-voicecard.ko | |
insmod $mod_dir/snd-soc-ac108.ko | |
insmod $mod_dir/snd-soc-wm8960.ko | |
sleep 1 | |
hw=$(aplay -l | grep seeed2micvoicec | awk '{print $2}' | sed 's/://') | |
cp /etc/voicecard/asound_2mic.conf /etc/asound.conf | |
cp /etc/voicecard/wm8960_asound.state /var/lib/alsa/asound.state | |
echo "Update ALSA config" | |
old=$(cat /etc/asound.conf | grep hw: | awk 'NR==1 {print $2}' | sed 's/\"//g') | |
sed -i -e "s/${old}/hw:${hw},0/g" /etc/asound.conf | |
alsactl restore | |
#Fore 3.5mm ('headphone') jack | |
amixer cset numid=3 1 | |
while :; do sleep 10; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment