From 81e0f0879d2779b7367beba2efc9f769d728ef61 Mon Sep 17 00:00:00 2001 From: AIWintermuteAI <32562299+AIWintermuteAI@users.noreply.github.com> Date: Wed, 21 Jul 2021 15:21:38 +0800 Subject: [PATCH 1/7] automation --- .github/workflows/stale.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/stale.yml diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..c2e15cd --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,23 @@ +name: Mark stale issues and pull requests + +on: + schedule: + - cron: '20 0 * * *' + +jobs: + stale: + + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + + steps: + - uses: actions/stale@v4.0.0 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: 'Stale issue message' + stale-pr-message: 'Stale pull request message' + stale-issue-label: 'no-issue-activity' + stale-pr-label: 'no-pr-activity' + days-before-stale: 15 From 41a09a3b67dc476b9ae2111d319e6941c3d2f689 Mon Sep 17 00:00:00 2001 From: AIWintermuteAI Date: Thu, 22 Jul 2021 17:52:05 +0800 Subject: [PATCH 2/7] added issue template --- .github/ISSUE_TEMPLATE/BUG_ISSUE.yml | 54 ++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 5 ++ .../workflows/ISSUE_TEMPLATE/BUG_ISSUE.yml | 55 +++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/BUG_ISSUE.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/workflows/ISSUE_TEMPLATE/BUG_ISSUE.yml diff --git a/.github/ISSUE_TEMPLATE/BUG_ISSUE.yml b/.github/ISSUE_TEMPLATE/BUG_ISSUE.yml new file mode 100644 index 0000000..add7e06 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/BUG_ISSUE.yml @@ -0,0 +1,54 @@ +name: Bug Report +description: File a bug report +title: "[Bug]: " +labels: [bug, triage] +assignees: + - AIWintermuteAI + - Pillar1989 +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + + - type: textarea + id: what-happened + attributes: + label: Describe the bug + description: A clear and concise description of what the bug is. + value: | + **To Reproduce** + Steps to reproduce the behavior: + 1. Go to '...' + 2. Click on '....' + 3. Scroll down to '....' + 4. See error + validations: + required: true + + - type: textarea + id: what-expected + attributes: + label: Expected behavior + description: A clear and concise description of what you expected to happen. + validations: + required: true + + - type: textarea + id: platform + attributes: + label: Platform + description: What platform are you running the code on. + value: | + - Device: [e.g. Raspberry Pi 4] + - OS: [e.g. Raspbian OS 32bit kernel version ...] + - Version/commit number [e.g. d1816f5] + validations: + required: true + + - type: textarea + id: logs + attributes: + label: Relevant log output + description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + render: shell diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..bc35e9c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: Seeed Tech Support Forum + url: https://forum.seeedstudio.com/ + about: Please ask and answer general questions here. \ No newline at end of file diff --git a/.github/workflows/ISSUE_TEMPLATE/BUG_ISSUE.yml b/.github/workflows/ISSUE_TEMPLATE/BUG_ISSUE.yml new file mode 100644 index 0000000..95524d5 --- /dev/null +++ b/.github/workflows/ISSUE_TEMPLATE/BUG_ISSUE.yml @@ -0,0 +1,55 @@ +name: Bug Report +description: File a bug report +title: "[Bug]: " +labels: [bug, triage] +assignees: + - AIWintermuteAI + - Pillar1989 +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + + - type: textarea + id: what-happened + attributes: + label: Describe the bug + description: A clear and concise description of what the bug is. + placeholder: | + **To Reproduce** + Steps to reproduce the behavior: + 1. Go to '...' + 2. Click on '....' + 3. Scroll down to '....' + 4. See error + validations: + required: true + + - type: textarea + id: what-happened + attributes: + label: Expected behavior + description: A clear and concise description of what you expected to happen. + placeholder: "" + validations: + required: true + + - type: textarea + id: platform + attributes: + label: Platform + description: What platform are you running the code on. + placeholder: | + - Device: [e.g. Raspberry Pi 4] + - OS: [e.g. Raspbian OS 32bit kernel version ...] + - Version/commit number [e.g. d1816f5] + validations: + required: true + + - type: textarea + id: logs + attributes: + label: Relevant log output + description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + render: shell From b595b95b2184f52e752256cca17e9b92e1a19cd7 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Wed, 4 Aug 2021 12:04:46 +0100 Subject: [PATCH 3/7] Revert "libasound_module_pcm_ac108.so is no longer installed, so libasound2-plugins shouldn't be needed" This reverts commit 8b2094fc23b7dbad5a263ea49fcd11c5970f2884. See #304 regarding missing libasound2-plugins. --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 4c7b9bd..8c84be9 100755 --- a/install.sh +++ b/install.sh @@ -108,7 +108,7 @@ if [[ $? -eq 0 ]]; then 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 + apt-get -y install dkms git i2c-tools libasound2-plugins # rpi-update checker check_kernel_headers fi From 17e2875d4d6b47376861a1f936b9f5b365845a11 Mon Sep 17 00:00:00 2001 From: Baozhu Zuo Date: Mon, 16 Aug 2021 11:22:46 +0800 Subject: [PATCH 4/7] delete snd-soc-wm8960.ko first see https://github.com/raspberrypi/linux/commit/14075fb3b561869c760a096a92ca0fab1f573174 --- install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/install.sh b/install.sh index 8c84be9..3603ae3 100755 --- a/install.sh +++ b/install.sh @@ -52,6 +52,9 @@ if [ $errorFound = 1 ] ; then exit 1 fi +#because https://github.com/raspberrypi/linux/commit/14075fb3b561869c760a096a92ca0fab1f573174, remove snd-soc-wm8960.ko first +find /lib/modules -name "snd-soc-wm8960.ko" -exec rm -rf {} \; + ver="0.3" uname_r=$(uname -r) From bd7623e9fb0a6a2e0604f19fac5f8f58a22496fb Mon Sep 17 00:00:00 2001 From: AIWintermuteAI Date: Tue, 17 Aug 2021 03:27:17 +0100 Subject: [PATCH 5/7] added reboot warning if active kernel version doesn't match updated kernel version --- .../workflows/ISSUE_TEMPLATE/BUG_ISSUE.yml | 55 ------------------- install.sh | 19 ++++++- 2 files changed, 17 insertions(+), 57 deletions(-) delete mode 100644 .github/workflows/ISSUE_TEMPLATE/BUG_ISSUE.yml diff --git a/.github/workflows/ISSUE_TEMPLATE/BUG_ISSUE.yml b/.github/workflows/ISSUE_TEMPLATE/BUG_ISSUE.yml deleted file mode 100644 index 95524d5..0000000 --- a/.github/workflows/ISSUE_TEMPLATE/BUG_ISSUE.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Bug Report -description: File a bug report -title: "[Bug]: " -labels: [bug, triage] -assignees: - - AIWintermuteAI - - Pillar1989 -body: - - type: markdown - attributes: - value: | - Thanks for taking the time to fill out this bug report! - - - type: textarea - id: what-happened - attributes: - label: Describe the bug - description: A clear and concise description of what the bug is. - placeholder: | - **To Reproduce** - Steps to reproduce the behavior: - 1. Go to '...' - 2. Click on '....' - 3. Scroll down to '....' - 4. See error - validations: - required: true - - - type: textarea - id: what-happened - attributes: - label: Expected behavior - description: A clear and concise description of what you expected to happen. - placeholder: "" - validations: - required: true - - - type: textarea - id: platform - attributes: - label: Platform - description: What platform are you running the code on. - placeholder: | - - Device: [e.g. Raspberry Pi 4] - - OS: [e.g. Raspbian OS 32bit kernel version ...] - - Version/commit number [e.g. d1816f5] - validations: - required: true - - - type: textarea - id: logs - attributes: - label: Relevant log output - description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. - render: shell diff --git a/install.sh b/install.sh index 3603ae3..2cc8a41 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,9 @@ #!/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 @@ -52,8 +56,6 @@ if [ $errorFound = 1 ] ; then exit 1 fi -#because https://github.com/raspberrypi/linux/commit/14075fb3b561869c760a096a92ca0fab1f573174, remove snd-soc-wm8960.ko first -find /lib/modules -name "snd-soc-wm8960.ko" -exec rm -rf {} \; ver="0.3" uname_r=$(uname -r) @@ -128,6 +130,16 @@ 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 @@ -157,6 +169,9 @@ function install_module { mkdir -p /var/lib/dkms/$mod/$ver/$marker } +#because https://github.com/raspberrypi/linux/commit/14075fb3b561869c760a096a92ca0fab1f573174, remove snd-soc-wm8960.ko first +#find /lib/modules -name "snd-soc-wm8960.ko" -exec rm -rf {} \; + install_module "./" "seeed-voicecard" From d840f77541f9f1ff64097a2aec274d549d6e8a23 Mon Sep 17 00:00:00 2001 From: AIWintermuteAI <32562299+AIWintermuteAI@users.noreply.github.com> Date: Thu, 19 Aug 2021 09:56:53 +0800 Subject: [PATCH 6/7] Update install.sh --- install.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 2cc8a41..a8f3279 100755 --- a/install.sh +++ b/install.sh @@ -130,7 +130,7 @@ 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%[-+]*} +kernel_base_ver=${kernels%%[-+]*} if [[ "$base_ver" != "$kernel_base_ver" ]] ; then echo "------------------------------------------------------" @@ -169,12 +169,8 @@ function install_module { mkdir -p /var/lib/dkms/$mod/$ver/$marker } -#because https://github.com/raspberrypi/linux/commit/14075fb3b561869c760a096a92ca0fab1f573174, remove snd-soc-wm8960.ko first -#find /lib/modules -name "snd-soc-wm8960.ko" -exec rm -rf {} \; - install_module "./" "seeed-voicecard" - # install dtbos cp seeed-2mic-voicecard.dtbo $OVERLAYS cp seeed-4mic-voicecard.dtbo $OVERLAYS From dd9391fb78e6ec0ead495e5246e32a781d056ab2 Mon Sep 17 00:00:00 2001 From: AIWintermuteAI Date: Fri, 20 Aug 2021 07:23:35 +0100 Subject: [PATCH 7/7] added 64-bit system installation script --- README.md | 7 +- install_arm64.sh | 236 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 240 insertions(+), 3 deletions(-) create mode 100755 install_arm64.sh diff --git a/README.md b/README.md index 46d77cf..d6f5d0d 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,8 @@ cd seeed-voicecard sudo ./install.sh sudo reboot ``` -It may probably happen that the driver won't compile with the latest kernel when raspbian rolls out new patches to the kernel. If so, please try `sudo ./install.sh --compat-kernel` which uses an older kernel but ensures that the driver can work. + +**Note** If you have 64-bit version of Rasperry Pi OS, use install_arm64.sh script for driver installation. ## ReSpeaker Documentation @@ -54,10 +55,10 @@ For hardware testing purposes we made a Rasperry Pi OS 5.10.17-v7l+ 32-bit image We provide official support for using reSpeaker with the following OS: - 32-bit Raspberry Pi OS -- 64-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 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. diff --git a/install_arm64.sh b/install_arm64.sh new file mode 100755 index 0000000..45597e9 --- /dev/null +++ b/install_arm64.sh @@ -0,0 +1,236 @@ +#!/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/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; }') + } + 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; }') + 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 + + 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 "------------------------------------------------------"