droelfdroelf / snd-digitakt

ALSA driver for the Elektron Digitakt
44 stars 6 forks source link

Ubuntu build instructions #4

Open alamminsalo opened 4 years ago

alamminsalo commented 4 years ago

Any possibility to get this working on Ubuntu? I almost got it to work by cloning linux sources (v5.4) and including sound/usb/{midi.h, usbaudio.h} from there. I'm unsure if doing this correctly (not much C-background). It seems to compile and when loaded recognizes digitakt. However there is some issue when trying to start jack with it and atleast with lowlatency kernel I had couple freezes when turning the device on/off.

dagargo commented 4 years ago

I tried to use it in Debian Buster (amd64) but I had some kernel freezes too with the standard kernel. Could you check if your issue is related to #1 ?

alamminsalo commented 4 years ago

I believe so, yes

naught101 commented 4 years ago

It would still be good to add some instructions for ubuntu to the README. I haven't managed to get it to work yet. This is what I've tried:

dpkg-query: no packages found matching raspberrypi-kernel-headers*
make -C /lib/modules/5.4.0-31-lowlatency/build M=/home/nedcr/Downloads/source_code/snd-digitakt/sound/usb/misc modules
make[1]: Entering directory '/usr/src/linux-headers-5.4.0-31-lowlatency'
dpkg-query: no packages found matching raspberrypi-kernel-headers*
  CC [M]  /home/nedcr/Downloads/source_code/snd-digitakt/sound/usb/misc/digitakt.o
  LD [M]  /home/nedcr/Downloads/source_code/snd-digitakt/sound/usb/misc/snd-digitakt.o
dpkg-query: no packages found matching raspberrypi-kernel-headers*
  Building modules, stage 2.
  MODPOST 1 modules
  CC [M]  /home/nedcr/Downloads/source_code/snd-digitakt/sound/usb/misc/snd-digitakt.mod.o
  LD [M]  /home/nedcr/Downloads/source_code/snd-digitakt/sound/usb/misc/snd-digitakt.ko
make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-31-lowlatency'

the dpkg errors can be ignored, I think. This results in:

digitakt.c  from-kernel  modules.order   snd-digitakt.ko   snd-digitakt.mod.c  snd-digitakt.o
digitakt.o  Makefile     Module.symvers  snd-digitakt.mod  snd-digitakt.mod.o
dpkg-query: no packages found matching raspberrypi-kernel-headers*
make -C /lib/modules/5.4.0-31-lowlatency/build M=/home/nedcr/Downloads/source_code/snd-digitakt/sound/usb/misc modules
make[1]: Entering directory '/usr/src/linux-headers-5.4.0-31-lowlatency'
dpkg-query: no packages found matching raspberrypi-kernel-headers*
dpkg-query: no packages found matching raspberrypi-kernel-headers*
  Building modules, stage 2.
  MODPOST 1 modules
make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-31-lowlatency'
make -C /lib/modules/5.4.0-31-lowlatency/build M=/home/nedcr/Downloads/source_code/snd-digitakt/sound/usb/misc modules_install
make[1]: Entering directory '/usr/src/linux-headers-5.4.0-31-lowlatency'
  INSTALL /home/nedcr/Downloads/source_code/snd-digitakt/sound/usb/misc/snd-digitakt.ko
At main.c:160:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:69
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:76
sign-file: certs/signing_key.pem: No such file or directory
  DEPMOD  5.4.0-31-lowlatency
Warning: modules_install: missing 'System.map' file. Skipping depmod.
make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-31-lowlatency'
depmod

Again, I think the dpkg errors are irrelevant, but the SSL error isn't, and the install fails.

Also, direct insmod fails:

sudo insmod snd-digitakt.ko
insmod: ERROR: could not insert module snd-digitakt.ko: Unknown symbol in module

Any ideas?

Noir- commented 4 years ago

I'm not very deep into Linux Kernel development so feel free to correct me. But I highly doubt that copying the header files would work. The header files are supposed to expose functionality which is present in the kernel. When you add headers from a different kernel version than you are running, the "promised" functionality from the copied headers is simply not available. The error message Unknown symbol in module indicates this. Maybe you can investigate the issue like described in here: https://askubuntu.com/a/1163861/520956

If my deductions are correct, you need to compile and/or install a kernel version which is compatible to this headers.

I got similar problems in the beginning when I tried to compile it on Arch Linux. I gave up on this since I wanted to use this module on the Raspberry Pi anyway.

naught101 commented 4 years ago

Mmm, that's why I copied the header files from the same version in git, but yes, maybe that's not enough.

The errors in dmesg are:

[584072.889789] snd_digitakt: Unknown symbol __snd_usbmidi_create (err -2)
[584072.890502] snd_digitakt: Unknown symbol snd_usbmidi_disconnect (err -2)

And they don't appear in the /proc/kallsyms

Ah! but they do after sudo modprobe snd_usbmidi_lib, and then I can insmod OK. Which I guess means that the module needs to define a dependency somehow?

naught101 commented 4 years ago

Now alsamixer shows Elektron Digitakt as a soundcard, with no controls, which I guess is OK.

However, I can't see it as a device in the Cadence config, so I can't use it for JACK (not sure if that should be possible), nor does it appear in the outputs/inputs for PulseAudio.

It doesn't show in arecord -l, but it does in arecord -L, as:

usbstream:CARD=Digitakt
    Elektron Digitakt
    USB Stream Output

Trying direct ALSA recording with ffmpeg, as described at https://trac.ffmpeg.org/wiki/Capture/ALSA also fails:

ffmpeg -f alsa -i usbstream:CARD=Digitakt -t 30 blah.wav
ffmpeg version 4.2.2-1ubuntu1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-3ubuntu1)
  configuration: --prefix=/usr --extra-version=1ubuntu1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  WARNING: library configuration mismatch
  avcodec     configuration: --prefix=/usr --extra-version=1ubuntu1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libaribb24 --enable-liblensfun --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
ALSA lib pcm_usb_stream.c:508:(_snd_pcm_usb_stream_open) Unknown field hint
[alsa @ 0x55eb2d2336c0] cannot open audio device usbstream:CARD=Digitakt (Invalid argument)
usbstream:CARD=Digitakt: Input/output error

So I guess something's not registering correctly. Might still be to do with mis-matching headers, I guess.

naught101 commented 4 years ago

@droelfdroelf or @alamminsalo any chance you could re-open this? Would be useful to have an active issue for discussion.

naught101 commented 4 years ago

Huh.. new firmware out today has class compliance... will test and see if it works.

Noir- commented 4 years ago

Yeah it works on Linux. But it's only the stereo sum which is pretty useless for the use cases most people have in mind when they want to use this driver.

naught101 commented 4 years ago

Ah, yeah, bummer. Oh well, still TRIG+YES will be nice. I will keep trying with snd-digitakt when I have time.

naught101 commented 4 years ago

OK, progress. When I last tried, I forgot to put th DT in overbridge mode, hence it not being recognised as an audio device. Now it does show, but I can't get it to work with Jack:

 /usr/bin/jackd -R -P 75 -d alsa -d hw:Digitakt -r 48000 -n 2 -p 256 -s &
[1] 10922
jackdmp 1.9.12                                                                                                                                                                                                                        
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2016 Grame.
Copyright 2016-2017 Filipe Coelho.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
no message buffer overruns
no message buffer overruns
no message buffer overruns
JACK server starting in realtime mode with priority 75
self-connect-mode is "Don't restrict self connect requests"
audio_reservation_init
Device reservation request with priority 2147483647 denied for "Audio1": org.freedesktop.DBus.Error.NoReply (Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, 
Failed to acquire device name : Audio1 error : Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broke
Audio device hw:Digitakt cannot be acquired...
Cannot initialize driver
JackServer::Open failed with -1
Failed to open server

[1]  + 10922 exit 255   /usr/bin/jackd -R -P 75 -d alsa -d hw:Digitakt -r 48000 -n 2 -p 256 -s
Noir- commented 4 years ago

Have you tried with arecord just to make sure that it's not an issue with jack?

naught101 commented 4 years ago

I just get

$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: CX8200 Analog [CX8200 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Digitakt [Digitakt], device 0: Digitakt [Digitakt]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
$ arecord -D hw:1 blah.wav
arecord: main:830: audio open error: Device or resource busy

Other settings don't seem to make an impact. Also, just plugging the DT in with OB kills pulse audio, and after that, I tried changing the USB config to USB audio/midi with it plugged in, and it froze my system entirely (to the point where even the SysReq magic keys wouldn't work). I can't see anything useful in the logs for that, but maybe that's because I always have trouble figuring out how to find "just before last crash" events in the system logs :/

droelfdroelf commented 4 years ago

To let you guys know, it is not dead (yet ;), I am just super busy with work...

naught101 commented 3 years ago

@droelfdroelf I noticed the developSR branch has some new activity, and I thought about trying it out with the 1.20A Digitakt firmware, but it seems to have the entire linux kernel included in it.. did you mean to do that?

naught101 commented 3 years ago

Tried master again, now that I've upgraded to ubuntu 20.04, and digitakt 1.20A, using the same process I described above. Still kills my machine. This time I got some relevant-looking kernel logs:

kern.log from immediately before the crash:

Dec  6 22:25:01 nedcr-X1-Yoga kernel: [ 1461.937389] snd_digitakt: version magic '5.4.0-52-lowlatency SMP preempt mod_unload ' should be '5.4.0-54-lowlatency SMP preempt mod_unload '
Dec  6 22:28:41 nedcr-X1-Yoga kernel: [ 1681.761706] usbcore: registered new interface driver snd-digitakt
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.036735] xhci_hcd 0000:00:14.0: ERROR Transfer event TRB DMA ptr not part of current TD ep_index 5 comp_code 1
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.036741] xhci_hcd 0000:00:14.0: Looking for event-dma 00000004880c32a0 trb-start 00000004880c32b0 trb-end 00000004880c32b0 seg-start 00000004880c3000 seg-end 00000004880c3ff0
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.036768] usb 1-3: USB disconnect, device number 2
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.036888] xhci_hcd 0000:00:14.0: ERROR Transfer event TRB DMA ptr not part of current TD ep_index 5 comp_code 1
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.036891] xhci_hcd 0000:00:14.0: Looking for event-dma 00000004880c32b0 trb-start 00000004880c32c0 trb-end 00000004880c32c0 seg-start 00000004880c3000 seg-end 00000004880c3ff0
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.036987] xhci_hcd 0000:00:14.0: ERROR Transfer event TRB DMA ptr not part of current TD ep_index 5 comp_code 1
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.036992] xhci_hcd 0000:00:14.0: Looking for event-dma 00000004880c32c0 trb-start 00000004880c32d0 trb-end 00000004880c32d0 seg-start 00000004880c3000 seg-end 00000004880c3ff0
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.037119] xhci_hcd 0000:00:14.0: ERROR Transfer event TRB DMA ptr not part of current TD ep_index 5 comp_code 1
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.037123] xhci_hcd 0000:00:14.0: Looking for event-dma 00000004880c32d0 trb-start 00000004880c32e0 trb-end 00000004880c32e0 seg-start 00000004880c3000 seg-end 00000004880c3ff0
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.037243] xhci_hcd 0000:00:14.0: ERROR Transfer event TRB DMA ptr not part of current TD ep_index 5 comp_code 1
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.037247] xhci_hcd 0000:00:14.0: Looking for event-dma 00000004880c32e0 trb-start 00000004880c32f0 trb-end 00000004880c32f0 seg-start 00000004880c3000 seg-end 00000004880c3ff0

syslog has similar looking stuff at the same time:

Dec  6 22:24:35 nedcr-X1-Yoga kernel: [ 1435.784593] snd_digitakt: version magic '5.4.0-52-lowlatency SMP preempt mod_unload ' should be '5.4.0-54-lowlatency SMP preempt mod_unload '
Dec  6 22:25:01 nedcr-X1-Yoga kernel: [ 1461.937389] snd_digitakt: version magic '5.4.0-52-lowlatency SMP preempt mod_unload ' should be '5.4.0-54-lowlatency SMP preempt mod_unload '
Dec  6 22:27:35 nedcr-X1-Yoga upowerd[1793]: energy 48.710000 bigger than full 48.390000
Dec  6 22:27:44 nedcr-X1-Yoga rtkit-daemon[1474]: Supervising 3 threads of 3 processes of 1 users.
Dec  6 22:27:44 nedcr-X1-Yoga rtkit-daemon[1474]: message repeated 3 times: [ Supervising 3 threads of 3 processes of 1 users.]
Dec  6 22:27:44 nedcr-X1-Yoga rtkit-daemon[1474]: Successfully made thread 15507 of process 2737 owned by '1000' RT at priority 10.
Dec  6 22:27:44 nedcr-X1-Yoga rtkit-daemon[1474]: Supervising 4 threads of 4 processes of 1 users.
Dec  6 22:28:41 nedcr-X1-Yoga kernel: [ 1681.761706] usbcore: registered new interface driver snd-digitakt
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.036735] xhci_hcd 0000:00:14.0: ERROR Transfer event TRB DMA ptr not part of current TD ep_index 5 comp_code 1
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.036741] xhci_hcd 0000:00:14.0: Looking for event-dma 00000004880c32a0 trb-start 00000004880c32b0 trb-end 00000004880c32b0 seg-start 00000004880c3000 seg-end 00000004880c3ff0
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.036768] usb 1-3: USB disconnect, device number 2
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.036888] xhci_hcd 0000:00:14.0: ERROR Transfer event TRB DMA ptr not part of current TD ep_index 5 comp_code 1
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.036891] xhci_hcd 0000:00:14.0: Looking for event-dma 00000004880c32b0 trb-start 00000004880c32c0 trb-end 00000004880c32c0 seg-start 00000004880c3000 seg-end 00000004880c3ff0
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.036987] xhci_hcd 0000:00:14.0: ERROR Transfer event TRB DMA ptr not part of current TD ep_index 5 comp_code 1
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.036992] xhci_hcd 0000:00:14.0: Looking for event-dma 00000004880c32c0 trb-start 00000004880c32d0 trb-end 00000004880c32d0 seg-start 00000004880c3000 seg-end 00000004880c3ff0
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.037119] xhci_hcd 0000:00:14.0: ERROR Transfer event TRB DMA ptr not part of current TD ep_index 5 comp_code 1
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.037123] xhci_hcd 0000:00:14.0: Looking for event-dma 00000004880c32d0 trb-start 00000004880c32e0 trb-end 00000004880c32e0 seg-start 00000004880c3000 seg-end 00000004880c3ff0
Dec  6 22:29:02 nedcr-X1-Yoga kernel: [ 1703.037243] xhci_hcd 0000:00:14.0: ERROR Transfer event TRB DMA ptr not part of current TD ep_index 5 c
droelfdroelf commented 3 years ago

@droelfdroelf I noticed the developSR branch has some new activity, and I thought about trying it out with the 1.20A Digitakt firmware, but it seems to have the entire linux kernel included in it.. did you mean to do that?

This is my dirty branch, don't expect anything to make sense or work there ;) ... I am trying to remove redundant things from the driver I copied most stuff off. The idea is to have it running in the RT kernel from https://blokas.io/ Patchbox OS at some point in the future.

naught101 commented 3 years ago

This is my dirty branch, don't expect anything to make sense or work there ;)

Fair enough, but unfortunately it's in the repo, which means that it's not possible to fetch from the repo without pulling all that linux kernel history (even if you never check out the branch), which is pretty slow.

Lcchy commented 3 years ago

Just here to say hi and thanks, and offer any help if possible, yet I don't have the knowledge to dive into kernel modules :p

I tried to install the module on a Rpi4b but the digitakt doesn't show up as an alsa device. I also tried the full mzero Rpi instructions but that didn't work either. The Module seems to be loaded but I have no sign of life, does someone know where there could be logs with a hint?

I have the version 1.20A of the digitakt firmware, maybe this could be a reason?

(In audio+midi usb mode the Digitakt shows up as a 2 channel alsa device as it should)