Wednesday, December 26, 2012

Restarting USB ehci_hcd

Lately I have been having issues with my Logitech Unifying wireless USB dongle for my mouse and keyboard.  I know this is not the Logitech device itself since it has worked reliably for over a year now.  This hasn't been an issue before so I suspect a recent update caused it to become unreliable.  I haven't tested other USB devices yet.  This is what I get when attempting to connect my Unifying USB dongle from dmesg:


    usb 2-1.3: new full-speed USB device number 39 using ehci_hcd
    usb 2-1.3: device not accepting address 39, error -32
    hub 2-1:1.0: unable to enumerate USB device on port 3

I found that simply reseting ehci_hcd resolves the issue so I wrote the following script:


    #!/bin/bash
    
    USB1="0000:00:1a.0"
    USB2="0000:00:1d.0"
    
    function reset_usb() {
        echo -n "$1" > /sys/bus/pci/drivers/ehci_hcd/unbind
        echo -n "$1" > /sys/bus/pci/drivers/ehci_hcd/bind
    }
    
    reset_usb $USB1
    reset_usb $USB2

You will need to fill in the "0000:00:xx:x" to fit your need.  You can find them by

    ls /sys/bus/pci/drivers/ehci_hcd


You will find a directory usb* in the "0000:00:xx:x" folder:

    ls -d /sys/bus/pci/drivers/ehci_hcd/0000\:00\:xx.x/usb*

Saturday, December 15, 2012

Android ADT and APK Traditional Install

It's been a while since I wrote anything for Android.  I surely miss it.  I absolutely love how 'bare bones' it can be in the sense that the install instructions are written with Linux developers in mind without compromising the Windows experience - this is a necessary evil.

My recent experiences have left me wondering if Google is giving up focusing on Android.  Although their directions are slightly cleaner than previously (links to links to links).  There is a few links to navigate before I could get from the SDK to ADT for Eclipse.

Currently the install instructions are for installing to your personal folder.  I don't know who does this in Linux so I aim to correct it here.  Obviously this could be tailored to install to whatever folder you choose, i.e. /usr/local/Google or /usr/lib/google depending on how you view things.  I choose to install mine to /opt/google where Google install Chrome and Music Manager.  The main advantage is that the Android tools will then be available to everyone and it doesn't pollute your home folder, uck!

Here is a helper script I use to give proper flags to files after unzipping so that you can browse folders and execute executable without being super user.

sudo find /opt/google/adt-bundle-linux -type d -exec chmod +rx {} \;

sudo find /opt/google/adt-bundle-linux -type f -exec chmod +r {} \;

for FILE in $(find /opt/google/adt-bundle-linux -type f); do \
    if [ ! -z "$(file $FILE | grep executable)" ]; then \
        echo $FILE; \
        sudo chmod +x $FILE; \
    fi; \
done



Update for Ubuntu 12.10 and Lotus Notes

Installing Lotus Notes has forced me once again to re-evaluate installing IBM Lotus Notes.  I am pleased to report that there is less steps involved!

These are the packages that I had to install in order to get Lotus Notes working from apt package manager:

apt-get install ia32-libs libgnomeprint2.2-0:i386 libgnomeprintui2.2-0:i386 \
    libgnomevfs2-0:i386 libgnome2-0:i386 libgnomeui-0:i386 libavahi-glib1:i386 \
    libbonobo2-0:i386 libpopt0:i386 libbonoboui2-0:i386 liborbit2:i386 \
    libart-2.0-2:i386 libgnomecanvas2-0:i386

I believe that it is still necessary to unpack the deb files and fix them.  For simplicity I am recycling my old script to do this.  To fix the packages themselves would require a bit of work (adding ":386") however then producing a patch could be helpful.

SRC_DEB="$(pwd)"
TAR=lotus_notes853_linuxUb_en.tar
TMP_INSTALL=/tmp/notes
NOTES_DEB_MODIFY="notes sametime"
NOTES_VERSION="8.5.3.i586"

if [ ! -e "$SRC_DEB/$TAR" ]; then
   echo "Could not find $TAR tar file in current folder."
   exit 0
fi

[ -e "$TMP_INSTALL" ] && rm -rf "$TMP_INSTALL"
mkdir -p "$TMP_INSTALL"

cp "$SRC_DEB/$TAR" "$TMP_INSTALL"
cd "$TMP_INSTALL"

tar xf "$TAR"

for DEB in $NOTES_DEB_MODIFY; do
   P="ibm-lotus-$DEB-$NOTES_VERSION"
   mkdir "$P"
   cd "$P"
   ar x "../$P.deb"

   mkdir DEBIAN
   tar xf data.tar.gz
   tar xf control.tar.gz -C DEBIAN

   cd DEBIAN
   cat control | sed -re "s/^(Pre\-Depends|Depends|Recommends|Conflicts):\s*.*$/\1:/" > control-mod
   mv control-mod control

   cd ..
   rm control.tar.gz
   rm data.tar.gz
   rm debian-binary

   cd ..
   sudo dpkg-deb -b "$P"
   rm -rf "$P"

   sudo dpkg -i --force-all $P.deb
done

Finally there are some changes to a few of the included libraries that I pulled directly from IBM's community article here.

wget http://www.freetechie.com/upload/lotus_notes/libgdk-x11-2.0.so.0
wget http://www.freetechie.com/upload/lotus_notes/libgdk_pixbuf-2.0.so.0
wget http://www.freetechie.com/upload/lotus_notes/libgdk_pixbuf_xlib-2.0.so.0
wget http://www.freetechie.com/upload/lotus_notes/libgtk-x11-2.0.so.0
sudo mv *.so.0 /opt/ibm/lotus/notes


I also needed the following so that I could open attachments.

# Make opening attachments work
sudo mv /opt/ibm/lotus/notes/openwith /opt/ibm/lotus/notes/openwith.bak
sudo ln -s $(which gnome-open) /opt/ibm/lotus/notes/openwith

Creating this shortcut within the Lotus Notes install folder cleared up some of the bugs.

sudo ln -s /usr/lib/i386-linux-gnu/gtk-2.0/modules/libcanberra-gtk-module.so \
   /opt/ibm/lotus/notes/libcanberra-gtk-module.so

That's it! There seems to be some issues with the Lotus Notes loading dialog box that were not there in my previous script. Not a big deal as everything else seems to work well. Enjoy!