Sunday, December 28, 2014

DLNA Streaming from Linux --> 1st Gen Sony GoogleTV


While cleaning up my wife's tablet I found a few hundred photos/videos from 2010-2011 time frame.  I copied them all to offline storage.  My kids were having a ball watching younger versions of themselves over my shoulder, so I thought, why can't I just stream this stuff?

The Sony GoogleTV already supports streaming from other DLNA devices.  This generally includes a lot of devices, like Windows laptops, that appear on the network and make videos and pictures available to DLNA clients.

I tried a few different approaches in Linux before I found one that just worked right out of the box.

First, there's MiniDLNA (now called ReadyMedia).  This project is "sort of" supported by Ubuntu with a separate repo.  However the objects in that old repo seem out of date, and the only way to get this up and running with the latest and greatest version is by building it from source.  I didn't want to mess with that this morning, so I moved on without even giving this one a go.

Next, I found MediaTomb.  While this was relatively easy to set up under Ubuntu, I couldn't get my Sony GTV to recognize it.  My phone w/ a DLNA client, however, *would* recognize it, but it refused to play any of the content.  I messed w/ the config file and uncommented some lines for the PS3, Google'd around a bit, didn't find any solution.  Uninstalled, moving on.

I looked around for Plex, which I know is popular, but it is commerical and I didn't really like the license terms, so I moved on.

I finally found Rygel, which installed easily under Mint/Ubuntu and in literally minutes I had it running.  I also installed the companion app, rygel-preferences, which made it super easy to point to specific folders that had the content I wanted to publish. 

I did have to run "rygel &" from the commandline to start the server, but after that the Sony GTV discovered it immediately and the kids could look at all 6GB of short movies and photos.



Sunday, September 21, 2014

FreeMind XML Parse Exception When Opening an Old Map

I think this bug has been fixed in a more recent version of FreeMind, but you may go through this with version 1.0.1 for Linux, possibly for Windows also:

1.  Try to open a map


2.  Get this error


This is clearly a bug, and I haven't seen it with newer versions of FreeMind on Windows.  A workaround is to fix the first line of the .mm file in question:

<map version="0.9.0">
<!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net -->
<node CREATED="1386726098959" ID="ID_368233367" MODIFIED="1386726102812" TEXT="git">


To resolve the issue, replace "0.9.0" with "1.0.1" using a text editor, save the file, and you should be able to open the file again.

If you want to update a large number of maps try the following (Linux command line):

sed -i -e 's/0\.9\.0/1.0.1/' *.mm

The above command will look for "0.9.0" and replace it with "1.0.1" in all files named *.mm, and the -i option means it will update the file in place.

(You can also use sed under Windows, see the unixutils package at Sourceforge)

Sunday, September 7, 2014

[Linux, Mint, Ubuntu] Update FreeMind the Lazy Way...

The latest version of FreeMind in the Ubuntu repositories as of this writing is 0.9, which is quite old.  But, there is an easy way to get the latest version, use a 3rd party repo.

See here:  http://www.ubuntuupdates.org/ppa/getdeb_apps?dist=trusty
wget -q -O - http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add -
sudo sh -c 'echo "deb http://archive.getdeb.net/ubuntu trusty-getdeb apps" >> /etc/apt/sources.list.d/getdeb.list'

After this, do:

sudo apt-get update

and finally:

wskellenger@marquette ~ $ sudo apt-get install freemind
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  freemind-plugins-help freemind-plugins-svg freemind-plugins-script
  freemind-plugins-map freemind-browser
Recommended packages:
  freemind-doc
The following packages will be upgraded:
  freemind
1 upgraded, 0 newly installed, 0 to remove and 27 not upgraded.
Need to get 20.1 MB of archives.
After this operation, 18.3 MB of additional disk space will be used.
Get:1 http://archive.getdeb.net/ubuntu/ trusty-getdeb/apps freemind all 1.0.1-1~getdeb1 [20.1 MB]
Fetched 20.1 MB in 15s (1,319 kB/s)            

[Linux] Create a Mind Map (Freemind) from a Directory Structure

I wanted to have a mindmap of the Cyanogenmod source tree.  It is a huge bunch of folders and I just want a nice way to have an overview of the file structure and make notes.

FreeMind, the open source mind mapping tool, has a native utility to import a directory structure, but I found that the resulting mind map was on the heavyweight side.  In fact, using FreeMind 0.9, the native import tool never completed the import -- after 30 minutes or so I had to kill the application.

So I just want to create a FreeMind file that has the directory entries as text nodes, and that's it.  How about using the awesome "tree" command line tool in Linux?

Here is what the output looks like from my /usr/share folder (note I'm using the -d option to show only directories):

wskellenger@marquette /usr/share $ tree -d
.
├── aclocal
├── acpi-support
├── adduser
├── alsa
│   ├── alsa.conf.d
│   ├── cards
│   │   └── SI7018
│   ├── init
│   ├── pcm
│   ├── speaker-test
│   └── ucm
│       ├── apq8064-tabla-snd-card
│       ├── DAISY-I2S
│       ├── Manta-I2S
│       ├── Manta-SPDIF
│       ├── PandaBoard
│       ├── PandaBoardES
│       ├── SDP4430
│       ├── tegraalc5632
│       ├── tegra-rt5640
│       └── Tuna
├── alsa-base
...snip...

Now if you take a look at the options for tree, there already is an option to output XML!  Try "tree --help" at the commandline, and you'll see something like this:

  ------- Graphics options ------
  -i            Don't print indentation lines.
  -A            Print ANSI lines graphic indentation lines.
  -S            Print with ASCII graphics indentation lines.
  -n            Turn colorization off always (-C overrides).
  -C            Turn colorization on always.
  ------- XML/HTML options -------
  -X            Prints out an XML representation of the tree.
  -H baseHREF   Prints out HTML format with baseHREF as top directory.
  -T string     Replace the default HTML title and H1 header with string.
  --nolinks     Turn off hyperlinks in HTML output.
  ---- Miscellaneous options ----
  --version     Print version and exit.
  --help        Print usage and this help message and exit.

So, awesome, shall we see what this option does?

wskellenger@marquette ~/cm11 $ tree -d -X | more
<?xml version="1.0" encoding="UTF-8"?>
<tree>
  <directory name=".">
    <directory name="abi">
      <directory name="cpp">
        <directory name="include">
        </directory>
        <directory name="src">
        </directory>
      </directory>
    </directory>
    <directory name="android">
    </directory>
    <directory name="art">
      <directory name="build">
      </directory>
      <directory name="compiler">
        <directory name="dex">
          <directory name="portable">
          </directory>
          <directory name="quick">
            <directory name="arm">
            </directory>
            <directory name="mips">
            </directory>
            <directory name="x86">
            </directory>
          </directory>
        </directory>
        <directory name="driver">
        </directory>
        <directory name="jni">
          <directory name="portable">
...snip...

And here is what a FreeMind file looks like:

<map version="0.9.0">
<!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net -->
<node CREATED="1410111246409" ID="ID_718284210" MODIFIED="1410122249321" TEXT="Android build env">
<node CREATED="1410122250455" HGAP="11" ID="ID_1487627158" MODIFIED="1410122267863" POSITION="right" TEXT="cm11" VSHIFT="-41">
<node CREATED="1410111257071" ID="ID_181927416" MODIFIED="1410111257071" TEXT="abi"/>
<node CREATED="1410111257072" ID="ID_1980677560" MODIFIED="1410111257072" TEXT="android"/>
<node CREATED="1410111257072" ID="ID_584603213" MODIFIED="1410111257072" TEXT="art"/>
<node CREATED="1410111257073" ID="ID_821356947" MODIFIED="1410111257073" TEXT="bionic"/>
<node CREATED="1410111257073" ID="ID_1847225096" MODIFIED="1410111257073" TEXT="bootable"/>
<node CREATED="1410111257074" ID="ID_777789702" MODIFIED="1410111257074" TEXT="build"/>
<node CREATED="1410111257074" ID="ID_1798981557" MODIFIED="1410111257074" TEXT="cts"/>
<node CREATED="1410111257075" ID="ID_1299267080" MODIFIED="1410111257075" TEXT="dalvik"/>
<node CREATED="1410111257076" ID="ID_283530905" MODIFIED="1410111257076" TEXT="developers"/>
<node CREATED="1410111257077" ID="ID_1162422382" MODIFIED="1410111257077" TEXT="development"/>
<node CREATED="1410111257078" ID="ID_772625792" MODIFIED="1410111257078" TEXT="device">
<node CREATED="1410122307224" FOLDED="true" ID="ID_981437287" MODIFIED="1410122649648" TEXT="common">
<node CREATED="1410122647210" ID="ID_1480883631" MODIFIED="1410122647823" TEXT="gps"/>
</node>
...snip...

To dump the output of "tree" we just do a simple redirect of the output:

wskellenger@marquette ~/cm11 $ tree -d -X > out.xml

Now we just need to make some simple substitutions in the "out.xml" file from "tree" to make it compatible with FreeMind.  This is really simple with Vim.

It looks like we need to do the following:

  1. Rename the "directory" elements to "node".
  2. Add the "CREATED" attribute with today's date.
  3. Add the "ID" attribute (this appears to hold a random number).
  4. Add the "MODIFIED" attribute, which also contains a date.
  5. Rename the "name" attribute to "TEXT"
  6. Get rid of the <?xml> element at the top.
  7. Replace the <tree> tag with <map version="0.9.0"> (use version="1.0.1" for the newer version of FreeMind).
  8. Replace </tree> at the bottom of the file with </map>
  9. Bonus hint: If you have a huge directory structure, like the Cyanogenmod file tree, you might want to add another attribute, FOLDED="true" to each "node" element.

This is really a search/replace problem.  If you don't know regular expressions, you should learn them, because this problem becomes pretty easy, except for the random number part, but even that can be solved with Vim.

So generally we will do some searching and replacing with Vim:

:%s/<directory/<node/gc
:%s/directory>/node>/gc
:%s/name=/TEXT=/gc
:%! perl -pne '$random=int(rand 100000000); s/<node/<node CREATED="1410111247071" ID="ID_$random" MODIFIED="1410111247072" /gc'
:%s/ID=/FOLDED="true" ID=/gc

I manually removed the <tree> tags and added the <map> tags.  I also manually removed the <?xml> tag at the top.  

The tricky part is in yellow: generating the random numbers.  I found the solution for that at StackOverflow.  In that line, we basically callupon perl to generate a random integer, and stuff it into a variable "$random".  After that, perl creates a vim-like search/replace string, searching for <node and updating it as shown.  Vim executes this for each and every line and performs the search/replace.  Slick.

After this, save the file and open it with FreeMind.

WARNING:  FreeMind 0.9.0 is really terrible about handling large maps.  With a huge directory tree (like what is in Cyanogenmod), you may open a few nodes and have it crash on you.  FreePlane seems to behave better with large maps.  Here is the result opened in FreePlane:


WARNING2: After you save the file in FreePlane, you probably won't be able to open it in FreeMind.  So save it as a new filename.

UPDATE: FreeMind 1.0.1 is much better at handling large maps.





Wednesday, July 2, 2014

Mint 17 install with Windows 8, machine doesn't boot...

I tried Arch for about six months but -- a running release system isn't for me.  I like the stability and ease with which Ubuntu/Mint can be maintained.  I was constantly breaking wifi and other things with Arch -- probably I was doing it wrong but, hey, when you use Linux you have a ton of choices.  So back to Mint.
After installing Mint 17 the machine didn't reboot.  I went directly to the grub2 recovery prompt and got something like this:

GRUB loading:
Welcome to GRUB!

error: file '/grub/i386-pc/normal.mod' not found
Entering rescue mode...
grub rescue>

Since you've already installed Mint (or Ubuntu), you can boot again with your LiveCD but then chroot into your new system.  This is kind of like exactly like using jumper cables on a car to get it started (this is the LiveCD), and then removing the jumper cables once the car is running (this is the chroot part).

Good instructions are here.  The important part:

Update Failure

If there was an update that made your system non-bootable and they have fixed it in the repositories, you can use the Live CD to run apt-get to get the new files to fix your system.
  1. Boot the Ubuntu Live CD.
  2. Press Ctrl-Alt-F1
  3. sudo mount /dev/sda1 /mnt  (/dev/sda8 is my Linux partition)
  4. sudo mount --bind /dev /mnt/dev
  5. sudo mount --bind /proc /mnt/proc
  6. sudo mount --bind /sys /mnt/sys
  7. sudo chroot /mnt
  8. apt-get update
  9. apt-get upgrade
If you have trouble accessing your network after chroot, you probably use DHCP and can work around this by adding OpenDNS name servers to your /etc/resolv.conf after you use chroot:
nameserver 208.67.222.222
nameserver 208.67.220.220
 

If you boot with the LiveCD and follow the above instructions, you'll be "in" your new Mint environment -- you just used jumper cables to get there.  At this point we can fix the booting issue.  (Notice that steps #8 and #9 above require you to update all of the packages on your system, this is a great idea to fix things that maybe weren't updated at the time the LiveCD was released.)

Now we need to fix grub.  If you look at my older post about installing Arch on top of Mint13, you know that I've got a Windows 8 system.  My boot partition is actually /dev/sda1 -- this is where the EFI stuff goes.  So just like I mentioned in that old post, I first need to mount /dev/sda1 to /boot/efi.

mint boot # mount /dev/sda1 /boot/efi

With that done I can run grub-install and tell it to put the efi stuff into /boot/efi (which will go into /dev/sda1 since it is mounted there).  If you are uncomfortable at this point I suggest you find some help elsewhere, like the Ubuntu forums.  There are also some tools like boot-repair that work quite well.  If you know what is going on so far, continue reading:

 
mint boot # grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=mint17 --boot-directory=/boot --recheck
Installing for x86_64-efi platform. 
Fatal: Couldn't open either sysfs or procfs directories for accessing EFI variables. 
Try 'modprobe efivars' as root. 
Fatal: Couldn't open either sysfs or procfs directories for accessing EFI variables. 
Try 'modprobe efivars' as root. 
Installation finished. 
No error reported. 


mint boot # modprobe efivars 


mint boot # grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=mint17 --boot-directory=/boot --recheck 
Installing for x86_64-efi platform. 
Fatal: Couldn't open either sysfs or procfs directories for accessing EFI variables. 
Try 'modprobe efivars' as root. 
Fatal: Couldn't open either sysfs or procfs directories for accessing EFI variables. 
Try 'modprobe efivars' as root. 
Installation finished. 
No error reported. 


mint boot # grub-mkconfig -o /boot/grub/grub.cfg 
Generating grub configuration file ... 
Found linux image: /boot/vmlinuz-3.13.0-24-generic 
Found initrd image: /boot/initrd.img-3.13.0-24-generic 
No volume groups found done 
mint boot #

Hm, that doesn't look good. Turns out I didn't boot the LiveCD the Right Way. I used the legacy method of booting and I needed to use the UEFI method.  I shut the machine down and restarted it. 

Now go into your BIOS setup and create a new EFI entry that will point to grub.  I talk about doing this in another old post.

To my surprise, after configuring the new UEFI option, the system booted. So I booted into my new Mint system but then I re-ran grub-install just to be sure:

wskellenger@marquette /boot $ mount | grep boot
/dev/sda7 on /boot type ext4 (rw)
/dev/sda1 on /boot/efi type vfat (rw)


wskellenger@marquette /boot $ sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=mint17 --boot-directory=/boot --recheck
[sudo] password for wskellenger:
Installing for x86_64-efi platform.
Installation finished. No error reported.


wskellenger@marquette /boot $ sudo grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.13.0-24-generic
Found initrd image: /boot/initrd.img-3.13.0-24-generic
  No volume groups found
Found Windows Boot Manager on /dev/sda1@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for EFI firmware configuration
done


wskellenger@marquette /boot $


You should be booting now.


Sunday, June 8, 2014

Jeep TJ (Wrangler) Oil Cap Breaks During Removal

Here is what happened to the oil fill cap in my 2006 Jeep Wrangler when I tried to remove it:


Isn't that nice?  Much more complicated than it needed to be, this oil cap has some teeth in it that ensure it can only be tightened to a specific torque, after which it will make a ratcheting "click click click" noise as it is tightened.  The teeth are angled such that when you remove it, they interlock and will not ratchet.

The problem is, all of these pieces are plastic.  And it's all broken.

Here is how I got the fill cap off after it broke:


And here is what I ordered from Amazon to replace it:


The new piece is solid plastic with a rubber o-ring.  It will not split in half.


Tuesday, May 6, 2014

ASUS Cube: Disable Voice Search Key, Add TV Power Key

The Asus Cube (image from Amazon.com)
I was able to disable the voice search key on the ASUS Cube, as well as turn the Netflix key into a TV power key simply by remapping these keys in the keyboard layout file.  

I won't go into great detail about getting root on this device here, you can find that yourself.  Root is however required to proceed. 

Look for this file: /system/usr/keylayout/Vendor_0b05_Product_17ca.kl.

The /system filesystem must be mounted with read/write access.  You can do this from adb or the awesome ES File Explorer is able to do this.

Change the following lines:
key 87    KEYCODE_VOICE_SEARCH
key 88    KEYCODE_NETFLIX

change to:
# key 87    KEYCODE_VOICE_SEARCH
# key 88    KEYCODE_NETFLIX
key 88    TV_POWER


Reboot the device completely, a good way to do this is by issuing "adb reboot".  Another way is to disconnect the power to the device.

Now you can stop accidentally hitting the voice search key and have a "sort of" working TV power key.  The reason I say this is because the IR blaster is required, so the newly-added TV_POWER button will not work unless you have the Cube powered up already.

If you don't want to change the Netflix key, you could, for example, change the existing TV/STB key to be TV_POWER.  I am not at the moment a Netflix subscriber so this key is useless to me.





Thursday, April 10, 2014

Resistor Parts Drawer Organization

I've got a terrible resistor organizing scheme going on and I want to fix it.  So I browsed around on the interweb hoping to find some advice.  This is probably all you need, a single discussion on stackoverflow.com where several different options are discussed.  I went with the top-rated one and I also discovered several photos on Google Images of people doing it this way.

So here's how Nich Fugal did it, and I like it very much, except there is a mistake on his diagram (55 and 75 ohms are the same colors).  Easy enough to correct, he provides an Adobe Illustrator document which you can import into Inkscape if you don't have Illustrator (I don't).

While I was making the small correction, I re-arranged the glyphs to fit on Avery 5160 mailing labels, I have some laying around here from when I was printing address for Christmas cards.  Here is the Inkscape document (for printing labels) if you want to use it.


You'll see some very faint lines, these are the approximate locations of the labels -- I'm a smidge off but it is pretty dang close.  You can make these lines completely transparent for printing or delete them altogether.  There are also some centerlines that I used to center the glyphs on each label.

Here are a couple of photos:

Applying the labels, my daughter Emma holding up the labels so I could take a photo...

The finished drawers!
I will probably create some "sub" drawers for the "10_" resistors, as this drawer is pretty stuffed.  Thanks to Nich Fugal for publishing these drawings, and check out his blog, called Makeatronics.

Thursday, January 16, 2014

Arch Install over Existing Linux (Mint) Installation with Windows 8 UEFI

Wow, that title sounds like fun.

Well, it wasn't bad at all.  After using Mint for a couple years I started to get frustrated with the outdated packages in APT (to name a few: scilab, hplip, freemind, bluez).  I liked Mint just fine, and keeping the system up to date is quite painless, which is a lot more than I can say for the several years I spent with Gentoo.

That being said, as I Googled for problems I was having with my Bluetooth setup, I noted that most of the hits were generated by archlinux.org.  I read a little about the distro and I decided to try it out.

For installers, there is so much information available on the Arch wiki it isn't even funny.  There's the 30,000 foot installation guide, which for experts is more of a checklist if you've done it a lot.  For everyone else but the sysadmins and hard-core experts, I recommend their beginner's guide.  This will have you going in no time.

The first thing I noticed was how small the LiveCD was -- it's only 500MB or so.  This is because Arch gives you a bare, and I mean BARE bones setup.  You won't find photo managers, a word processor, solitaire, and mine sweeper.  You won't find ANYTHING except the bare basics to boot the system and get you going.  Everything after that is what YOU add, and this can sometimes be shocking.  For example, if you think you might connect to a secure wifi network with your laptop, you might want to install wpa_supplicant.

Before installing Arch, I spent some time cleaning out my Mint system.  Not unlike moving day, you've got to pack your crap and move out.  This takes some time.

Once I thought I was ready to go, I knew I wasn't going to follow the beginner's guide to a T.  All I really needed to do was wipe my root partition, install the new kernel, set up the new environment, and reboot.

So, I didn't need to know about partitioning or formatting.  I knew I needed to start somewhere in that area of the guide.

After booting the LiveCD I quickly realized I needed to have some knowledge about the existing partitions.  I used lsblk:

$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 465.8G  0 disk 
|-sda1   8:1    0   500M  0 part
|-sda2   8:2    0    40M  0 part 
|-sda3   8:3    0   128M  0 part 
|-sda4   8:4    0   500M  0 part 
|-sda5   8:5    0   232G  0 part 
|-sda6   8:6    0   7.2G  0 part 
|-sda7   8:7    0 190.8M  0 part
|-sda8   8:8    0 220.3G  0 part
`-sda9   8:9    0   4.9G  0 part

Well, I know the 200+ GB partitions are my Windows 8 drive and my Linux drive, but I wasn't sure which.  I just had to mount them and take a look around to figure out what was what.

I ended up scribbling the following down on a scrap of nearby paper:

/sda8 --> data/root
/sda9 --> swap
/sda7 --> boot/grub

I think it is obvious, but I want to note, that if you follow any instructions here you'd better be damn sure you know what you're doing.  Computer configuration can be UNFORGIVING.  If you are attached to any data on your hard drive, you'd better back everything up right now.  The computer doesn't particularly care if it blows all of your wedding pictures away.  You have been warned.

Now then -- I formatted /sda8 as ext4 (it already was formatted ext4, but I basically wanted to wipe it).  I did a "swapon /sda9", I mounted sda7 as /boot, and I chrooted into sda8.  (Okay, there was a little more to it than that but I basically followed the beginner's guide after the part about partitioning your system.)

Boom, I was in my new Linux system.  Now the tricky part was setting up GRUB.  There is a lot of info about GPT, UEFI, etc all over the Arch Wiki.  In particular see the excellent grub guide.  Most of the guides are taking you from ground zero, where you're starting with a blank drive.  In my case, I had a drive that was already populated.

In particular there are some warnings about checking for a GPT and an ESP here.


I didn't see a GPT when I tried using parted as described above.  In fact this is what I've got:

[root@marquette /]# parted /dev/sda print
Model: ATA ST500LM012 HN-M5 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system     Name                          Flags
 1      1049kB  525MB   524MB   fat32           EFI system partition          boot
 2      525MB   567MB   41.9MB  fat32           Basic data partition          hidden
 3      567MB   701MB   134MB                   Microsoft reserved partition  msftres
 4      701MB   1226MB  524MB   ntfs            Basic data partition          hidden, diag
 5      1226MB  250GB   249GB   ntfs            Basic data partition
 7      250GB   251GB   200MB   ext4
 8      251GB   487GB   237GB   ext4
 9      487GB   492GB   5264MB  linux-swap(v1)
 6      492GB   500GB   7765MB  ntfs            Microsoft recovery partition  hidden, diag

So there's my ESP, partition 1 or /sda1.  I don't see "Partition Table: GPT" as the wiki mentions.  The article also mentions:  "An EFI System Partition (ESP) is needed on every disc you want to boot using EFI. GPT is not strictly necessary, but it is highly recommended and is the only method currently supported in this article."

Okay then, I don't think I have it, and I'm not messing around with these existing partitions lest I break my Windows 8 installation.

Check out the UEFI Alternative Method.  Here we are getting into some interesting commands.  What I noticed while I was poking around on /boot is that I already have a directory called /boot/efi.  FURTHER, I noticed while poking around the EFI parition (sda1 for me), that there was /Boot, /EFI, /Microsoft, /linuxmint directories.  Inside these I would drill down and eventually find some *.efi files.  Presumably this is where the booting magic happens.

I ended up mounting /dev/sda1 at /boot/efi:

[root@marquette /]# mount /dev/sda1 /boot/efi

Following the alternative instructions on the Arch grub wiki, I did this (modified what was on the wikipage and copied below):

# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch --boot-directory=/boot --recheck --debug

Don't forget the equal signs after the command line arguments!  You might get errors without some of them.  If all was successful, you'll see some stuff like this at the end:

grub-install: info: executing efibootmgr -c -d /dev/sda -p 1 -w -L arch -l \EFI\arch\grubx64.efi.
BootCurrent: 0008
Timeout: 0 seconds
BootOrder: 0008,0001,0002,0003,0000,0004,0005,0006,0007
Boot0000* mint
Boot0001* Realtek PXE B09 D00
Boot0002* P4: HL-DT-ST DVD+-RW GT80N    
Boot0003* P0: ST500LM012 HN-M500MBB     
Boot0004* Windows Boot Manager
Boot0005* UEFI: IP4 Realtek PCIe FE Family Controller
Boot0006* UEFI: IP6 Realtek PCIe FE Family Controller
Boot0007* linuxmint
Boot0008* arch
Installation finished. No error reported.

It turns out all of the crap above will be visible by the BIOS -- these *are* your UEFI boot options.  You'll want "arch" to be your main entry point.  (I still have to figure out how to get rid of some the old mint stuff.)

Next do: 

# grub-mkconfig -o /boot/grub/grub.cfg

[root@marquette boot]# grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux
Found initramfs image: /boot/initramfs-linux.img
Found fallback initramfs image: /boot/initramfs-linux-fallback.img
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/initramfs-linux.img
Found linux image: /boot/vmlinuz-3.12.7-031207-generic
Found initrd image: /boot/initrd.img-3.12.7-031207-generic
Found linux image: /boot/vmlinuz-3.12.6-031206-generic
Found initrd image: /boot/initrd.img-3.12.6-031206-generic
  /dev/cdrom: open failed: No medium found
Found Windows Boot Manager on /dev/sda1@/EFI/Microsoft/Boot/bootmgfw.efi
done

Now, reboot and see if it worked.  If all went well you should see the grub boot screen.

If you get a grub command line, something went wrong.  You can try following these instructions to see if you can get up and running again.

Good luck.

Monday, January 6, 2014

Wii Remote Plus and Linux

I've had this happen to me several times:

  • Find some cool project on the internet involving some piece of hardware
  • Run out and buy the hardware
  • Can't get hardware to work as advertised
  • Discover that the hardware I bought is revision "d" and I needed revision "c or lower"
Welp, if you're trying to get a Wiimote to work, you're might be here because you can't get it working or you don't know what to do next.

The first thing I learned is that there are several types of Wiimote controllers.  The basic one looks like this:

Wiimote, image from http://metroid.wikia.com/wiki/Wii_Remote

Now, I ran down to Best Buy to get one of these, and I found about FIFTY of these (at least) hanging on a rack, in all different colors.  Except they were slightly different.  What I got was the Wii Remote Plus:

Wii Remote Plus, image from Amazon.com
This is all confusing since my Wii Remote Plus says "MotionPlus Inside".  Turns out the MotionPlus was a little plugin/add-on for the first Wiimote that gave it higher resolution and more sensing capabilities.  This device is built-in to the Wii Remote Plus, so almost certainly for marketing reasons they had to give this device a new name and a rubber case.  Behind the rubber case the device looks basically identical to the original Wiimote above but it INCLUDES the higher-resolution sensing.  It cost me $31 at Best Buy.

There are add-ons, like nunchucks, drums, guitars, etc.

Now, there is lots of information available about hacking these devices.

Maybe the most well-known is wmgui, part of Donnie Smith's cwiid project:



wmgui, part of the cwiid project

The wmgui program (shown above) runs in Linux and displays the Wiimote sensor outputs.  I didn't get it to work, apparently because I have a Wii Remote Plus.  From what I gather support for the Wii Remote Plus wasn't added.  

Further, this program  requires that you pair to the device directly from the app in userspace, something that seemed to annoy David Hermann:

The XWiimote software stack is a very recent approach to write Linux drivers for the Nintendo Wii Remote. Long time cwiid and wiiuse were the only choices to use Wii Remotes under Linux. However, both tools very badly designed. They require the application that uses the device to perform a Bluetooth inquiry, connect to the device and run a user-space driver instead of adding the device to the Linux input devices and let applications use them with well-defined APIs like linux-input / evdev. An application does not need to connect to keyboards by itself so why should it need to connect to Wii Remotes? Also the libraries provided by both projects either required threads or global objects which is horrible to use in most applications. This is why the XWiimote project was created.

While calling cwiid and wiiuse "very badly designed", David seems to have picked up the torch and created a proper driver (hid-wiimote.ko) for the Wiimote that has been in the Linux kernel since verson 3.1.  

There's also a BlueZ plugin since version 4.96.  This is perhaps why my installed version of bluez was able to pair with the Wii Remote Plus immediately, and for that I give David (and the other project authors) thanks:

wskellenger@marquette ~ $ dpkg --list | grep bluez
ii  bluez                                    4.98-2ubuntu7

I also found that once paired, the arrow keys on the Wii Remote Plus are also used immediately by X.Org (for example to position a cursor), just as described here, although I haven't installed xwiimote-tools yet...  So because I'm suing a kernel 3.12 the support is already there.  This is cool.  I assume I'm already using xwiimote, so I didn't even get to look at wiiuse.  The rest of the article will thus talk about xwiimote and accompanying tools.



Now, I want to see more about the data that is coming from this controller and David describes the xwiimote-tools package that goes with the kernel driver.  This is easy enough to acquire and build from source:

wskellenger@marquette ~/Projects $ git clone https://github.com/dvdhrm/xwiimote.git
Cloning into 'xwiimote'...
remote: Reusing existing pack: 1249, done.
remote: Total 1249 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (1249/1249), 705.21 KiB | 952 KiB/s, done.
Resolving deltas: 100% (604/604), done.
wskellenger@marquette ~/Projects $ cd xwiimote/
wskellenger@marquette ~/Projects/xwiimote $ ./autogen.sh 

...bunch of output skipped...

wskellenger@marquette ~/Projects/xwiimote $ make

At this point the code is compiled and you could run "make install", but I wasn't ready to do that yet, I just wanted to see xwiishow.

wskellenger@marquette ~/Projects/xwiimote $ find | grep xwiishow
./doc/xwiishow.1
./tools/xwiishow-xwiishow.o
./tools/.deps/xwiishow-xwiishow.Po
./tools/xwiishow.c
./xwiishow
./.libs/xwiishow

There she is (bold above).  I tried to run it:

wskellenger@marquette ~/Projects/xwiimote $ ./xwiishow
Usage:
xwiishow [-h]: Show help
xwiishow list: List connected devices
xwiishow <num>: Show device with number #num
xwiishow /sys/path/to/device: Show given device
UI commands:
q: Quit application
f: Freeze/Unfreeze screen
s: Refresh static values (like battery or calibration)
k: Toggle key events
r: Toggle rumble motor
a: Toggle accelerometer
i: Toggle IR camera
m: Toggle motion plus
n: Toggle normalization for motion plus
b: Toggle balance board
p: Toggle pro controller
g: Toggle guitar controller
d: Toggle drums controller
1: Toggle LED 1
2: Toggle LED 2
3: Toggle LED 3
4: Toggle LED 4

Cool, there's a ton of stuff you can play with.  First I'll try 'list':

wskellenger@marquette ~/Projects/xwiimote $ ./xwiishow list
Listing connected Wii Remote devices:
  Found device #1: /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.0/bluetooth/hci0/hci0:12/0005:057E:0330.000B
End of device list

That being accomplished with success, it sees a device #1 which looks like it works with the xwiishow <1> command above:

wskellenger@marquette ~/Projects/xwiimote $ ./xwiishow 1

What I got was a warning that I wasn't running as root, something that looked like this:

Running xwiishow as a normal user.  Press 'q' to exit.
Just press 'q' to exit and try again as root.  Note the warning above "screen smaller than 80x24; no view" -- if you see this you should enlarge your terminal window before you try this:

wskellenger@marquette ~/Projects/xwiimote $ sudo ./xwiishow 1

Now I got a warning that the window still wasn't large enough, so make it at least 160x48 and you'll get this:


Cool! As you move the device around you can see all of the data that it spits out.  You can also see some awesome ASCII art, the likes and caliber of which I haven't seen since my Telix days in the early 90s.  

Now you can play with the other features, like using the keyboard buttons 1-4 to enable/disable the LEDs on the device, or the 'R' key to enable/disable the feedback motor (vibrator) inside.

Thanks to David Hermann (xwiimote), Donnie Smith (cwiid), and Michael LaForest (wiiuse) for their hours of hacking to bring us these cool tools!

Depending on what you want to do, you may need to figure out which package you need.  For the project I've got in mind I'm hoping I can just use xwiimote, since it is already there in the kernel, there isn't any need to install anything else.


Dell Inspiron 3520 + Broadcom 43142 Bluetooth Not Visible/Not Pairing (Linux Mint/Ubuntu)

I started to write a much longer post here but I deleted the whole thing and started over.  Instead I'll just describe what I've done in the past 24 hours to get wireless working on my Inspiron 3520 with the ugly duckling Broadcom 43142 Wifi+Bluetooth card:
  • I updated the Bluetooth drivers *in Windows 8* first.  I saw this recommended somewhere in my research, that the firmware would be updated through Windows first.  I got the latest drivers from dell.com.
  • I updated the BIOS using the update file I found at dell.com for my machine.
  • While I was at it I updated the wifi driver in Windows also (the file was also from dell.com).
Still, after all of that, I didn't have any luck with Bluetooth.  The adapter was simply not visible.

Then:

I upgraded the kernel version from 3.4.x to 3.12.x.  

Boom.  Suddenly the Bluetooth adapter was visible and I could actually use it to connect with devices.  This was something I hadn't seen before yesterday:


I was able to pair devices and everything was spendid.

Unfortunately, wifi stopped working.

At this point I just went to bed, I was tired of messing with this and it was about midnight or so.

Jump forward about 18 hours and I started working on the wifi issue.

This thread was the most help in solving that problem.  The long and short of it is, for this card I've only found that the "wl" kernel module will work to support this thing.  I used this file (available at the above linked thread):

bcmwl-kernel-source_6.30.223.141+bdcom-0ubuntu1_amd64.deb

I installed it with the Package Installer, despite the warning that this version was newer than the 'official' one.  Wifi works now.  All is great, except:

Now bluetooth stopped recognizing devices.

At least I can still see the adapter, where before I couldn't:

wskellenger@marquette ~ $ hciconfig -a
hci0: Type: BR/EDR  Bus: USB
BD Address: C0:18:85:CB:56:42  ACL MTU: 1021:8  SCO MTU: 64:1
UP RUNNING PSCAN 
RX bytes:1575 acl:0 sco:0 events:96 errors:0
TX bytes:1918 acl:0 sco:0 commands:84 errors:0
Features: 0xff 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
Link policy: RSWITCH HOLD SNIFF 
Link mode: SLAVE ACCEPT 
Name: 'marquette-0'
Class: 0x7e0100
Service Classes: Networking, Rendering, Capturing, Object Transfer, Audio, Telephony
Device Class: Computer, Uncategorized
HCI Version: 4.0 (0x6)  Revision: 0x0
LMP Version: 4.0 (0x6)  Subversion: 0x210b
Manufacturer: Broadcom Corporation (15)

Now, I can't confirm that installing the wifi driver caused my bluetooth issue.  To be honest, since it was a full day later, I don't know why I couldn't see devices any longer.  After all, it worked last night!  I tried un-installing the driver, re-installing the kernel, rebooting several times, but no dice, I could not get bluetooth to recognize anything at all.  In fact, all I was trying to do was get back to the performance from last night, where Bluetooth pairing worked.  I didn't care about wifi anymore.

Then I found this post.

Basically it instructs you to install this package:

bt-bcm43142-onereic_0.0+20111116somerville2_amd64.deb

And after restarting the bluetooth daemon, I was in business:

marquette wskellenger # service bluetooth restart
bluetooth stop/waiting
bluetooth start/running, process 7070

I don't think it is working perfectly.  I'm noticing a lot of glitchy behavior, like after pairing my Wii MotionPlus, I notice notifications from the Power Manager that my laptop battery is charging...?  I'll make updates here if I find anything else unusual.  For now I'm happy to see this, native pairing of the MotionPlus without any additional software:


Now, for anyone that reads this:  This Broadcom card is a pain in the ass for Linux users.  I've had nothing but trouble with this thing under Linux and it has poor performance (poor reception, dropping connections) in Windows as well.  In researching these issues, I came across posts marked [WORKAROUND], where the proposed workaround included purchasing a different adapter and being done with this Broadcom nonesense.  I'm seriously considering going that route also.

But then again:  this device seems to work with much less hassle in Windows.

UPDATE (18-Jan-2014): I've got better results with Arch Linux and Bluez5.  I'll write a new post on that.


(Philosophy follows)

A Harley rider once told me that working on the bike and making modifications are part of the experience, part of the fun.

And, to some extent I think that comparison rings true for Linux users.  It is frustrating to me that I can't just start working on my next diversion involving this Nintendo controller + Bluetooth, but at the same time I am motivated to stay up until 2 and 3 in the morning tinkering around trying to get it to work!  Why?  Over the last few years, I've spend countless hours messing around with stuff like this and I sometimes look back and wonder if it was worth it.

If you're trying to bake a cake for the first time, do you assemble the recipe ingredients and then expect that some obscure unused feature of your oven won't work at the last minute?  Of course not.

But at the same time there is something fun about this that I can't explain it to anyone else.  I've got a computer running on 100% free software, and with that brings the ability to examine in great detail how everything works.  I've learned so much from >10 years of messing around that I think at the end of the day, it has all been worth the struggle.

Current time: 12:20 am.