Monday, 9 July 2012

Getting the M-Audio Fast Track II working in Ubuntu Studio 12.04, the unnecessarily hard way

As a hobbyist guitar player, I like to record parts here and there to aid in song composition (read: filling my hard drive with completely unrelated 13 second riffs).  Getting tired of the noisy signals I was getting by feeding my guitar in through unbalanced cables to an ancient, generic soundcard, I figured it was time I catch up to the rest of the world and get a USB soundcard.


My initial test was with an MBox Mini 2 from digidesign - looks like a decent unit and was recommended in high esteem  from a friend of mine:
"I'm a big stupid asshole jerk and won't work with linux lolfag"

 

However, as a cheap motherfucker open source software enthusiast, I am currently running Ubuntu Studio 12.04 on my recording desktop, so this required some fiddling with drivers.


Come to my rescue oh grand google! Deliver me driver source code!  I stumbled upon this source code purported to be bridging the gap between my fancy hardware and ghetto software, and compiled it with glee. 


trdenton@dingler:~/tanzu_usb/mbox2-kernel$ make
make -C /lib/modules/3.2.0-26-generic/build M=/home/trdenton/tanzu_usb/mbox2-kernel modules
make[1]: Entering directory `/usr/src/linux-headers-3.2.0-26-generic'
  CC [M]  /home/trdenton/tanzu_usb/mbox2-kernel/card.o
/home/trdenton/tanzu_usb/mbox2-kernel/card.c:69:15: error: expected declaration specifiers or ‘...’ before string constant
/home/trdenton/tanzu_usb/mbox2-kernel/card.c:70:20: error: expected declaration specifiers or ‘...’ before string constant
/home/trdenton/tanzu_usb/mbox2-kernel/card.c:71:16: error: expected declaration specifiers or ‘...’ before string constant
/home/trdenton/tanzu_usb/mbox2-kernel/card.c:72:25: error: expected declaration specifiers or ‘...’ before string constant
/home/trdenton/tanzu_usb/mbox2-kernel/card.c: In function ‘snd_usb_audio_create’:
/home/trdenton/tanzu_usb/mbox2-kernel/card.c:314:45: error: ‘THIS_MODULE’ undeclared (first use in this function)
/home/trdenton/tanzu_usb/mbox2-kernel/card.c:314:45: note: each undeclared identifier is reported only once for each function it appears in
/home/trdenton/tanzu_usb/mbox2-kernel/card.c: At top level:
/home/trdenton/tanzu_usb/mbox2-kernel/card.c:630:1: warning: data definition has no type or storage class [enabled by default]
/home/trdenton/tanzu_usb/mbox2-kernel/card.c:630:1: warning: type defaults to ‘int’ in declaration of ‘MODULE_DEVICE_TABLE’ [-Wimplicit-int]
/home/trdenton/tanzu_usb/mbox2-kernel/card.c:630:1: warning: parameter names (without types) in function declaration [enabled by default]
/home/trdenton/tanzu_usb/mbox2-kernel/card.c: In function ‘snd_usb_audio_init’:
/home/trdenton/tanzu_usb/mbox2-kernel/card.c:651:9: error: ‘THIS_MODULE’ undeclared (first use in this function)
/home/trdenton/tanzu_usb/mbox2-kernel/card.c: At top level:
/home/trdenton/tanzu_usb/mbox2-kernel/quirks.h:23:12: warning: ‘mbox2_skip_setting_quirk’ declared ‘static’ but never defined [-Wunused-function]
/home/trdenton/tanzu_usb/mbox2-kernel/quirks.h:26:12: warning: ‘snd_usb_mbox2_boot_quirk’ declared ‘static’ but never defined [-Wunused-function]
/home/trdenton/tanzu_usb/mbox2-kernel/card.c: In function ‘snd_usb_audio_init’:
/home/trdenton/tanzu_usb/mbox2-kernel/card.c:652:1: warning: control reaches end of non-void function [-Wreturn-type]
make[2]: *** [/home/trdenton/tanzu_usb/mbox2-kernel/card.o] Error 1
make[1]: *** [_module_/home/trdenton/tanzu_usb/mbox2-kernel] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.2.0-26-generic'
make: *** [all] Error 2




Of course, this didn't deter me, so I dove into the files it was erroring out on, added an #include or two, and lo and behold my zany usb sound driver compiled!


...however, recording from it would simply hang QJackctl.  So basically, I fucked the entire thing up.


After googling usb sound devices for hours a good nights rest, I found a decent usb soundcard that seemed to be working with Ubuntu studio...
could it be????

But, when I connected it, I got some nasty errors (via demesg):

[ 3343.960043] usb 2-2: new full-speed USB device number 5 using uhci_hcd
[ 3344.422941] snd_usb_audio: Unknown symbol usb_alloc_urb (err 0)
[ 3344.422957] snd_usb_audio: Unknown symbol usb_free_urb (err 0)
[ 3344.422982] snd_usb_audio: Unknown symbol usb_alloc_coherent (err 0)
[ 3344.423004] snd_usb_audio: Unknown symbol usb_ifnum_to_if (err 0)
[ 3344.423037] snd_usb_audio: Unknown symbol usb_register_driver (err 0)
[ 3344.423084] snd_usb_audio: Unknown symbol usb_interrupt_msg (err 0)
[ 3344.423126] snd_usb_audio: Unknown symbol usb_submit_urb (err 0)
[ 3344.423149] snd_usb_audio: Unknown symbol usb_free_coherent (err 0)
[ 3344.423175] snd_usb_audio: Unknown symbol usb_driver_claim_interface (err 0)
[ 3344.423188] snd_usb_audio: Unknown symbol usb_control_msg (err 0)
[ 3344.423215] snd_usb_audio: Unknown symbol usb_set_interface (err 0)
[ 3344.423229] snd_usb_audio: Unknown symbol usb_deregister (err 0)
[ 3344.423246] snd_usb_audio: Unknown symbol usb_string (err 0)
[ 3344.423268] snd_usb_audio: Unknown symbol usb_get_descriptor (err 0)
[ 3344.423290] snd_usb_audio: Unknown symbol usb_unlink_urb (err 0)
[ 3344.423304] snd_usb_audio: Unknown symbol usb_reset_configuration (err 0)
[ 3344.423314] snd_usb_audio: Unknown symbol usb_kill_urb (err 0)
[ 3344.423324] snd_usb_audio: Unknown symbol snd_usbmidi_create (err 0)
[ 3344.423350] snd_usb_audio: Unknown symbol snd_pcm_format_name (err 0)
[ 3344.423363] snd_usb_audio: Unknown symbol snd_usbmidi_disconnect (err 0)

So not only did my kernel module fail for the previous one, I also managed to screw it up entirely for any further USB sound devices....great....

After googling how to recompile kernel modules to no avail, I eventually decided that I couldn't fuck the thing up any worse and installed the linux source code from the Ubuntu Repositories.  I decided to throw caution to the wind and try my hand at recompiling kernel modules (not for the faint of heart).


Long story short, install the Linux source from the repositories (I used synaptic) and it will be found in /usr/src/linux-source/linux-(adadfadfasdf).tar.bz2.   bunzip2 that shit, untar it, and cp the files in /usr/src/linux-source(asdfadsf)/linux-source(adfadsfadf)/sound/usb to a test directory.

Then, use the following modified Makefile (made from the mbox mini2's sketchy drivers makefile, updated to reflect modern code):

KVERSION = $(shell uname -r)

snd-usb-audio-objs :=   card.o \
                        clock.o \
                        endpoint.o \
                        format.o \
                        helper.o \
                        mixer.o \
                        mixer_quirks.o \
                        pcm.o \
                        proc.o \
                        quirks.o \
                        stream.o

snd-usbmidi-lib-objs := midi.o

obj-m += snd-usb-audio.o snd-usbmidi-lib.o

all:
        make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules

clean:
        make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean

install:
        mkdir -p /lib/modules/$(KVERSION)/kernel/sound/usb
        cp *.ko /lib/modules/$(KVERSION)/kernel/sound/usb
        depmod
        modprobe snd-usb-audio

        # If already inserted, please remove and reinsert the new module:
        # sudo rmmod snd-usb-audio
        # sudo rmmod snd-usbmidi-lib
        # sudo modprobe snd-usb-audio
 



Of course, save this in your test directory as 'Makefile'.  Then, compile the thing:


make
sudo make install


and re-insert it into the kernel with modprobe (make sure your usb device is unplugged, or it won't let you remove the active modules)


sudo rmmod snd-usb-audio
sudo rmmod snd-usbmidi-lib
sudo modprobe snd-usb-audio



To get this guy recording/playing audio in Ubuntu Studio, fire up Qjackctl, and open the setup window.  Select the Fast Track 2 device on the interface menu.


And that's how it's done!

Hope someone finds this useful,

T

1 comment:

  1. Hello, I think you might have the solution to my problem. I'm new to Linux and can't find a way to get my Fast Track II going.
    Do you think this solution might work in Ubuntu Studio 13.04? If it does, please let me know where in the explaination should i begin from a fresh install.
    I'm new to linux so I'm learning this as I do it, not really familiar to compiling, kernels and all this.

    Anyway i I hope you can give me a hand.
    Thanks in advance!

    ReplyDelete