Automating the Tascam US-122 in Ubuntu 9.04

I gave away my Tascam US-122 usb audio interface some time ago, and immediately missed having it to play around with. I wouldn’t call myself a musician, but I do think it is fun to plug a guitar into the computer, fire up qjackctl and jackrack and see what kinda weird noises I can get the computer to make. So this weekend I picked one up on craigslist pretty cheap and thought I would see about automating the installation with a shell script.

I got the steps from this tutorial

*UPDATE* 4-22-2010

I have altered this script it should now run fine with sudo (rather than full root) privileges, and that the script should be run on a fully updated Ubuntu Studio distribution running the Real Time kernel.

So first, if you are on a regular Ubuntu system;

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install ubuntustudio-audio linux-rt linux-headers-rt

When the packages are done installing, reboot and be sure to select the Real Time kernel at the boot menu. It will be the one that ends with ‘rt’. It is important to be running the correct kernel because the script compiles firmware for the running kernel. Next log in to the desktop plug the US-122 into an open usb port. Open a terminal window and type;

sudo

After making sure that the file has executable permission you can just drag and drop it into the open terminal window and hit ‘Enter’. Or, you can just type ‘/bin/bash ‘ and just drop the file in without checking and then hit the ‘Enter’ key. When the script is completed running, close the terminal window, you should now have a functioning device, with the lights lit up, and it will automatically work every time you plug it in.

Download the script here, and the code is here;

#!/bin/bash# script builds and installs the firmware for the tascam us-122 # script variables tascamE="/tmp/tascam/tascam_error.txt" # an error log tascamL="/tmp/tascam/tascam_log.txt" # an activity log CompDir="/tmp/tascam"    # Compile in temp directory easy cleanup ScriptL=`find ~/ -name tascam.sh` # locate the script #this is a processing indicator (aka spinner) i=1
sp="/-\|"
echo -n ' '
IsWorking()
{
while [ -n "`pgrep $RUNNING`" ]
do
sleep 0.01
printf "\b${sp:i++%${#sp}:1}"
done
ErrChck
}
# error checking routine ErrChck()
{
ERCHK=`cat $tascamE`
if [ -n "$ERCHK" ]; then
    echo " ########################################### ## Errors were ecountered! ## ## read /tmp/tascam/tascam_error.txt ## ## and /tmp/tascam/tascam_log.txt ## ## to find out what went wrong. ## ###########################################"
    exit 0
else
    echo -e "\b done! \n"
fi
}
# make sure script is run with root permissions if [ `whoami` != "root" ]; then
    echo -e \\r"** You must have root permission to execute this script, try: sudo "$ScriptL
    exit 0
else
# checking for and installing any required packages
mkdir $CompDir
echo '' > $tascamE PkgStrng=""
printf  "** Installing Any Missing Packages . . . . . . "
apt-get -y install fxload alsa-base alsa-firmware-loaders alsa-tools alsa-tools-gui alsa-utils alsamixergui 1>$psmL 2>$psmE &
RUNNING=apt-get
IsWorking
printf  "** Downloading ALSA Firmware . . . . . . . . . "
cd $CompDir
wget ftp://ftp.alsa-project.org/pub/firmware/alsa-firmware-1.0.19.tar.bz2 >> $tascamL 2>&1 &
RUNNING="wget"
IsWorking
printf  "** Extracting ALSA Firmware . . . . . . . . . . "
tar -xjf alsa-firmware-1.0.19.tar.bz2 1>>$tascamL 2>>$tascamE &
RUNNING="tar"
IsWorking
printf  "** Installing ALSA Firmware . . . . . . . . . . "
cd ./alsa-firmware-1.0.19/
./configure --prefix=/usr >> $tascamL 2>&1 && make >> $tascamL 2>&1 && sudo make install  >> $tascamL 2>&1 &
RUNNING="make"
IsWorking
printf "** Downloading TASCAM US-122 Firmware . . . . . "
cd /usr/share/alsa/firmware/
wget http://langerland.de/linux/usx2y/usx2y-fw-0.1b.tar.bz2 >> $tascamL 2>&1 &
RUNNING="wget"
IsWorking
printf  "** Extracting TASCAM US-122 Firmware . . . . . "
tar -xjf usx2y-fw-0.1b.tar.bz2 1>>$tascamL 2>>$tascamE &
RUNNING="tar"
IsWorking
#load the firmware printf  "** Installing TASCAM US-122 Firmware . . . . . "
usbScan=`lsusb | grep Tascam`
fxload -s /usr/share/alsa/firmware/usx2y-fw-0.1b/ld2-ezusb.hex -I /usr/share/alsa/firmware/usx2yloader/us122fw.ihx -D /dev/bus/usb/${usbScan:4:3}/${usbScan:15:3} 1>>$tascamL 2>>$tascamE
# create link to where firmware is expected to be ln -s /usr/share/alsa/firmware/usx2yloader /lib/firmware/usx2yloader 1>>$tascamL 2>>$tascamE
usx2yloader 1>>$tascamL 2>>$tascamE
# udev rules for plug-n-play echo -e "BUS==\"usb\", ACTION==\"add\", SYSFS{idProduct}==\"8006\", SYSFS{idVendor}==\"1604\", RUN+=\"/bin/sh -c '/sbin/fxload -D %N -s /usr/share/alsa/firmware/usx2yloader/tascam_loader.ihx -I /usr/share/alsa/firmware/usx2yloader/us122fw.ihx'\"\n\nBUS==\"usb\", ACTION==\"add\", SYSFS{idProduct}==\"8007\", SYSFS{idVendor}==\"1604\", RUN+=\"/bin/sh -c '/usr/bin/usx2yloader'\"" >$CompDir/tascam.sh
sudo mv $CompDir/tascam.sh /etc/udev/rules.d/55-tascam.rules
# the firmware has been successfully installed now clean up rm -R $CompDir
echo  "done!"
echo "** Tascam US-122 successfully installed!"
fi
exit 0

*Edit
After playing around a bit I became somewhat put-off by the horrible audio recording performance of Ubuntu, even with the realtime kernel. It seems that I am not the only person to notice this, others have noted that Ubuntu with the Studio packages installed behaves much worse than a fresh install from an actual Ubuntu Studio DVD. And the consensus seems to be that 64Studio works much better. So on the testimonials of others I went ahead and installed 64Studio, and it does indeed run much more smoothly (after I fixed the broken xorg.conf), and since both Ubuntu and 64Studio are built from debian GNU Linux the script above worked with it as well.

`
Advertisements

22 thoughts on “Automating the Tascam US-122 in Ubuntu 9.04

  1. Hi, I have a Lionstracs Mediastation running Kubuntu 10.10 Linux. I don’t understand the working of Linux , it is new for me. i want to install my US 122 on my mediastation. Does the information you gave to install the US 122 also works on my system?

    Thanks

    1. Yes, it should work with any debian/ubuntu derived distribution (such as Kubuntu). I believe that I tested this on 10.10, but perhaps I am mistaken. Let me know if you have any problems with the script.

      1. hi, can you please,please,please help?me to install the US 122? I dont understand Linux.

        Regards,
        Romeo

    2. Romeo, the post is pretty self explanetory, however it is slightly outdated; the realtime patches have been integrated into the mainline kernel so there is really nothing extra that needs to be installed (as far as a realtime kernel etc goes).

      Just update the system, and then run this script with the tascam plugged in. When the script completes you should see the lights blink on and the device is ready to use; from this point on the tascam will be plug and play since the script installs the firmware and writes a configuration file for it.

      1. Hi ( sorry, I don;t see your name),

        Thank you very much for this info but again I beg you to help me, because I do not know ANYTHING from the LINUXsysytem and I have to record a demo-cd for my band this week. So..please, can you explain what you mean with “update the system” ( what must I do?) and “run the script”? ( How do I run the script?)

        The LINUX system is like Chinese for me..

        Please, I will be very greatful to you!

        grtz. Romeo

      2. I am not trying to be a jerk or anything but there really isn’t anything I can add to better explain what needs to be done. I will summerize the instructions here:

        1) open a terminal
        2) run the following command:
        sudo apt-get update && sudo apt-get upgrade
        3) run the script, in the terminal window type:
        sudo

        press the space bar and then drag the downloaded script onto the terminal window, this should produce something like this in the terminal:
        sudo /home/romeo/Downloads/tascam.sh

        it may complain about executable permissions, in which case right-click the downloaded script (tascam.sh) and select ‘Properties’ from the menu and then select the ‘Permissions’ tab and check the ‘Execute’ box were it says ‘Allow executing file as a program’ then close the dialog to change the permissions. Now step 3 should work, of course you could check the permssions before trying step 3 (recommended).

  2. Hi Ibnr,
    thanks for your help…I tried this what you have wrote…But it is not working with me. At point 3 when compiling the script, the terminal seems to be stuck.

    Thanks again,
    Romeo

    1. the script may take some time to run, it should provide progress messages as it completes its tasks, and if it doesn’t work it should produce and error message and tell you were to look for an error log (/tmp/tascam/tascam_error.txt)

      At what point is the script stopping, or is it not stopping but just getting stuck? does it provide any message to indicate what went wrong if it is stopping on its own?

      If the script isn’t actually crashing but just not running all the way through, it should still create a log file that may shed some light on what is going on. The log file is located at /tmp/tascam/tascam_log.txt and is deleted upon successful commpletion of the script.

    2. Apologies Romeo, I just gave the script a run on 12.04 and it seems that some time in the last couple of years (since the last time I ran the script) things have changed breaking the script. I can’t get to it right now but I will rewrite it sometime in the next few day; there are other things to change with it as well.

      1. hi 1bnr,
        so much thanks for your help, I apreciate!!! No, the sript is not stopping.

        The cursor seems to working because before the cursor ( where you must type something in the terminal) is a sort of activity. I see some fast movements of a slash, dots, triangle etc just besides the cursor. But it takes very long and ther is nothing afterwards than.
        I can’t wait till you fix the update . i need it very much..Thanks again..

        Romeo
        ( P.S. I am from Holland)

      2. I poked around at it last night and the new process is considerabling simpler. Now all the software can be installed via repositories. Until I get the script worked out you could try the following:
        1) install medibuntu repositories:
        instructions here, it is not to dificult, just a little copy and paste into the terminal.
        2) install alsa-firmware:
        sudo apt-get install alsa-firmware
        3) load the firmware:
        sudo usx2yloader

        The US-122 should light up and become functional.

        P.S. Without a proper udev configuration file step 3 will need to be rerun everytime the US-122 is plugged in or the computer is restarted.

        P.P.S It may be that step 1 is not neccessary on a Lionstrac workstation; I would be surprised if they didn’t come with the medibuntu repository pre installed, although I was unable to find out from their website.

  3. Hi 1 bnr,
    thanks again but it seems that I cant get acces to the medibuntu. This is my terminalwhen I try what you said:oot@mediastation:/home/mediastation# sudo apt-get install alsa-firmware
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package alsa-firmware
    root@mediastation:/home/mediastation# sudo us2xyloader
    sudo: us2xyloader: command not found
    root@mediastation:/home/mediastation# udo sed -e ‘s/ non-free//’ -i /etc/apt/sources.list.d/medibuntu.list
    The program ‘udo’ is currently not installed. You can install it by typing:
    apt-get install udo
    You will have to enable the component called ‘universe’
    root@mediastation:/home/mediastation# sudo sed -e ‘s/ non-free//’ -i /etc/apt/sources.list.d/medibuntu.list
    root@mediastation:/home/mediastation# sudo wget –output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list && sudo apt-get –quiet update && sudo apt-get –yes –quiet –allow-unauthenticated install medibuntu-keyring && sudo apt-get –quiet update
    –2012-04-05 14:39:48– http://www.medibuntu.org/sources.list.d/twins.list
    Resolving http://www.medibuntu.org... 88.191.127.22
    Connecting to http://www.medibuntu.org|88.191.127.22|:80… connected.
    HTTP request sent, awaiting response… 404 Not Found
    2012-04-05 14:39:48 ERROR 404: Not Found.

    root@mediastation:/home/mediastation# udo apt-get –yes install app-install-data-medibuntu apport-hooks-medibuntu
    The program ‘udo’ is currently not installed. You can install it by typing:
    apt-get install udo
    You will have to enable the component called ‘universe’
    root@mediastation:/home/mediastation# sudo apt-get –yes install app-install-data-medibuntu apport-hooks-medibuntu
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package app-install-data-medibuntu
    E: Unable to locate package apport-hooks-medibuntu
    root@mediastation:/home/mediastation# sudo sed -e ‘s/ non-free//’ -i /etc/apt/sources.list.d/medibuntu.list
    root@mediastation:/home/mediastation# sudo sed -e ‘s/ non-free//’ -i /etc/apt/sources.list.d/medibuntu.list
    root@mediastation:/home/mediastation# sudo apt-get install alsa-firmware
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package alsa-firmware
    root@mediastation:/home/mediastation# sudo usx2yloader
    sudo: usx2yloader: command not found
    root@mediastation:/home/mediastation#

    Thanks,
    I shall wait behind my pc , maybe you can help me out here…

    Romeo

    1. I looks like you need to enable the ‘universe’ repositories as well. In terminal type:

      kdesudo kate /etc/apt/sources.list

      this will open up the repository list, look for the lines that have universe in them and remove the ‘#’ from the begining of these lines. The ‘#’ tell the computer to ignore these lines and you want the computer to read them instead. With these changes made, save the file and close the text editor. Alternatively this can be accomplished from an update or package manager software (probably Muon or KpackageKit) by checking a box in the configuration, but I am not sure exactly how since I don’t use kde.

      With Universe enabled:

      sudo apt-get update && sudo apt-get upgrade

      then try again to install the medibuntu repositories (the following is all one line, right-click in the box, select all and paste it in the terminal/konsole):

      sudo wget --output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list && sudo apt-get --quiet update && sudo apt-get --yes --quiet --allow-unauthenticated install medibuntu-keyring && sudo apt-get --quiet update

      then update the software list again:

      sudo apt-get update && sudo apt-get upgrade

      then try again to install the firmware and other neccesarry applications:

      sudo apt-get install fxload alsa-base alsa-firmware alsa-firmware-loaders alsa-tools alsa-tools-gui alsa-utils alsamixergui

      now load the firmware (with tascam plugged in):

      sudo usx2yloader

      The US-122 should now be up and running. I will try to get the script this weekend and mabe by then have a Kubuntu 10.10 system to test it on as well.

      EDIT

      Just reread your last comment, it appears that you entered the command to install the medibuntu repositories wrong, just copy the entire command as one line and paste it into the terminal window. It may be that universe repositories are not needed after all, although they do have handy things like mp3 and other copyrighted codecs in them.

  4. Hi 1bnr,

    I have no good luck. i did what you said but my Konsole gives this:root@mediastation:/home/mediastation# kdesudo kate/etc/apt/sources list
    The program ‘kdesudo’ is currently not installed. You can install it by typing:
    apt-get install kdesudo
    You will have to enable the component called ‘main’
    root@mediastation:/home/mediastation# apt-get install kdesudo
    Reading package lists… Done
    Building dependency tree… 50Building dependency tree… 50Building dependency tree
    Reading state information… 0Reading state information… 3Reading state information… Done
    E: Unable to locate package kdesudo
    root@mediastation:/home/mediastation# kdesudo kate /etc/apt/sources.list
    The program ‘kdesudo’ is currently not installed. You can install it by typing:
    apt-get install kdesudo
    You will have to enable the component called ‘main’
    root@mediastation:/home/mediastation# udo apt-get update && sudo apt-get upgrade
    The program ‘udo’ is currently not installed. You can install it by typing:
    apt-get install udo
    You will have to enable the component called ‘universe’
    root@mediastation:/home/mediastation#

    It seems that it can’t locate my KDE…
    Linux is very difficult for me…… To much headache too install something..

    But otherwise a very stable system..

    I am glad you are helping me. This will make me wiser in Linux, but Ithink it take years before I can understand the method.

    Thanks,
    Romeo

    1. first, is the Lionstrac mediastation connected to the internet? this is very important since the software repositories are located on remote servers. Second, there is no application named ‘udo’; this error message:

      The program ‘udo’ is currently not installed. You can install it by typing:

      is the result of your missing part of the command that installs the medibuntu repository. Look at the instructions for installing medibuntu again; the command should all be on one line, it will get word wrapped in the terminal (as well as on blogs/wikis so it looks like more than one, but it is really all one line) but this is not a problem, it just can’t contain any line-returns (caused by the enter key).

      Additionally the error message:

      You will have to enable the component called ‘main’

      leads me to believe that all the repositories have been disabled, probably to prevent updates from accidentally breaking the system (if it isn’t broken don’t fix/update it). However this also prevents you from installing software that has not been included. Another theory is that Lionstrac has their own customized versions of software that they test and host on their own repositories replacing the main repository. If you don’t have the necessary knowledge to figure these things out on your own I would urge you to seek professional help with this. I don’t mind helping, but it seems that this piece of equipment is complex and unique enough that some ‘hands on’ time is likely needed to figure out what needs to be done. With out proper investigation and preparation, changes to the software could have disastrous effects on the performance of the device.

      good luck,

  5. Hi 1bnr, thanks for all the help you gave me. I think indeed that Lionstracs has a kind of protection-system. I tried evrything… but no succeeding. It is very frustating! If you can’t help me, I think nobody can.. Your knowledgement of LIUXsystems is great..

    Again..thank you for all the support . I will forget to use the TASCAM with the MEDIASTATION and try to solve this big problem another way. I even cannot use the build-in soundcard of the Lionstracs..I can’t find the soundcard anywhere in JACK…

    regards,

    Romeo

    1. I didn’t get to rewriting that script this weekend, but I did try the instructions that I posted above on a kubuntu 10.10 system and they worked without a hitch; If you get somebody that knows Linux to look at the Lionstrac they should be able to get the US-122 to work.

  6. Hi 1bnr,
    I tried again…but it is not working. Now the Mediastation from Lionstracs has a soundcard built in. I want to use that, but also no signal. Very complicated….

    But again..thank you that you have took the time to help me, I apreciate much.

    If you can find a solution to make the US 122 work on the Mediastation I will b very greatful.
    have a nice Easterday.

    regards,
    Romeo

  7. Hi 1bnr,
    I can’t succeed to make anything work depending on the built in computersoundcard from Lionstracs Mediastation. The only possibility is the TASCAM US 122. I hope you can write something to make it work.

    Thanks,
    Romeo

  8. Hello 1bnr and Romeo,
    I found this thread via google and just want to let you know, that I successfully installed the US 122 via medibuntu and packages on Ubuntu 11.10. Thanks for your efforts!
    Regards
    Martin

  9. hi Martin, thanks….but can you please tell me what you have done to make the US 122 work? I don.t see any thread.

    regards,

    Romeo

  10. Hi Romeo, I installed the medibuntu package, I just followed the instructions obove, plugged everything in and started the script “sudo usx2yloader”, it is required that everything is connected incl. mic
    Regards Martin

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s