From e750de0ecc84ee81035bbb27ad820848aafd7dda Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 24 Aug 2020 12:03:46 +0100 Subject: [PATCH 01/30] Allow kernel images to be elsewhere - Ubuntu kernel is not at Raspbian location --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index 3268e69..2665d29 100755 --- a/install.sh +++ b/install.sh @@ -66,6 +66,7 @@ function get_kernel_version() { _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)) | zcat | grep -a -m1 "Linux version" | strings | awk '{ print $3; }') } From cd899a83d54343045bfc25d791fb592d57dfe1a5 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Thu, 27 Aug 2020 13:15:03 +0100 Subject: [PATCH 02/30] make the overlay un-install directory configurable, for Ubuntu --- uninstall.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/uninstall.sh b/uninstall.sh index c9491d6..2d28681 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -55,9 +55,12 @@ echo "remove dtbos" for i in $RPI_HATS; do dtoverlay -r $i done -rm /boot/overlays/seeed-2mic-voicecard.dtbo || true -rm /boot/overlays/seeed-4mic-voicecard.dtbo || true -rm /boot/overlays/seeed-8mic-voicecard.dtbo || true +OVERLAYS=/boot/overlays +[ -d /boot/firmware/overlays ] && OVERLAYS=/boot/firmware/overlays + +rm ${OVERLAYS}/seeed-2mic-voicecard.dtbo || true +rm ${OVERLAYS}/seeed-4mic-voicecard.dtbo || true +rm ${OVERLAYS}/seeed-8mic-voicecard.dtbo || true echo "remove alsa configs" rm -rf /etc/voicecard/ || true From e82e6fde67d9f7b77b3898912a656cb1329fdb8e Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Thu, 27 Aug 2020 13:17:20 +0100 Subject: [PATCH 03/30] make the config un-install directory configurable, for Ubuntu --- uninstall.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/uninstall.sh b/uninstall.sh index 2d28681..6b9f8d1 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -14,6 +14,8 @@ fi uname_r=$(uname -r) CONFIG=/boot/config.txt +[ -f /boot/firmware/usercfg.txt ] && CONFIG=/boot/firmware/usercfg.txt + get_overlay() { ov=$1 if grep -q -E "^dtoverlay=$ov" $CONFIG; then From 1f7323417b60c032f626535a8a94dee255bffcb7 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Fri, 4 Sep 2020 20:22:17 +0100 Subject: [PATCH 04/30] temporary work-around for not being able to read sysclk from dts for ac10x The "sysclk = 24000000" value is supposed to come from the "clock-frequency" field of ac108_mclk / ac10x_mclk, but somehow it isn't on 5.4 (vs 4.19). This is a temporary work-around. For some strange unknown reasons, this affects only the square 4-mic device, but not the linear 4-mic nor the 6-mics device. The other two devices have two ac108's, and seem to work fine without it. In v4.19: seeed_voice_card_probe [snd_soc_seeed_voicecard] -> devm_snd_soc_register_card [snd_soc_core] -> snd_soc_register_card [snd_soc_core] -> seeed_voice_card_dai_init [snd_soc_seeed_voicecard] -> asoc_simple_card_init_dai [snd_soc_simple_card_utils] -> snd_soc_dai_set_sysclk [snd_soc_core] -> ac108_set_sysclk [snd_soc_ac108] In 5.4: seeed_voice_card_probe [snd_soc_seeed_voicecard] -> devm_snd_soc_register_card [snd_soc_core] -> snd_soc_register_card [snd_soc_core] -> snd_soc_instantiate_card [snd_soc_core] -> seeed_voice_card_dai_init [snd_soc_seeed_voicecard] -> asoc_simple_init_dai.part.0 [snd_soc_seeed_voicecard] -> snd_soc_dai_set_sysclk [snd_soc_core] -> ac108_set_sysclk [snd_soc_ac108] Which results in the "ac108_set_sysclk :24000000" kernel message. Note the extra snd_soc_instantiate_card(), and the copied/renamed asoc_simple_init_dai() - it became static and not-available to other drivers in v5.x. See https://github.com/respeaker/seeed-voicecard/issues/246 --- seeed-voicecard.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/seeed-voicecard.c b/seeed-voicecard.c index 1ed9a0e..aceb7b9 100644 --- a/seeed-voicecard.c +++ b/seeed-voicecard.c @@ -457,6 +457,8 @@ static int seeed_voice_card_dai_link_of(struct device_node *node, #else ret = asoc_simple_parse_clk_codec(dev, codec, dai_link, codec_dai); #endif + if (!strncmp(dai_link->codecs->dai_name, "ac10", 4)) + codec_dai->sysclk = 24000000; if (ret < 0) goto dai_link_of_err; From f47375e54dd07d758c71d861467820b3f8333061 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Fri, 4 Sep 2020 06:37:57 +0100 Subject: [PATCH 05/30] Add reference to Ubuntu kernel package names Signed-off-by: Hin-Tak Leung --- install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/install.sh b/install.sh index 2665d29..c9fca53 100755 --- a/install.sh +++ b/install.sh @@ -100,7 +100,10 @@ function check_kernel_headers() { 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 From 8c25d818905a3509adb8df3a8fff9dfe18a95407 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Fri, 4 Sep 2020 06:26:13 +0000 Subject: [PATCH 06/30] update check_kernel_headers() for Ubuntu header packages --- install.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/install.sh b/install.sh index c9fca53..1d8370b 100755 --- a/install.sh +++ b/install.sh @@ -80,6 +80,10 @@ function check_kernel_headers() { [ "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" From 5ca9ab45dfe7ff65718990f36ee2e8fae58bdac2 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Wed, 9 Sep 2020 03:25:19 +0100 Subject: [PATCH 07/30] Use logic from raspi-config to determine if bcm2835 routing option exists or not The snd_bcm2835.enable_compat_alsa option: enable_compat_alsa:Enables ALSA compatibility virtual audio device (bool) is off these days, since the beginning of 2020 apparently. Reference: raspi-config (20200120) buster; urgency=medium * Add audio switching for discrete internal ALSA devices -- Simon Long Mon, 20 Jan 2020 11:38:37 +0000 --- seeed-voicecard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seeed-voicecard b/seeed-voicecard index f8c3986..79a3551 100755 --- a/seeed-voicecard +++ b/seeed-voicecard @@ -150,6 +150,6 @@ fi alsactl restore #Force 3.5mm ('headphone') jack -if [[ "$kernel_ver" =~ ^4\.*$ ]]; then +if aplay -l | grep -q "bcm2835 ALSA"; then amixer cset numid=3 1 || true fi From cca7bbfe2af11acef42d9ce1e2a73de10dc69533 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Thu, 10 Sep 2020 23:18:08 +0100 Subject: [PATCH 08/30] comment about Raspberry Pi 4 having two HDMI ports The if-endif block below around the amixer call fixes https://github.com/respeaker/seeed-voicecard/issues/239 https://github.com/respeaker/seeed-voicecard/issues/240 https://github.com/respeaker/seeed-voicecard/issues/243 --- seeed-voicecard | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/seeed-voicecard b/seeed-voicecard index 79a3551..9a135a1 100755 --- a/seeed-voicecard +++ b/seeed-voicecard @@ -150,6 +150,12 @@ fi alsactl restore #Force 3.5mm ('headphone') jack +# The Raspberry Pi 4, released on 24th Jun 2019, has two HDMI ports, +# and can drive two displays with audios for two users simultaneously, +# in a "multiseat" configuration. The earlier single virtual ALSA +# option for re-directing audio playback between headphone jack and HDMI +# via a 'Routing' mixer setting was turned off eventually to allow +# simultaneous usage of all 3 playback devices. if aplay -l | grep -q "bcm2835 ALSA"; then amixer cset numid=3 1 || true fi From de23c612101018ad7f53361f2fdc55fefee50228 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Sun, 13 Sep 2020 18:18:30 +0100 Subject: [PATCH 09/30] Use pr_info() for just routine information, not pr_warn() --- ac101.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ac101.c b/ac101.c index a4bcd62..762c8d3 100644 --- a/ac101.c +++ b/ac101.c @@ -1152,14 +1152,14 @@ int ac101_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) switch(fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: /* codec clk & frm master, ap is slave*/ #if _MASTER_MULTI_CODEC == _MASTER_AC101 - pr_warn("AC101 as Master\n"); + pr_info("AC101 as Master\n"); reg_val |= (0x0< Date: Sun, 13 Sep 2020 18:24:25 +0100 Subject: [PATCH 10/30] Use pr_warn() for recoverable errors, not pr_info() --- ac101.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ac101.c b/ac101.c index 762c8d3..92b2583 100644 --- a/ac101.c +++ b/ac101.c @@ -376,7 +376,7 @@ static int ac101_switch_probe(struct ac10x_priv *ac10x) { ac10x->irq = gpiod_to_irq(ac10x->gpiod_irq); if (IS_ERR_VALUE(ac10x->irq)) { - pr_info("[ac101] map gpio to irq failed, errno = %ld\n", ac10x->irq); + pr_warn("[ac101] map gpio to irq failed, errno = %ld\n", ac10x->irq); ac10x->irq = 0; goto _err_irq; } @@ -384,7 +384,7 @@ static int ac101_switch_probe(struct ac10x_priv *ac10x) { /* request irq, set irq type to falling edge trigger */ ret = devm_request_irq(ac10x->codec->dev, ac10x->irq, audio_hmic_irq, IRQF_TRIGGER_FALLING, "SWTICH_EINT", ac10x); if (IS_ERR_VALUE(ret)) { - pr_info("[ac101] request virq %ld failed, errno = %ld\n", ac10x->irq, ret); + pr_warn("[ac101] request virq %ld failed, errno = %ld\n", ac10x->irq, ret); goto _err_irq; } From 9722cb01e480c0b5b5e94bc6d9f8862c5733f32e Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 14 Sep 2020 14:26:40 +0100 Subject: [PATCH 11/30] Revert "temporary work-around for not being able to read sysclk from dts for ac10x" This reverts commit 138d22226ed2b36a94d74873f8f1ac3193ee944f. --- seeed-voicecard.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/seeed-voicecard.c b/seeed-voicecard.c index aceb7b9..1ed9a0e 100644 --- a/seeed-voicecard.c +++ b/seeed-voicecard.c @@ -457,8 +457,6 @@ static int seeed_voice_card_dai_link_of(struct device_node *node, #else ret = asoc_simple_parse_clk_codec(dev, codec, dai_link, codec_dai); #endif - if (!strncmp(dai_link->codecs->dai_name, "ac10", 4)) - codec_dai->sysclk = 24000000; if (ret < 0) goto dai_link_of_err; From c4c112dcafbc83ce19730bf53429a3b39bd38ca3 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 14 Sep 2020 11:25:59 +0100 Subject: [PATCH 12/30] relocating fixed-clock entry, based on upstream advice See upstream - https://github.com/raspberrypi/documentation/issues/1671 https://github.com/raspberrypi/documentation/pull/1673 Quoted here: * Only Device Tree nodes at the top level of the tree and children of a bus node will be probed. For nodes added at run-time there is the further limitation that the bus must register for notifications of the addition and removal of children. However, there are exceptions that break this rule and cause confusion: the kernel explicitly scans the entire tree for some device types - clocks and interrupt controller being the two main ones - in order to (for clocks) initialise them early and/or (for interrupt controllers) in a particular order. This search mechanism only happens during booting and so doesn't work for nodes added by an overlay at run-time. It is therefore recommended for overlays to place fixed-clock nodes in the root of the tree unless it is guaranteed that the overlay will not be used at run-time. --- seeed-4mic-voicecard-overlay.dts | 2 +- seeed-8mic-voicecard-overlay.dts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/seeed-4mic-voicecard-overlay.dts b/seeed-4mic-voicecard-overlay.dts index de7213b..db0b988 100644 --- a/seeed-4mic-voicecard-overlay.dts +++ b/seeed-4mic-voicecard-overlay.dts @@ -13,7 +13,7 @@ }; fragment@1 { - target-path = "/clocks"; + target-path = "/"; __overlay__ { ac108_mclk: codec-mclk { compatible = "fixed-clock"; diff --git a/seeed-8mic-voicecard-overlay.dts b/seeed-8mic-voicecard-overlay.dts index 6d60469..56a1433 100644 --- a/seeed-8mic-voicecard-overlay.dts +++ b/seeed-8mic-voicecard-overlay.dts @@ -13,7 +13,7 @@ }; fragment@1 { - target-path = "/clocks"; + target-path = "/"; __overlay__ { ac10x_mclk: codec-mclk { compatible = "fixed-clock"; From cf98b67079420bbe87eca4bf37a6fa937ce3295f Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 14 Sep 2020 11:27:45 +0100 Subject: [PATCH 13/30] rebuilt dtbo on current Raspbian --- seeed-4mic-voicecard.dtbo | Bin 2349 -> 2259 bytes seeed-8mic-voicecard.dtbo | Bin 3463 -> 3385 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/seeed-4mic-voicecard.dtbo b/seeed-4mic-voicecard.dtbo index 764dc804b98a83cb68fff3a92157b5c2e20671f1..09ee56626c466a2f3d1bca1e8482608c2c88a8d9 100644 GIT binary patch delta 421 zcmZ20bXid20`I@K3=ABX85kHW7#P^@0BH>%76f7eAO-@)??CY-6E&7|Fadd5`V0&c zZ|6)7XLJ#a2FU_3GZ3=?an|HDjQ)&elm9Tv3swR7AOMpKo@~REF4~b&To9j#kP!tk z7fjy4WNx?($U-*jIvW2gkPos0Y96EFWCdpN$?nW5hCcs+07)hc$OgF-rZOGKR)F$> zUSh18Jcn7Dv48RoX64DRnKe{>fO5#{mq69RT@K_kPX55A&MF0Dte#xLV$Ha9@&*=t z#siZd0Lc@R1z43CuT3ss)tVf~D#&;b$ns}=G5G*%G~=7eGHl9>A16Do#S4Ob2m&y3 guTS2Ex0`I@K3=EvQ3=9kw3=HfBKw1Nc1%X%qh=G9dF9QSHkBJ(~c{qSPE&b%2 z{N(K7iPv*DnSp#3AdZ}D!{{xT2vQ5gFwug^GZ_6DYbL*7lviy4ih}@5E*QvWLgGh) z_>&zNB`2FQd5QL=6c@yUi~|CY4pAUpHhBt@dEg!(3)zmlX#C$mKFCE-dl=PG`3xX? zk>r6c=V8|N4f+oRNV;NxY$Vq)<^uT&PXhWHvB@81Dc@ zbSCq#@-sdGva}}eW9FRf&nmskzfXR{8ZQV6ClG*!1H;|PF>Kmk ecOZ!}u9`f94P^5Pwsf|f%)HVHoz42}OBey)FHxre diff --git a/seeed-8mic-voicecard.dtbo b/seeed-8mic-voicecard.dtbo index 4ef515b52dc5e8ef508e41cea63bb9f1f0fe3d55..2dcaa93d42b0a3535fbe2aaea8354e8690d6ac9e 100644 GIT binary patch delta 920 zcmah{&r4KM6u#&En0ar;2?t|Dr^V=yjftpD!c;~GxyT{{4T+>2-n>+pbZW+(QqUrV zAna`X11z^eRJ3RrZCVT@E~1UlqK)8k+F0M2dDlh|JaFzk-*>)q-#ho7=gCi$|a1lK4%BqsN>f3RNgALN&c z6@&+W@CLC|NE=es0)P7#hFv-k)BG1sneDXAIr9uJnmKzLxnUkLlU+aRy8qw(4XjTL zdNQxn^_N6{`dB^c9iA~d__Z}oHQuwj&(R4X;X!kB@i10LHQ&dZcIJs+D3|W%A&2Se zVi0S*d>AWfPK>Y#5t7wQ{YMW*Q)X$RO2 z)Zj@jPM#w;9mB8{%GxzBA>NNBxI5fM244*iP>d^BJ9z_Z59i&Kl_ zPo-kZN~vo~MULZ6!#(&BI4m%!l)Jr>UXMCJeYr|=veIbt$MCV0A9uq+|3&FpeEc+Su|5*)I+sOPyqn7FjH*Sp{S4cJsA zD$TDb@h6`@aA>}4QL8EONT^2N`Az7|ef1Xwqey83BTu8%iAUwx<_yw%4@gedEQ>Kk zF8Vn=WR)E&V|;Sf%H~ zM z2vvxaZpM?{h-pm={J>3kqFhX8clenr+TOc0yIF6|KFM+_QsDW>+xS$yRhgM?UTBpc OPqdXr{To-K7X1eSFNL@O From cbd6da78fc2cea3b8bd3844dd6fbe94cac28ae37 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 14 Sep 2020 11:10:31 +0000 Subject: [PATCH 14/30] updating non-standard PATH for Ubuntu in uninstall.sh --- uninstall.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/uninstall.sh b/uninstall.sh index 6b9f8d1..c88caf9 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -53,6 +53,7 @@ do_overlay() { RPI_HATS="seeed-2mic-voicecard seeed-4mic-voicecard seeed-8mic-voicecard" +PATH=$PATH:/opt/vc/bin echo "remove dtbos" for i in $RPI_HATS; do dtoverlay -r $i From 90144a2f2e644e7b9ef6ce2af600a62e7ca8c839 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 14 Sep 2020 11:13:40 +0000 Subject: [PATCH 15/30] updating for Ubuntu location of dkms-generated kernel modules --- uninstall.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/uninstall.sh b/uninstall.sh index c88caf9..a00f7a1 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -82,6 +82,9 @@ echo "remove kernel modules" rm /lib/modules/*/kernel/sound/soc/codecs/snd-soc-wm8960.ko || true rm /lib/modules/*/kernel/sound/soc/codecs/snd-soc-ac108.ko || true rm /lib/modules/*/kernel/sound/soc/bcm/snd-soc-seeed-voicecard.ko || true +rm /lib/modules/*/updates/dkms/snd-soc-wm8960.ko || true +rm /lib/modules/*/updates/dkms/snd-soc-ac108.ko || true +rm /lib/modules/*/updates/dkms/snd-soc-seeed-voicecard.ko || true echo "remove $CONFIG configuration" for i in $RPI_HATS; do From 9285159a7ddb50ba733630042abf46de29214a53 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Sat, 12 Sep 2020 00:39:19 +0000 Subject: [PATCH 16/30] Apparently, snd_soc_dai_set_bclk_ratio should be used where snd_soc_dai_set_tdm_slot is. See, for example, commit b78b30e32a19f1ac79c26e0a3e9f7bc7385a02a2 Author: j-schambacher Date: Tue May 19 13:56:17 2020 +0200 Switch to snd_soc_dai_set_bclk_ratio Replaces obsolete function snd_soc_dai_set_tdm_slot --- seeed-voicecard.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/seeed-voicecard.c b/seeed-voicecard.c index 1ed9a0e..43535aa 100644 --- a/seeed-voicecard.c +++ b/seeed-voicecard.c @@ -322,10 +322,8 @@ static int asoc_simple_init_dai(struct snd_soc_dai *dai, } if (simple_dai->slots) { - ret = snd_soc_dai_set_tdm_slot(dai, - simple_dai->tx_slot_mask, - simple_dai->rx_slot_mask, - simple_dai->slots, + ret = snd_soc_dai_set_bclk_ratio(dai, + simple_dai->slots * simple_dai->slot_width); if (ret && ret != -ENOTSUPP) { dev_err(dai->dev, "simple-card: set_tdm_slot error\n"); From 6875869cb253bdfd0caeb8bb6cb1e33f16aa0068 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Sun, 13 Sep 2020 15:33:56 +0000 Subject: [PATCH 17/30] emit warning for calling ac108_set_sysclk() with unexpected arguments Don't know why Seeed Studio staff did not put it in. Conflicts: ac108.c --- ac108.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ac108.c b/ac108.c index 29e0a94..12ab27b 100644 --- a/ac108.c +++ b/ac108.c @@ -810,6 +810,9 @@ static int ac108_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int fr struct ac10x_priv *ac10x = snd_soc_dai_get_drvdata(dai); + if (freq != 24000000 || clk_id != SYSCLK_SRC_PLL) + dev_warn(dai->dev, "ac108_set_sysclk freq = %d clk = %d\n", freq, clk_id); + freq = 24000000; clk_id = SYSCLK_SRC_PLL; From 19cfed5bd772ff89b26acc1abdd748b6738a0b6c Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Fri, 18 Sep 2020 01:06:57 +0100 Subject: [PATCH 18/30] Adding missing shebang This script has no bash-ism, so /bin/sh (dash on Debian/Ubuntu) is fine. --- builddtbo.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/builddtbo.sh b/builddtbo.sh index e98800f..d6e8009 100755 --- a/builddtbo.sh +++ b/builddtbo.sh @@ -1,3 +1,4 @@ +#!/bin/sh #dtoverlay -r seeed-2mic-voicecard DTC_FLAGS="-b 0 -Wno-unit_address_vs_reg -I dts -O dtb" From 1372794704ff6c94ffdd690d9d750dde7adc535d Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 04:25:35 +0100 Subject: [PATCH 19/30] Revert "Don't force kernel downgrade" This reverts commit 30276c80bc1e66cdece5ce6d88928e1fa5265e2c. --- install.sh | 41 +++++++++++++++++++++++++++++++++++++---- seeed-voicecard | 4 +++- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 1d8370b..872b428 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,7 @@ #!/bin/bash +FORCE_KERNEL="1.20190925+1-1" + if [[ $EUID -ne 0 ]]; then echo "This script must be run as root (use sudo)" 1>&2 exit 1 @@ -100,15 +102,46 @@ function check_kernel_headers() { apt-get -y --reinstall install raspberrypi-kernel } +function download_install_debpkg() { + local prefix name r + prefix=$1 + name=$2 + + for (( i = 0; i < 3; i++ )); do + wget $prefix$name -O /tmp/$name && break + done + dpkg -i /tmp/$name; r=$? + rm -f /tmp/$name + return $r +} + +function install_kernel() { + local _url _prefix + + # Instead of retriving the lastest kernel & headers + [ "X$FORCE_KERNEL" == "X" ] && { + # Raspbian kernel packages + apt-get -y --force-yes install raspberrypi-kernel-headers raspberrypi-kernel + # Ubuntu kernel packages + apt-get -y install linux-raspi linux-headers-raspi linux-image-raspi + } || { + # We would like to a fixed version + KERN_NAME=raspberrypi-kernel_${FORCE_KERNEL}_armhf.deb + HDR_NAME=raspberrypi-kernel-headers_${FORCE_KERNEL}_armhf.deb + _url=$(apt-get download --print-uris raspberrypi-kernel | sed -nre "s/'([^']+)'.*$/\1/g;p") + _prefix=$(echo $_url | sed -nre 's/^(.*)raspberrypi-kernel_.*$/\1/g;p') + + download_install_debpkg "$_prefix" "$KERN_NAME" + download_install_debpkg "$_prefix" "$HDR_NAME" + } +} + # 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 + install_kernel # rpi-update checker check_kernel_headers fi diff --git a/seeed-voicecard b/seeed-voicecard index 9a135a1..2e11ef0 100755 --- a/seeed-voicecard +++ b/seeed-voicecard @@ -122,7 +122,8 @@ if [ "$overlay" ]; then rm /etc/asound.conf rm /var/lib/alsa/asound.state - kernel_ver=$(uname -r) # get_kernel_version) +: <<\EOF + kernel_ver=$(get_kernel_version) # echo kernel_ver=$kernel_ver # TODO: dynamic dtoverlay Bug of v4.19.x @@ -137,6 +138,7 @@ if [ "$overlay" ]; then fi done fi +EOF #make sure the driver loads correctly dtoverlay -d $OVERLAYS $overlay || true From b83519eb828fd59b1e40947aa1dfe0d8872719b8 Mon Sep 17 00:00:00 2001 From: Psycho Date: Sun, 9 Aug 2020 17:57:20 +0200 Subject: [PATCH 20/30] English correction --- install.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index 872b428..ba309ca 100755 --- a/install.sh +++ b/install.sh @@ -7,7 +7,7 @@ if [[ $EUID -ne 0 ]]; then exit 1 fi -# Check for enough space on /boot volume +# Check if 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 .." @@ -89,10 +89,10 @@ function check_kernel_headers() { # 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." + echo " Couldn't find *** corresponding *** kernel headers with apt-get." + echo " This may happen if you ran 'rpi-update'." + echo " Choose *** y *** to revert the kernel to version $VER_HDR and continue." + echo " Choose *** N *** to 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 @@ -118,7 +118,7 @@ function download_install_debpkg() { function install_kernel() { local _url _prefix - # Instead of retriving the lastest kernel & headers + # Instead of retrieving the lastest kernel & headers [ "X$FORCE_KERNEL" == "X" ] && { # Raspbian kernel packages apt-get -y --force-yes install raspberrypi-kernel-headers raspberrypi-kernel @@ -195,8 +195,8 @@ 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 alsa plugins +# we don't 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 @@ -246,6 +246,6 @@ systemctl enable seeed-voicecard.service systemctl start seeed-voicecard echo "------------------------------------------------------" -echo "Please reboot your raspberry pi to apply all settings" +echo "Please reboot your device to apply all settings" echo "Enjoy!" echo "------------------------------------------------------" From 901b451bd53734419f0ae2641f7f21d6401b3cbf Mon Sep 17 00:00:00 2001 From: KillingJacky Date: Mon, 27 Apr 2020 07:58:47 +0100 Subject: [PATCH 21/30] add an cmd line option for choosing compile with compatible kernel; clean up more when uninstalling --- install.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index ba309ca..71685a1 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/bin/bash -FORCE_KERNEL="1.20190925+1-1" +FORCE_KERNEL="1.20200819-1" if [[ $EUID -ne 0 ]]; then echo "This script must be run as root (use sudo)" 1>&2 @@ -115,6 +115,14 @@ function download_install_debpkg() { return $r } +option_pattern="compat-kernel" +if [[ $1 =~ ${option_pattern} ]]; then + echo "will compile with a compatible kernel..." +else + FORCE_KERNEL="" + echo "will compile with the latest kernel..." +fi + function install_kernel() { local _url _prefix @@ -181,6 +189,10 @@ function install_module { for _i in $kernels; do dkms build -k $_i -m $mod -v $ver && { dkms install --force -k $_i -m $mod -v $ver + } || { + echo "Can't compile with this kernel, aborting" + echo "Please try to compile with the option --compat-kernel" + exit 1 } done From 957b1298d5b7018af485fa3c57c78cc151b78aab Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 08:09:25 +0100 Subject: [PATCH 22/30] Add: more convenience error message about /boot free space --- install.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 71685a1..32110cf 100755 --- a/install.sh +++ b/install.sh @@ -8,21 +8,20 @@ if [[ $EUID -ne 0 ]]; then fi # Check if enough space on /boot volume -boot_line=$(df -h | grep /boot | head -n 1) +boot_line=$(df -BM | grep /boot | head -n 1) +MIN_BOOT_SPC=25 # MegaBytes 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 + if [[ "$unit" != "M" ]]; then + echo "Warning: /boot volume not found .." + elif [ "$free_space" -lt "$MIN_BOOT_SPC" ]; then echo "Error: Not enough space left ($boot_space) on /boot" + echo " at least $MIN_BOOT_SPC MB required" 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 From 4cec9e73df8a7291f28dddd5e9e5819bf858317b Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 09:12:35 +0100 Subject: [PATCH 23/30] Fix: probing architecture when installing specific package --- install.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 32110cf..3d5e311 100755 --- a/install.sh +++ b/install.sh @@ -55,6 +55,7 @@ fi ver="0.3" uname_r=$(uname -r) +arch_r=$(dpkg --print-architecture) # we create a dir with this version to ensure that 'dkms remove' won't delete # the sources during kernel updates @@ -133,8 +134,8 @@ function install_kernel() { apt-get -y install linux-raspi linux-headers-raspi linux-image-raspi } || { # We would like to a fixed version - KERN_NAME=raspberrypi-kernel_${FORCE_KERNEL}_armhf.deb - HDR_NAME=raspberrypi-kernel-headers_${FORCE_KERNEL}_armhf.deb + KERN_NAME=raspberrypi-kernel_${FORCE_KERNEL}_${arch_r}.deb + HDR_NAME=raspberrypi-kernel-headers_${FORCE_KERNEL}_${arch_r}.deb _url=$(apt-get download --print-uris raspberrypi-kernel | sed -nre "s/'([^']+)'.*$/\1/g;p") _prefix=$(echo $_url | sed -nre 's/^(.*)raspberrypi-kernel_.*$/\1/g;p') From 74620fbdbf8ac7819e964ac8b71c26feda22180b Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 09:13:55 +0100 Subject: [PATCH 24/30] Remove: useless dd message in get_kernel_version() --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 3d5e311..a49f114 100755 --- a/install.sh +++ b/install.sh @@ -70,7 +70,7 @@ function get_kernel_version() { 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)) | zcat | grep -a -m1 "Linux version" | strings | awk '{ print $3; }') + _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 From 6af23967a50abb13647fd72c5a8ae861b1a5ae30 Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 09:14:54 +0100 Subject: [PATCH 25/30] Add: prevent install package again in download_install_debpkg() --- install.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index a49f114..04747a0 100755 --- a/install.sh +++ b/install.sh @@ -103,9 +103,19 @@ function check_kernel_headers() { } function download_install_debpkg() { - local prefix name r + local prefix name r pkg status _name prefix=$1 name=$2 + pkg=${name%%_*} + + status=$(dpkg -l $pkg | tail -1) + _name=$( echo "$status" | awk '{ printf "%s_%s_%s", $2, $3, $4; }') + status=$(echo "$status" | awk '{ printf "%s", $1; }') + + if [ "X$status" == "Xii" -a "X${name%.deb}" == "X$_name" ]; then + echo "debian package $name already installed." + return 0 + fi for (( i = 0; i < 3; i++ )); do wget $prefix$name -O /tmp/$name && break From 30216a9c7cd8287372a48a02032d19ccfd2d7b29 Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 09:15:41 +0100 Subject: [PATCH 26/30] Add: probing kernel postfix automatically for dkms --- install.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 04747a0..69e011d 100755 --- a/install.sh +++ b/install.sh @@ -174,8 +174,9 @@ fi # 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) +# kernels="${base_ver}+ ${base_ver}-v7+ ${base_ver}-v7l+" +# select exact kernel postfix +kernels=${base_ver}$(echo $uname_r | sed -re 's/^[0-9.]+(.*)/\1/g') function install_module { local _i From 0abc6ed072c731768b2abdb0082a00c5f6c74dc7 Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 11:00:37 +0100 Subject: [PATCH 27/30] Add: checking current directory when installing --- install.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/install.sh b/install.sh index 69e011d..ad0ca61 100755 --- a/install.sh +++ b/install.sh @@ -48,6 +48,13 @@ for cmd in dtparam dtoverlay ; do errorFound=1 fi done + +if [ ! -x seeed-voicecard -o ! -f seeed-voicecard.service ]; then + echo "Please run this script in the project directory" + echo "which has files such as install.sh and seeed-voicecard.service" + errorFound=1 +fi + if [ $errorFound = 1 ] ; then echo "Errors found, exiting." 1>&2 exit 1 From b5def1af8ed71783f5dd067afb8d3c9d260a9899 Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 11:01:51 +0100 Subject: [PATCH 28/30] Add: script option --keep-kernel to not change current kernel --- install.sh | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index ad0ca61..3be9d4d 100755 --- a/install.sh +++ b/install.sh @@ -132,13 +132,48 @@ function download_install_debpkg() { return $r } -option_pattern="compat-kernel" -if [[ $1 =~ ${option_pattern} ]]; then +function usage() { + cat <<-__EOF__ + usage: sudo ./install [ --compat-kernel | --keep-kernel ] [ -h | --help ] + default action is update kernel & headers to latest version. + --compat-kernel uses an older kernel but ensures that the driver can work. + --keep-kernel don't change/update the system kernel, maybe install + coressponding kernel headers. + --help show this help message +__EOF__ + exit 1 +} + +compat_kernel= +keep_kernel= +# parse commandline options +while [ ! -z "$1" ] ; do + case $1 in + -h|--help) + usage + ;; + --compat-kernel) + compat_kernel=Y + ;; + --keep-kernel) + keep_kernel=Y + ;; + esac + shift +done + +if [ "X$keep_kernel" != "X" ]; then + FORCE_KERNEL=$(dpkg -s raspberrypi-kernel | awk '/^Version:/{printf "%s\n",$2;}') + echo "Keep current system kernel not to change" +elif [ "X$compat_kernel" != "X" ]; then echo "will compile with a compatible kernel..." else FORCE_KERNEL="" echo "will compile with the latest kernel..." fi +[ "X$FORCE_KERNEL" != "X" ] && { + echo -e "The kernel & headers use package version: $FORCE_KERNEL\r\n\r\n" +} function install_kernel() { local _url _prefix From 2baddde5ba0418cba4aaa6a4704715d4b410c9e7 Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 11:03:03 +0100 Subject: [PATCH 29/30] Fix: install ubuntu kernel only if debian kernel install failed --- install.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 3be9d4d..e806c40 100755 --- a/install.sh +++ b/install.sh @@ -181,9 +181,10 @@ function install_kernel() { # Instead of retrieving the lastest kernel & headers [ "X$FORCE_KERNEL" == "X" ] && { # Raspbian kernel packages - apt-get -y --force-yes install raspberrypi-kernel-headers raspberrypi-kernel - # Ubuntu kernel packages - apt-get -y install linux-raspi linux-headers-raspi linux-image-raspi + apt-get -y --force-yes install raspberrypi-kernel-headers raspberrypi-kernel || { + # Ubuntu kernel packages + apt-get -y install linux-raspi linux-headers-raspi linux-image-raspi + } } || { # We would like to a fixed version KERN_NAME=raspberrypi-kernel_${FORCE_KERNEL}_${arch_r}.deb From 84247b003709f64e90533729d94b695f9a1978c1 Mon Sep 17 00:00:00 2001 From: Andre Marschalek <39925052+cyberh0me@users.noreply.github.com> Date: Sat, 22 Aug 2020 15:17:14 +0200 Subject: [PATCH 30/30] Update seeed-voicecard to avoid systemd error messages because of failed service start systemctl restart seeed-voicecard.service Job for seeed-voicecard.service failed because the control process exited with error code. See "systemctl status seeed-voicecard.service" and "journalctl -xe" for details. --- seeed-voicecard | 2 ++ 1 file changed, 2 insertions(+) diff --git a/seeed-voicecard b/seeed-voicecard index 2e11ef0..b94ec20 100755 --- a/seeed-voicecard +++ b/seeed-voicecard @@ -161,3 +161,5 @@ alsactl restore if aplay -l | grep -q "bcm2835 ALSA"; then amixer cset numid=3 1 || true fi + +exit 0