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!

Saturday, August 11, 2012

Importance of Using the Latest Wi-Fi Drivers

I've been working with some embedded devices implementing wireless solutions.  Initially I thought this process would be well known and easy to carry out.  It turns out that even today there are many challenges.

Wi-Fi has gone through a number of revisions of it's own ranging from 802.11g to n and lately extending to wireless mirroring: Mirracast.  Adopters of the Wi-Fi Alliance standards have had their challenges too.  You can find a list of supported wireless devices, such as USB, at linuxwireless.org.  But I haven't had much luck getting the one in my possession to work consistently on embedded.

Worse yet, OpenSSL is not working for me any more on strict secured corporate networks using PEAP authentication and MSCHAPv2 for inner authentication.  The problem is not limited to Ubuntu, a thread has been going on this year since April regarding the OpenSSL issue.  The latest Android 4.1 also shares this issue.

The Desktop Solution

Currently I back port my OpenSSL with the following:

After downloading the above you can run this script to install:

#!/bin/bash
echo "Replacing newer SSL libraries."
sudo dpkg -i libssl1.0.0_1.0.0e-2ubuntu4.2_i386.deb
sudo dpkg -i openssl_1.0.0e-2ubuntu4.2_amd64.deb
sudo dpkg -i libssl1.0.0_1.0.0e-2ubuntu4.2_amd64.deb
sudo dpkg -i libssl-dev_1.0.0e-2ubuntu4.2_amd64.deb

Further Issues Crop Up...

Three months after solving this issue another one recently appeared where my wireless card connects to the corporate secured access point (mentioned above) but drops only a few seconds into browsing a page or when sharing a mouse with another computer using Synergy.  I can reset the connection like so:

sudo /etc/init.d/network-manager restart

However this just delays the inedible dropped connection.  I continue to check in on the latest OpenSSL issues but they still do not work.  As a result, I have decided to check out the latest work on linuxwireless.org and had some luck for a change (sort of).

I found that by installing the latest work from linuxwireless.org my connection appears to drop - just move that mouse around while on your Windows box - however this time the connection appears to reconnect immediately.  I can't say for sure what is going on other than Synergy breaks but there is no message about my wireless disconnecting and seconds later Synergy reconnects.

How to Build the Latest

Note: I offer no warranty to those who follow my steps.  You should probably know what you are doing.

First you will need to install the necessary libraries:

sudo apt-get install hostapd libnl1 libnl-dev python-m2crypto

Then download all sources:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
git clone git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-regdb.git

git clone git://github.com/mcgrof/crda.git
git clone git://git.sipsolutions.net/iw.git
git clone git://git.sipsolutions.net/rfkill.git

The compat-wireless code may not be accessible from a direct link as it may be "anti-hotlinked".

wget http://linuxwireless.org/download/compat-wireless-2.6/compat-wireless.tar.bz2

Then build each individual source code:

cd wireless-regdb
make
sudo mkdir /usr/lib/crda
sudo cp regulatory.bin /usr/lib/crda/regulatory.bin

cd ../crda
make USE_OPENSSL=1 clean

make USE_OPENSSL=1 all_noverify
sudo make USE_OPENSSL=1 install

cd ../iw
make
sudo make install

cd ../rfkill
make
sudo make install

cd ..
tar xf compat-wireless.tar.bz2
cd compat-wireless

You can view which wireless devices are supported by compat-wireless simple by following:

./scripts/driver-select

Then run the same script with your driver - in my case I used intel.

./scripts/driver-select [Your Wireless Device Here]
make
sudo make install

cd ..

It is recommended that you replace your old firmware with new firmware.  But before you do that make a backup!

# Backup your current firmware
tar jcf my-original-firmware.tar.bz2 /lib/firmware

Now override your old firmware with the latest firmware provided by the Linux git repositories.

# Out with the old and in with the new
sudo cp -r linux-firmware/* /lib/firmware

Restarting is probably the easiest way to make the changes take place.  Save everything and restart!

#sync; sudo shutdown -r now

Installing Lotus Notes for Ubuntu 12.04 x86_64

Bare in mind here that this is my first post using blogger.

Not too long ago I was working with my IT on installing Lotus Notes for Ubuntu.  The fact that they even had deb file was amazing.  Sadly, the targeted architecture was only 32 bit.  Doing some Goolging I found a few links with bits and pieces such as this one from IBM but the most help I found was from here.

Following the later link I have put together an installer script using the Lotus Notes deb package file which installs the package and installs the necessary 32 bit libraries.  You can find my script on Google Code.

There are still some occasions when the gtk decorator fails.  When this happens you loose the ability to move and resize all windows.  I know that it has something to do with menus being located on the top Ubuntu bar versus being located on the application window top bar.

The fix is simple for the gtk decorator.  Just run the following command:

compiz-decorator