respeaker / seeed-voicecard

2 Mic Hat, 4 Mic Array, 6-Mic Circular Array Kit, and 4-Mic Linear Array Kit for Raspberry Pi
GNU General Public License v3.0
471 stars 284 forks source link

Add support for Ubuntu (aarch64) #211

Closed mxklb closed 3 years ago

mxklb commented 4 years ago

When trying to install the driver on Ubuntu with Raspberry PI 4

root@ubuntu:/# uname -a
Linux ubuntu 5.3.0-1018-raspi2 #20-Ubuntu SMP Mon Feb 3 19:45:46 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux

I get /boot/overlays not found or not a directory error:

root@ubuntu:/seeed-voicecard# ./install.sh 
/boot/overlays not found or not a directory
dtparam not found
dtoverlay not found
Errors found, exiting.

It would be nice to be able to install the driver on other Linux distributions commonly used with a PI.

Is there any chance to install/compile the driver with Ubuntu aarch64 on a PI 4?

AKrause4 commented 4 years ago

I had this exact same issue when trying to install the driver on Jetson Nano (Developer Kit edition), did not have issues on Raspberry Pi 4 with Raspbian Buster

AKrause4 commented 4 years ago

The boot directory is not on its own partition, is that required?

anna@elf:~/seeed-voicecard$ df -h Filesystem Size Used Avail Use% Mounted on /dev/mmcblk0p1 118G 12G 102G 10% / none 1.7G 0 1.7G 0% /dev tmpfs 2.0G 181M 1.8G 10% /dev/shm tmpfs 2.0G 77M 1.9G 4% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup tmpfs 396M 132K 396M 1% /run/user/1000

mxklb commented 4 years ago

The main difference is that files configured by seeed-voicecard/install.sh are located in /boot/firmware on ubuntu while raspbian has them directly in /boot. Ubuntu may also handle some boot config files slightly different but main purpose is the same. The seeed-voicecard/install.sh requires files to be in /boot, so therefore the install script stops early before doing anything.

@AKrause4 It is commonly known that the driver works on raspbian, its developed for this OS. This Issue is a feature request to support Ubuntu! Special partitioning of boot generally is not required, see: https://serverfault.com/questions/334663/what-is-the-recommended-size-for-a-linux-boot-partition But are you shure that you've used vanilla flashed PI 4 ubuntu aarch64. The sd-card should be partitioned into boot and root file-systems, mine looks like this:

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1.9G     0  1.9G   0% /dev
tmpfs           380M  4.3M  375M   2% /run
/dev/mmcblk0p2   59G  5.9G   51G  11% /
tmpfs           1.9G     0  1.9G   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/loop0       81M   81M     0 100% /snap/core/8596
/dev/loop1       81M   81M     0 100% /snap/core/8691
/dev/loop3       60M   60M     0 100% /snap/lxd/13477
/dev/mmcblk0p1  253M  127M  127M  51% /boot/firmware
/dev/loop4       60M   60M     0 100% /snap/lxd/13489
tmpfs           380M  4.0K  380M   1% /run/user/1004 
hhuysqt commented 4 years ago

I also have the identical issue on Ubuntu Server 1804 on RPI 4 with 4GB RAM. I prefer Ubuntu because the official 32-bit Raspbian cannot support up to 4GB RAM out of the box. Support for Ubuntu is strongly demanded :)

hhuysqt commented 4 years ago

See seeed-voicecard-v5.3.c for my ad-hoc solution. I made some modification to work on linux kernel v5.3.0 or higher, which has merged some API changes on simple_card: patch1: separate asoc_simple_card_parse_dai() and patch2: rename asoc_simple_card_xxx(). To install it on my 64-bit RPI4 Ubuntu 1804 with kernel 5.3.0-1019-raspi2, I manually follow the instructions in install.sh. Since there is neither dtparam nor dtoverlay command on ubuntu, I manually insert the device tree blob in sysfs.

dony71 commented 4 years ago

@hhuysqt : how do you apply patch for kernel 5.5.7 ? in simple_card_utils.h, there is NOT any function asoc_simplecard but instead asocsimple (card omitted)

hhuysqt commented 4 years ago

@dony71 Well, I don't patch the kernel, but I modify the driver. See seeed-voicecard-v5.3.c, I change asoc_simplecard to asocsimple, and commit other changes as well to match the new simple card APIs in the kernel.

dony71 commented 4 years ago

@hhuysqt I try to compile without patching simple_card_utils.h and get this error below

pi64 /var/lib/dkms/seeed-voicecard/0.3/build # vi make.log 866 | dev_dbg(dai->dev, "used as slave when AC101 is master\n"); | ^~~ /var/lib/dkms/seeed-voicecard/0.3/build/ac108.c:868:2: note: here 868 | case SND_SOC_DAIFMT_CBS_CFS: /AC108 Slave/ | ^~~~ /var/lib/dkms/seeed-voicecard/0.3/build/wm8960.c: In function ‘wm8960_hw_params’: /var/lib/dkms/seeed-voicecard/0.3/build/wm8960.c:752:6: warning: this statement may fall through [-Wimplicit-fallthrough=] 752 | if ((iface & 0x3) != 0) { | ^ /var/lib/dkms/seeed-voicecard/0.3/build/wm8960.c:756:2: note: here 756 | default: | ^~~ /var/lib/dkms/seeed-voicecard/0.3/build/seeed-voicecard.c: In function ‘seeed_voice_card_parse_aux_devs’: /var/lib/dkms/seeed-voicecard/0.3/build/seeed-voicecard.c:513:28: error: ‘struct snd_soc_aux_dev’ has no member named ‘codec_of_node’ 513 | priv->snd_card.aux_dev[i].codec_of_node = aux_node; | ^ make[1]: [scripts/Makefile.build:266: /var/lib/dkms/seeed-voicecard/0.3/build/seeed-voicecard.o] Error 1 make[1]: Waiting for unfinished jobs.... make: *** [Makefile:1693: /var/lib/dkms/seeed-voicecard/0.3/build] Error 2

hhuysqt commented 4 years ago

@dony71 Oh sorry but I didn't notice the API changes since kernel V5.4... https://elixir.bootlin.com/linux/v5.4-rc1/source/include/sound/soc.h#L965 struct snd_soc_aux_dev::codec_of_node had been changed to struct snd_soc_aux_dev::dlc::of_node As an ad-hoc solution, you may change it to

 priv->snd_card.aux_dev[i].dlc.of_node = aux_node;

But currently the arm64 Ubuntu mirror holds linux-image-5.3.0-1022-raspi2 for 18.04, and linux-image-5.4.0-1006-raspi2 for 20.04, so I'm not going to update my kernel and I'm not sure if there are any other issues...

StuartIanNaylor commented 4 years ago

@dony71 Oh sorry but I didn't notice the API changes since kernel V5.4... https://elixir.bootlin.com/linux/v5.4-rc1/source/include/sound/soc.h#L965 struct snd_soc_aux_dev::codec_of_node had been changed to struct snd_soc_aux_dev::dlc::of_node As an ad-hoc solution, you may change it to

 priv->snd_card.aux_dev[i].dlc.of_node = aux_node;

But currently the arm64 Ubuntu mirror holds linux-image-5.3.0-1022-raspi2 for 18.04, and linux-image-5.4.0-1006-raspi2 for 20.04, so I'm not going to update my kernel and I'm not sure if there are any other issues...

@hhuysqt It was 20.04 day today and just wondering if you fancied having a go at making an easier install for us noobs.

I guess really we just need to take your changes and just apply the bottom part of the script.

dkms build -k $_i -m $mod -v $ver && {
      dkms install --force -k $_i -m $mod -v $ver
    }

Not very knowledgable but rather than the -k $_i if you omit is it just created for current? The perf gains for Pi4 64bit bit are quite considerable so wouldn't mind setting up shop on 20,04 but its just the respeaker that is a pain.

HinTak commented 4 years ago

The standard kernel header /usr/include/linux/version.h , contains the kernel version and a macro for KERNEL_VERSION(a, b,c) which allows you to do version comparison likes here:

https://git.kernel.org/pub/scm/linux/kernel/git/backports/backports.git/tree/backport/backport-include/linux/version.h

(the device driver backport project). what you want is the reverse, porting forward, but the idea is similar: you inserts a few "#if LINUX_VERSION_IS_LESS(x1,x2,x3) ... #endif" everywhere to allow the driver to work for two kernel versions, if they turn out to be different sufficiently.

StuartIanNaylor commented 4 years ago

I just had a go on Archlinux and can not install there :)

Think I will just wait to see if someone will kindly provide something a little more simple for us who don't know much more than the sound card purchased :)

HinTak commented 4 years ago

Ported the code to build against 5.5 headers - https://github.com/HinTak/seeed-voicecard/tree/v5.5 - the details are in the changelog, should work for 5.3(?) 5.4+ .

The install.sh has a few other problems, so it is perhaps best not to use it especially the dkms part, but do "make ; make install" plus copying the dtbo.

HinTak commented 4 years ago

I added the the kernel version checking macro but then realize the needed changes are spread across 5.1/5.2/5.3/5.4 (again, see changelog) so it is too much work to try to make one tree work for all .

StuartIanNaylor commented 4 years ago

Just one error on make

In file included from /home/ubuntu/seeed-voicecard/seeed-voicecard.c:28:
/home/ubuntu/seeed-voicecard/seeed-voicecard.c: In function ‘seeed_voice_card_dai_link_of’:
./include/sound/simple_card_utils.h:101:2: error: implicit declaration of function ‘asoc_simple_parse_dai’; did you mean ‘asoc_simple_parse_clk’? [-Werror                                                       =implicit-function-declaration]
  101 |  asoc_simple_parse_dai(node, dai_link->cpus, is_single_link)

If you could make a branch for 5.4 as being LTS and Ubuntu 20.04 LTS it would be great for dummies such as me :)

But looking like its almost there, thanks Hintak. I would prob create another repo a fork so you can have 2 URLs as dummies such as me will not understand and grab the wrong branch.

ubuntu@ubuntu:~/seeed-voicecard$ make
make -C /lib/modules/5.4.0-1008-raspi/build M=/home/ubuntu/seeed-voicecard modules
make[1]: Entering directory '/usr/src/linux-headers-5.4.0-1008-raspi'
  CC [M]  /home/ubuntu/seeed-voicecard/wm8960.o
/home/ubuntu/seeed-voicecard/wm8960.c: In function ‘wm8960_hw_params’:
/home/ubuntu/seeed-voicecard/wm8960.c:752:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
  752 |   if ((iface & 0x3) != 0) {
      |      ^
/home/ubuntu/seeed-voicecard/wm8960.c:756:2: note: here
  756 |  default:
      |  ^~~~~~~
  LD [M]  /home/ubuntu/seeed-voicecard/snd-soc-wm8960.o
  CC [M]  /home/ubuntu/seeed-voicecard/ac108.o
In file included from ./include/linux/printk.h:353,
                 from ./include/linux/kernel.h:15,
                 from ./include/linux/list.h:9,
                 from ./include/linux/module.h:9,
                 from /home/ubuntu/seeed-voicecard/ac108.c:15:
/home/ubuntu/seeed-voicecard/ac108.c: In function ‘ac108_set_fmt’:
./include/linux/dynamic_debug.h:122:52: warning: this statement may fall through [-Wimplicit-fallthrough=]
  122 | #define __dynamic_func_call(id, fmt, func, ...) do { \
      |                                                    ^
./include/linux/dynamic_debug.h:143:2: note: in expansion of macro ‘__dynamic_func_call’
  143 |  __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__)
      |  ^~~~~~~~~~~~~~~~~~~
./include/linux/dynamic_debug.h:157:2: note: in expansion of macro ‘_dynamic_func_call’
  157 |  _dynamic_func_call(fmt,__dynamic_dev_dbg,   \
      |  ^~~~~~~~~~~~~~~~~~
./include/linux/device.h:1810:2: note: in expansion of macro ‘dynamic_dev_dbg’
 1810 |  dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
      |  ^~~~~~~~~~~~~~~
/home/ubuntu/seeed-voicecard/ac108.c:866:4: note: in expansion of macro ‘dev_dbg’
  866 |    dev_dbg(dai->dev, "used as slave when AC101 is master\n");
      |    ^~~~~~~
/home/ubuntu/seeed-voicecard/ac108.c:868:2: note: here
  868 |  case SND_SOC_DAIFMT_CBS_CFS:    /*AC108 Slave*/
      |  ^~~~
  CC [M]  /home/ubuntu/seeed-voicecard/ac101.o
  LD [M]  /home/ubuntu/seeed-voicecard/snd-soc-ac108.o
  CC [M]  /home/ubuntu/seeed-voicecard/seeed-voicecard.o
In file included from /home/ubuntu/seeed-voicecard/seeed-voicecard.c:28:
/home/ubuntu/seeed-voicecard/seeed-voicecard.c: In function ‘seeed_voice_card_dai_link_of’:
./include/sound/simple_card_utils.h:101:2: error: implicit declaration of function ‘asoc_simple_parse_dai’; did you mean ‘asoc_simple_parse_clk’? [-Werror                                                       =implicit-function-declaration]
  101 |  asoc_simple_parse_dai(node, dai_link->cpus, is_single_link)
      |  ^~~~~~~~~~~~~~~~~~~~~
/home/ubuntu/seeed-voicecard/seeed-voicecard.c:304:8: note: in expansion of macro ‘asoc_simple_parse_cpu’
  304 |  ret = asoc_simple_parse_cpu(cpu, dai_link, &single_cpu);
      |        ^~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:275: /home/ubuntu/seeed-voicecard/seeed-voicecard.o] Error 1
make[1]: *** [Makefile:1722: /home/ubuntu/seeed-voicecard] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-1008-raspi'
make: *** [Makefile:37: all] Error 2
ubuntu@ubuntu:~/seeed-voicecard$ In file included from /home/ubuntu/seeed-voicecard/seeed-voicecard.c:28:
In: command not found
ubuntu@ubuntu:~/seeed-voicecard$ /home/ubuntu/seeed-voicecard/seeed-voicecard.c: In function ‘seeed_voice_card_dai_link_of’:
-bash: /home/ubuntu/seeed-voicecard/seeed-voicecard.c:: No such file or directory
ubuntu@ubuntu:~/seeed-voicecard$ ./include/sound/simple_card_utils.h:101:2: error: implicit declaration of function ‘asoc_simple_parse_dai’; did you mean ‘asoc_simple_parse_clk’? [-Werror                                                       =implicit-function-declaration]
-bash: ./include/sound/simple_card_utils.h:101:2:: No such file or directory

Command 'did' not found, but there are 19 similar ones.

ubuntu@ubuntu:~/seeed-voicecard$   101 |  asoc_simple_parse_dai(node, dai_link->cpus, is_single_link)
-bash: syntax error near unexpected token `node,'

Complete output and looks so near but also for me so far :)

StuartIanNaylor commented 4 years ago

Ported the code to build against 5.5 headers - https://github.com/HinTak/seeed-voicecard/tree/v5.5 - the details are in the changelog, should work for 5.3(?) 5.4+ .

The install.sh has a few other problems, so it is perhaps best not to use it especially the dkms part, but do "make ; make install" plus copying the dtbo.

Hintak any chance you could port against 5.4 as 5.5 is already EOL. 5.4 is LTS so at least will run to 2023

HinTak commented 4 years ago

There is not further work between 5.4 and 5.5 (i.e. None of the changes so far is 5.5 specific). I called the branch v5.5 mostly because I am cross-developing from a 5.5 host. As I said, see the changelog - each of the changes say what version of kernel it is needed.

StuartIanNaylor commented 4 years ago
In file included from /home/ubuntu/seeed-voicecard/seeed-voicecard.c:28:
/home/ubuntu/seeed-voicecard/seeed-voicecard.c: In function ‘seeed_voice_card_dai_link_of’:
./include/sound/simple_card_utils.h:101:2: error: implicit declaration of function ‘asoc_simple_parse_dai’; did you mean ‘asoc_simple_parse_clk’? [-Werror=implicit-function-declarat                    ion]
  101 |  asoc_simple_parse_dai(node, dai_link->cpus, is_single_link)
      |  ^~~~~~~~~~~~~~~~~~~~~
/home/ubuntu/seeed-voicecard/seeed-voicecard.c:304:8: note: in expansion of macro ‘asoc_simple_parse_cpu’
  304 |  ret = asoc_simple_parse_cpu(cpu, dai_link, &single_cpu);
      |        ^~~~~~~~~~~~~~~~~~~~~

This is on 5.4 and it doesn't work that is all I know, apols.

parse_daifmt ?

StuartIanNaylor commented 4 years ago

If you copy the dtbo to /boot/firmware/overlays and set /boot/firmware usrcfg.txt

dtparam=i2s=on
dtoverlay=i2s-mmap
dtoverlay=seeed-2mic-voicecard

It actually finds a wm8960 alsactl and everything is there just not sound or recording. Noticed it in the kernel for 5.4 and thought give 20.04 a go but no.

But its there :)

ubuntu@ubuntu:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 7/7
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 IEC958/HDMI [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: ALSA [bcm2835 ALSA], device 2: bcm2835 IEC958/HDMI1 [bcm2835 IEC958/HDMI1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: seeed2micvoicec [seeed-2mic-voicecard], device 0: bcm2835-i2s-wm8960-hifi wm8960-hifi-0 [bcm2835-i2s-wm8960-hifi wm8960-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
HinTak commented 4 years ago

I have looked at the log, for some reason asoc_simple_parse_dai was made static (private) - I.E. You are supposed to use one of the public functions which wraps it. An ugly way of doing it would be to make another private static copy, which was what @hhuysqt did with one such part. I did look at his work after I finished mine - it is more or less the same, but in one big lump (and also some unrelated/questionable extra). I don't think it is a good idea to do such modification in one lump wholesale, though I might have presented mine that way if I have not anticipated reviews/questions.

HinTak commented 4 years ago

The device tree overlay tells the kernel what composite sound hardware is present and how it relates to the individual ICs and circuitry. So it is not surprising that just loading the overlay gives alsa the ability to "see" a card. The c part of the respeaker driver code is strictly speaking a collection of driver code for the individual IC/circuitry bits, connected by the dt overlay.

StuartIanNaylor commented 4 years ago

I have looked at the log, for some reason asoc_simple_parse_dai was made static (private) - I.E. You are supposed to use one of the public functions which wraps it. An ugly way of doing it would be to make another private static copy, which was what @hhuysqt did with one such part. I did look at his work after I finished mine - it is more or less the same, but in one big lump (and also some unrelated/questionable extra). I don't think it is a good idea to do such modification in one lump wholesale, though I might have presented mine that way if I have not anticipated reviews/questions.

With all honesty the driver situation with these cards is extremely bad. Even on raspbian the lockdown to a previous kernel can cause many problems and restrict use of a very varied distro. The use of the PI4 has a big interest in 64bit OS due to perf gains and Ubuntu until Raspbian catches up does provide a modern LTS 64 bit kernel and has huge interest. Problems do go further though as from watching the install in progress and the large amount of libs it installs for a 'simple_card' I have already run into problems where why the cards needs a JackD lib I am unsure but installing a voice AI Mycroft causes a dependency clash and its replaced by another lib and renders no audio.

I have little idea about the api and how kernel changes have made that problematic but all I know is the kernel lockdown in Raspbian is extremely bad and massively restrictive in the use of the Pi. Also for some reason a linux sound card driver seems to be sensitive to what is installed as audio packages, which is also extremely bad. The driver installs services and overwrites asound.conf and settings and the question is why. What that install does, why and reason is a mystery and the only thing blatantly clear is that its extremely bad.

We need core drivers that are not dependent on installable packages that runs on Raspbian and the latest LTS. So its 4.19 and 5.4 and current whats in between actually matters little as the current support for 4.19 and 5.4 is somewhere between non existent and absolutely woeful.

But it would seem this all-in-one design of multiple cards has set an enormous task.

StuartIanNaylor commented 4 years ago

The device tree overlay tells the kernel what composite sound hardware is present and how it relates to the individual ICs and circuitry. So it is not surprising that just loading the overlay gives alsa the ability to "see" a card. The c part of the respeaker driver code is strictly speaking a collection of driver code for the individual IC/circuitry bits, connected by the dt overlay.

I was looking at https://github.com/torvalds/linux/blob/master/sound/soc/codecs/wm8960.c

MODULE_DESCRIPTION("ASoC WM8960 driver");
--
  | MODULE_AUTHOR("Liam Girdwood");

Yeah I guess all we are missing is codec handling.

HinTak commented 4 years ago

The respeaker, at least the 6-mic version I have, have 3 on-board ICs, ac101 and ac108 . The c code glues in those.

StuartIanNaylor commented 4 years ago

That is my point we have 2mic, 4 mic, 6 mic with various chips all sharing a single driver that unless you use a single old dated kernel none work! The C code does not glue those in as they are seperate hardware but a single driver does.

HinTak commented 4 years ago

There is already an issue opened about removing the forced kernel downgrade - https://github.com/respeaker/seeed-voicecard/issues/209 - I am all for it. To be honest it was a temporary workaround for an upstream issue that was fixed a few months ago (with my pushing them) so can be reverted. Indeed I have a patch to revert that which I meant to issue a pull for here.

While I am against staying at 4.19, I understand the reason - the respeaker card is NOT a simple card, despite its size - it has two buttons on, and 12 LEDs . As I explained earlier: it is a composite device, or perhaps, better described as a daughter add-on extension circuit board.

The main issue is not raspbian vs ubuntu, or 32-bit vs 64-bit, but the amount of changes, re-organization and rewrites in the kernel itself between 4.19 and 5.4 . I have to constantly reference the kernel changelog to see what is changed and why it is changed, and how to adjust to it. I understand why seeed studio does not want to do this work...

(btw, if you go to my page, under font validator's readme, there is a donation link - if either seeed studio or 3Rd party wants to fund the porting work...)

HinTak commented 4 years ago

The connectivity describes the ICs, etc are in the dt overlays and they are also platform-independent (I.E. Works on non-linux too!). The individual IC drivers are actually all very modular - and, honestly not where the porting problem to new kernels is. Please stop advocating breaking into individual "card" drivers - you don't know what you are talking about.

The code is clean enough that for most of the work I have done so far, I was actually building it against x86_64 host rather than aarch64, and it is okay that way - despite x86_64 host does not even have an I2S bus for doing ARM-style audio!

HinTak commented 4 years ago

I updated my v5.5 branch and it should build cleanly on 5.4+ onwards. Also took the chance to add a few fixes and remove the forced kernel downgrade. (you'll still need to correct for the difference in the overlay locations).

If it does not run correctly after install (and putting the overlay in the adjusted place) and reboot, please post the output of "dmesg".

(and perhaps a donation at the HinTak/Font-Validator link to get another sd card, at least, would be nice...)

StuartIanNaylor commented 4 years ago

The connectivity describes the ICs, etc are in the dt overlays and they are also platform-independent (I.E. Works on non-linux too!). The individual IC drivers are actually all very modular - and, honestly not where the porting problem to new kernels is. Please stop advocating breaking into individual "card" drivers - you don't know what you are talking about.

The code is clean enough that for most of the work I have done so far, I was actually building it against x86_64 host rather than aarch64, and it is okay that way - despite x86_64 host does not even have an I2S bus for doing ARM-style audio!

I don't think I have ever seen a linux driver as such and when you have a WM8960 why are other cards installed and even services to detect cards that you will never get. I don't have to know very much to notice the manner of this driver is very strange, that is just very apparent knowledge or not.

I was actually building it against x86_64 host rather than aarch64, and it is okay that way - despite x86_64 host does not even have an I2S bus for doing ARM-style audio!

That is just bizzare you are admitting you are building a device driver on a platform that can not even run it. I feel this weird twilight moment.

HinTak commented 4 years ago

@StuartIanNaylor neither are as bizarre as you think - if you look at the beginning of your raspbian boot message (output of dmesg) - you will find that the raspbian kernel itself is built from cross-compilation. It makes a lot of sense to cross-compile on a much more powerful host. This is very routine for ARM- development.

As I mentioned a few times, the respeaker card is really a composite device / multi-function daughter add-on board. It is also very common for ARM- based add-on boards to have a lot of variants / sub-models. Look under the asoc/soc directory of the kernel tree, rather than the sound tree. (soc = system on chip). You don't know what you are talking about.

StuartIanNaylor commented 4 years ago

The problem is when it comes to creating and developing linux drivers I make no claims of any knowledge and openly admit I don't know. I have 3 Respeaker devices and they are heading for the bin as I am starting to get a strong relisation the dev lead of their drivers is not much different either.

HinTak commented 4 years ago

@StuartIanNaylor - v4.19 was released in October 2018, and raspbian only switched to 4.19 from 4.14 before this winter. That's not bad going for a small company. And seriously, the respeaker works well enough for raspbian (the official pi distro).

I personally am not switching to ubuntu on my pi any time soon - my more interesting focus is this https://github.com/HinTak/vdfs-driver/commits/master - it is Samsung's file system driver for reading their shipping smart speakers and TVs. The public driver code was based on v4.1, which was released in June 2015. Despite the kernel being 5 years old, samsung is still shipping their TVs and smart speakers with it, and in their upcoming products AFAIC. I am porting the file system driver code from v4.1 32-bit arm to v5.5/5.6 x86_64, so am doing a lot of kernel "archeology" anyway, so have a look at this.

You'd have thought a big company like Samsung, and for TVs costing thousands US dollars, they could afford to keep their software up to date? and runs on 64-bit arm ubuntu at least? LOL!

If you can afford 3 respeaker devices (plus 3 pi's to go with it...) - you can afford to buy me a small blank SD card.

StuartIanNaylor commented 4 years ago

I doesn't work well. It works on vanilla raspbian with a clean install.

On completely different services of other installs seeed.voicecard.service fails. On pulseaudio install it often fails.

Apr 28 02:23:52 raspberrypi pulseaudio[669]: W: [alsa-sink-bcm2835-i2s-wm8960-hifi wm8960-hifi-0] alsa-sink.c: Resume failed, couldn't restore original sample set
Apr 28 02:23:52 raspberrypi pulseaudio[669]: W: [alsa-sink-bcm2835-i2s-wm8960-hifi wm8960-hifi-0] alsa-sink.c: Resume failed, couldn't restore original sample set
Apr 28 02:23:52 raspberrypi pulseaudio[669]: W: [alsa-sink-bcm2835-i2s-wm8960-hifi wm8960-hifi-0] alsa-sink.c: Resume failed, couldn't restore original sample set
Apr 28 02:23:52 raspberrypi pulseaudio[669]: W: [alsa-sink-bcm2835-i2s-wm8960-hifi wm8960-hifi-0] alsa-sink.c: Resume failed, couldn't restore original sample set
Apr 28 02:23:52 raspberrypi pulseaudio[669]: W: [alsa-sink-bcm2835-i2s-wm8960-hifi wm8960-hifi-0] alsa-sink.c: Resume failed, couldn't restore original sample set

This is my current journalctl and all I have done is install pulseaudio and enabled the module-echo-cancel

Its a complete fudge so that it reverts to a kernel because all you can make it work is with that and alsa. I am not spending another penny with respeaker or Seeed again as its been a total waste of my my money presuming at least one will work well. They don't and my money will be to buy a sound card that does.

Thank you.

Make a working decent driver that isn't anything more than a bad hack and maybe I would, but I doubt I will be back.

HinTak commented 4 years ago

@StuartIanNaylor - pulseaudio doesn't work is a pulseaudio problem. You should test with aplay / arecord to assure correct functionality. You have not heard that the author of pulseaudio (also being the author of the well-loved-not systemd) often get death threats for making strange and controversial decisions? :-)

If you need my advice on a sound device with a simplier driver that's up to date with current kernel development, have a look at the octo card of audioinjector.net . It offers similar functionalities (just rather not-pretty, as in the actual external physical appearance) with an "up-to-date to current kernel" software stack.

I thought the Samsung illustration is sufficient - Seed Studio builds the respeaker for a "standard raspberry pi setup" (i.e. raspbrian). Anything else, well, it is extra, and I'd be happy they do it but not too upset if they don't. They never claim that it would run on anything else. Until Raspbrian itself moved to 64-bit and a more current kernel, I am okay with anything being DYI. Same with Samsung's TV - okay they charge a lot of money. The TV is for watching TV programmes, and I am not expecting any big help from them on reading their firmware files (my fun activity) any time soon. Expecting Samsung to want to help me to run their firmware file system driver on current desktop linux, is ridiculous.

HinTak commented 4 years ago

Also, I specifically asked for the output of "dmesg" if it does not work. journalctl is not dmesg, it is not, honestly. "dmesg" gives the kernel ring buffer's messages, and is a lot lower level than journalctl. BTW, journalctl (part of systemd) is from the same guy who wrote pulseaudio. You cannot use one of his tools to find out what's wrong with another piece of his software! He does not write buggy software (sarcasm).

StuartIanNaylor commented 4 years ago

@HinTak

(also being the author of the well-loved-not systemd) often get death threats for making strange and controversial decisions? :-)

Its actually unnerving to speak to you, its a tirade of BS. Many thanks for the waste of my time and purchases. Goodbye and hopefully get better. Best wishes.

HinTak commented 4 years ago

@StuartIanNaylor : the guy who wrote pulseaudio, also wrote systemd later (in that order, historically). Quite well-known fact. Many people try to avoid using either, also quite a well-known fact.

I am not sure what kind of tech support you expect for what is, in reality about $40-60 US piece of audio equipment, and what can be reasonably expected. I gave my advice - injector.net 's audio device is functionally similar, and driver works with up-to-date kernels (but the board itself is not aesthetically pretty!).

A typical Samsung smart TV is in x10 price range, and yet I am not expecting that Samsung to respond to my request of using it outside of what they claim to support... Just saying.

gradil commented 4 years ago

In my case, I'm locked to use: 4.15.0-37-generic #40~upboard06-Ubuntu SMP Wed Nov 27 11:29:44 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

I'm using an UP2 (upsquared) Board from AAEON/intel, with R-PI compatible GPIO (already using other Pi-hat boards successfully ).

Is there any support prior to linux kernel v5.3.0? I've not been able to get a workaround.

HinTak commented 4 years ago

@gradil the normal official master should just work for such old kernel.( raspbian ships 4.19)

gradil commented 4 years ago

@HinTak I'm not on raspbian, so I get the errors:

/boot/overlays not found or not a directory dtparam not found dtoverlay not found Errors found, exiting.

So given this I'm trying a solution similar to @hhuysqt solution's.

HinTak commented 4 years ago

@gradil ubuntu put files in different places compared to debian . I think you need to manually copy them into /boot/firmware instead of /boot , or something like that. But there is no code (compiled code) change - just file locations are different.

See earlier remark https://github.com/respeaker/seeed-voicecard/issues/211#issuecomment-619478473

gradil commented 4 years ago

@HinTak Yes it's the approach I'm currently trying. If it really works that linearly I think it should be something to add in the Readme

HinTak commented 4 years ago

Where files are located is really installation/packaging...

HinTak commented 3 years ago

FYI. See #240 , which is likely a 64-bit issue.

edit: fixed - it is just amixer accidentally turning recording volume of channel 3 really low, rather than selecting headphone for output, when run against newer kernel. works perfectly for me on the 6-mic device with ubuntu 64-bit now.

I'll add the userland stuff soon in my branch,

AndreMarschalek commented 3 years ago

please can anyone tell me the exact steps i must do to have this card working on fresh installed Ubuntu with 5.4.0-1015-raspi kernel on Raspberry Pi 4?

HinTak commented 3 years ago

@cyberh0me here it is:

The prerequisite script was written based on my notes/command history while setting my 6-mic up; and it works fine. There are probably some mistakes/typos. I am okay with Seeed Studio or others wanting to sponsor me on testing etc (just click the donate link in my FontValidator repo) - but I don't work for Seeed Studio, so this is provided as is, upto a point where it helps me to make mine work better in the future.

StuartIanNaylor commented 3 years ago

There is also this repo that doesn't need the scripts and services that respeaker provide or have unnessacary kernel freeze or requirements.

https://github.com/pguyot/wm8960

HinTak commented 3 years ago

@StuartIanNaylor I already explained elsewhere - the 2-mics device uses wm8960 for which a number of drivers exists, including built-in to the stock latest linux kernel (i.e. You do not need extra drivers if you use the latest kernel). The 4-mics and 6-mics devices uses the ac101/ac108 for which this is currently the only option AFAIK. If you have a 2-mics device, yes, please feel free to use the alternatives, including just using the latest kernel itself without anything else!

See the wm8960.* files in Linus's tree : https://github.com/torvalds/linux/tree/master/sound/soc/codecs

HinTak commented 3 years ago

I don't agree with Seeed Studio's policy of downgrading to kernels which are a few years old either. Hence the "v5.5" branch, and it is the default branch on mine, because latest raspbian and ubuntu are both 5.4 based. There is a "v5.7" branch for more recent kernels than 5.4 too, and I imagine if there are future incompatible changes in the kernel, I'll make new branches and switch the default too.

https://github.com/HinTak/seeed-voicecard

AndreMarschalek commented 3 years ago

i absolutely agree this produces update problem issues in the future and makes devices unsecure