From c3ddbb521da74f29b49f5b95a03a46d49cc4f779 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Thu, 13 Aug 2020 16:20:25 +0100 Subject: [PATCH 01/10] likely v5 kernels behave like late 4.x, regarding dynamic dtoverlay; untested, and possibly revisit. --- seeed-voicecard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seeed-voicecard b/seeed-voicecard index 5c9fa16..f693ed3 100755 --- a/seeed-voicecard +++ b/seeed-voicecard @@ -127,7 +127,7 @@ if [ "$overlay" ]; then # TODO: dynamic dtoverlay Bug of v4.19.x # no DT node phandle inserted. - if [[ "$kernel_ver" =~ ^4\.19.*$ ]]; then + if [[ "$kernel_ver" =~ ^4\.19.*$ || "$kernel_ver" =~ ^5\.*$ ]]; then for i in $RPI_HATS; do if [ "$i" == "$overlay" ]; then do_overlay $overlay 0 From d8775ccb934776215f9ccced3500a427b9cd60c2 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Thu, 13 Aug 2020 17:08:51 +0100 Subject: [PATCH 02/10] Use pr_info() for regular information --- ac108.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ac108.c b/ac108.c index 8c09143..29e0a94 100644 --- a/ac108.c +++ b/ac108.c @@ -1436,8 +1436,8 @@ static int ac108_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *i if (of_property_read_u32(np, "tdm-chips-count", &val)) val = 1; ac10x->tdm_chips_cnt = val; - pr_err(" ac10x i2c_id number: %d\n", index); - pr_err(" ac10x data protocol: %d\n", ac10x->data_protocol); + pr_info(" ac10x i2c_id number: %d\n", index); + pr_info(" ac10x data protocol: %d\n", ac10x->data_protocol); ac10x->i2c[index] = i2c; ac10x->i2cmap[index] = devm_regmap_init_i2c(i2c, &ac108_regmap); @@ -1459,7 +1459,7 @@ static int ac108_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *i ac10x_fill_regcache(&i2c->dev, ac10x->i2cmap[index]); ac10x->codec_cnt++; - pr_err(" ac10x codec count : %d\n", ac10x->codec_cnt); + pr_info(" ac10x codec count : %d\n", ac10x->codec_cnt); ret = sysfs_create_group(&i2c->dev.kobj, &ac108_debug_attr_group); if (ret) { From 07dc49259ac8c16e44f730003021cc15d19d7bd3 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Tue, 18 Aug 2020 23:30:21 +0100 Subject: [PATCH 03/10] remove "-c 1" and also protect with test for older kernel / alsa The "-c 1" was simply wrong. The default (-c 0) sound device of older kernel / alsa has a numid=3 selector for auto vs headphone vs hdmi . Newer kernel simply has multiple devices. Also, headphone is -c 0 . $ amixer contents numid=2,iface=MIXER,name='Headphone Playback Switch' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=1,iface=MIXER,name='Headphone Playback Volume' ; type=INTEGER,access=rw---R--,values=1,min=-10239,max=400,step=0 : values=-2000 | dBscale-min=-102.39dB,step=0.01dB,mute=1 TODO: For now, broadly dividing by kernel v4.x vs v5.x is good enough, but it would be nice to find out when / which kernel /alsa this is relevant. closes https://github.com/respeaker/seeed-voicecard/issues/240 --- seeed-voicecard | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/seeed-voicecard b/seeed-voicecard index f693ed3..f8c3986 100755 --- a/seeed-voicecard +++ b/seeed-voicecard @@ -150,5 +150,6 @@ fi alsactl restore #Force 3.5mm ('headphone') jack -amixer -c 1 cset numid=3 1 || true - +if [[ "$kernel_ver" =~ ^4\.*$ ]]; then + amixer cset numid=3 1 || true +fi From 71f01070d876f7eeec620525befe039786dcb6ee Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Fri, 21 Aug 2020 16:27:08 +0100 Subject: [PATCH 04/10] spelling --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 1252048..f9ab572 100755 --- a/install.sh +++ b/install.sh @@ -77,7 +77,7 @@ function check_kernel_headers() { # echo RUN=$VER_RUN HDR=$VER_HDR echo " !!! Your kernel version is $VER_RUN" - echo " Not found *** coressponding *** kernel headers with apt-get." + 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." From 1f9c1464ab9253488965a77e963f4805a6ccc4c2 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Sun, 23 Aug 2020 18:12:49 +0100 Subject: [PATCH 05/10] make the overlay install directory configurable, for Ubuntu --- install.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index f9ab572..209aab3 100755 --- a/install.sh +++ b/install.sh @@ -31,8 +31,11 @@ fi # - check for /boot/overlays # - dtparam and dtoverlay is available errorFound=0 -if [ ! -d /boot/overlays ] ; then - echo "/boot/overlays not found or not a directory" 1>&2 +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? @@ -144,9 +147,9 @@ install_module "./" "seeed-voicecard" # install dtbos -cp seeed-2mic-voicecard.dtbo /boot/overlays -cp seeed-4mic-voicecard.dtbo /boot/overlays -cp seeed-8mic-voicecard.dtbo /boot/overlays +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 From 5cefec4cca188aa7985fdb2589935010b652f30e Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Sun, 23 Aug 2020 18:27:31 +0100 Subject: [PATCH 06/10] make the config file configurable, for Ubuntu --- install.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 209aab3..a0b2802 100755 --- a/install.sh +++ b/install.sh @@ -165,13 +165,16 @@ grep -q "^snd-soc-wm8960$" /etc/modules || \ echo "snd-soc-wm8960" >> /etc/modules #set dtoverlays -sed -i -e 's:#dtparam=i2c_arm=on:dtparam=i2c_arm=on:g' /boot/config.txt || true -grep -q "^dtoverlay=i2s-mmap$" /boot/config.txt || \ - echo "dtoverlay=i2s-mmap" >> /boot/config.txt +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$" /boot/config.txt || \ - echo "dtparam=i2s=on" >> /boot/config.txt +grep -q "^dtparam=i2s=on$" $CONFIG || \ + echo "dtparam=i2s=on" >> $CONFIG #install config files mkdir /etc/voicecard || true From 60e90d6faec16309a619e060049feed9890e8490 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Sun, 23 Aug 2020 18:52:11 +0100 Subject: [PATCH 07/10] Ubuntu kernels is not at /boot/kernel.img. Revisit for Raspbian check running kernel agree with installed kernel, and ask the user to reboot before continue Ubuntu kernels are not installed at /boot/kernel.img --- install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index a0b2802..d348026 100755 --- a/install.sh +++ b/install.sh @@ -113,7 +113,8 @@ 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="${base_ver}+ ${base_ver}-v7+ ${base_ver}-v7l+" +kernels=$(uname -r) function install_module { local _i From 7f88e11fd01dfaf67f5905e79b2f4c89e6f9b5cb Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Sun, 23 Aug 2020 19:17:30 +0100 Subject: [PATCH 08/10] adding advice to run ./ubuntu-prerequisite.sh in install.sh --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index d348026..ff03511 100755 --- a/install.sh +++ b/install.sh @@ -42,6 +42,7 @@ fi 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 From 6bcd4cad2f9406b995507610d42385acb41932ba Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Sun, 23 Aug 2020 20:17:17 +0100 Subject: [PATCH 09/10] /opt/vc/bin is not on standard $PATH on Ubuntu --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index ff03511..3268e69 100755 --- a/install.sh +++ b/install.sh @@ -39,6 +39,7 @@ if [ ! -d $OVERLAYS ] ; then 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 From 88aae48c41e58427a1a80f3348d8e2fcc484b2e3 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Sun, 23 Aug 2020 20:23:37 +0100 Subject: [PATCH 10/10] adding new ubuntu-prerequisite.sh script notes and typo --- ubuntu-prerequisite.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 ubuntu-prerequisite.sh diff --git a/ubuntu-prerequisite.sh b/ubuntu-prerequisite.sh new file mode 100755 index 0000000..f938a7a --- /dev/null +++ b/ubuntu-prerequisite.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# Copyright (c) Hin-Tak Leung 2020 +# +# Overview: +# This script compiles and install the Broadcom VideoCore tools, +# configure the dynamic loader for the non-standard library location, +# and update the loader cache. +# +# A few steps explicitly requires root privilege, which are +# marked with "sudo". The rest is just checking for duplicate/previous +# action. +# +# This derived from my command history on ubuntu 20.04.1 .YMMV + +sudo apt install -y git gcc make alsa-utils cmake + +git clone git://github.com/raspberrypi/userland.git +pushd userland/ + +arch=$(uname -m) +if [[ "$arch" =~ aarch64 ]]; then + ./buildme --aarch64 +else + ./buildme +fi +# ./buildme already includes "sudo make install" at the end + +popd + +# matches Raspbian's location: +if [ ! -f /etc/ld.so.conf.d/00-vmcs.conf ] ; then + echo "/opt/vc/lib" | sudo tee -a /etc/ld.so.conf.d/00-vmcs.conf + sudo ldconfig -v +else + echo "/etc/ld.so.conf.d/00-vmcs.conf exists - no need to update ld.cache!" +fi