Sunday, March 16, 2014


I will be tweaking this moving forward as needed.  Feel free to submit additional modules or modifications either here, or as issues on the github project.

Right now, running two scripts builds a kernel with changes adding CAN and PiTFT (half-broken since Adafruit does NOT distribute source, just binaries), and spi-dma.

Monday, February 24, 2014

PiCAN, finally...

There are scattered instructions on getting CAN running on the PI.  This has a one-stop, and I hope to make it both more clear and automated.

The first hurdle was to regenerate the kernel build tree which I've already covered in all its painful detail. 

Within the above github project is a script that includes that part, patches the .config to add CAN support and builds the kernel tree.  It also adds two extra modules including a better mcp2515 driver (the mcp251x will lose data and lock).  It then packages it up as a compressed tar, ready to send to the pi.

The discussion in the raspi forums is 20 pages.  All of this information is somewhere in there, but usually after a series of "try this", "set that", "what driver?", so it is easy to get lost as to which piece solved that part of the puzzle.  There are also brief notes.

And it has a module load and start reading script.

Saturday, February 15, 2014

Adafruit PiTFT with minimal hacking

Technically, it is dual-head.  Both the HDMI and the TFT work, and you can select which goes where.  I haven't tried true one-X two-display, and there are some hiccups.

I posted the steps at adafruit, which I am reposting here:

I like to keep the current raspian distro, but just got the PiTft.  What to do?

Turns out it was easy, as long as there was no previous or other /lib/modules/3.6.11+ directory, but since I'm at 3.10.25+, it will work.

1. make a directory to work in, e.g. rpilcd, and change to it
2. download just raspberrypi-bootloader-adafruit-112613.deb
3. use "ar xv raspberrypi-bootloader-adafruit-112613.deb" to extract the files.
4. use "tar xvzf data.tar.gz" which will be the install.
5. delete the usr/ tree.  (note changing /usr/share/doc...config.Debian.gz will make it harder to find the kernel if you want to recompile).
6. go into boot/ and delete everything except kernel.img - rename kernel.img to kern_lcd.img
7. create this smaller archive, "tar cvzf pitftkern.tgz lib boot".
8. copy pitftkern.tgz to the pi using scp or another method.
9. from the top directory on the pi, unpack the archive "cd /; sudo tar xvzf pitftkern.tgz"
10 edit the /boot/config.txt file and add a line, "kernel=kern_lcd.img".  This tells the bootloader which kernel image to load.
(I have my kernel with framebuffer rotation support as a different name, and the stock kernel.img as alternatives preceeded by a #".
reboot.  Do the proper insmods for spi and the tftfb and the lcd should activate.  cat /dev/random >/dev/fb1 should show colorful noise.  Follow the rest of the tutorial

You can follow the instructions to make it permanent, but it will only work if you boot the particular kernel with the LCD support (mainly for the one module required).

The two "consoles" are side by side, using "con2fbmap X Y" - this program takes "ttyX" and maps it to /dev/fbY, e.g. "con2fbmap 1 1" maps console 1 to framebuffer 1.  framebuffer 0 is normal video.  Switch consoles by control-alt-FunctionX.  (alt-FuncX if not under the xwindows system).

In /usr/share/X11/xorg.conf.d/99-fbturbo.conf is a line saying which framebuffer, change "/dev/fb0" to "/dev/fb1" and X will appear on the LCD.

(I haven't found the touchscreen - not any of the /dev/input devices - but my usb combo has a mouse).

While waiting for a module update, and keeping my raspian current, I can still play with the display.

To go back to the current distribution (which has other changes I'm working with), I need just change the kernel= line in /boot/config.txt.

Friday, February 14, 2014

Breaking the spirit of the GPL - Pi edition.

The GPL says you must post the source which can recreate the exact binary you distribute.  The whole point is so that it would be easy to modify.  Tivo broke it one way - the loader required a digital signature, so you could build it but not run it.

There is a second way.  Obfuscation.  For those who aren't aware, there are mechanisms in the kernel to prevent bugs by insuring modules (things like filesystem, drivers, network protocols) that aren't always used match up with the running kernel and other modules.  So there are checksums for each symbol in the module and kernel so you can insure you are talking to the right version of the kernel code, not one that has structures, data, or the API moved.

So to build an exact kernel where you can add a module, you need the exact source.  And the config, but the kernel places that in /proc/config.gz  Technically you don't need the source, but certain build info which is easily extracted after a build.

Part of the cooperation is that everyone tries to use the stock kernel and add to it, otherwise if everyone built their own kernel and modules, it would be nearly impossible to merge the features.  But that is why it is normally easy and the kernel itself has ways to help.

Lets say some company wanted to make it as hard as possible to rebuild the source so you could easily add to the kernel.  One thing they could do is post 999 wrong, bad, misconfigured images, all encrypted so you had to build the kernel to find out "is this the one?", and the one good kernel.  But used random numbers so it would be very hard to figure out which one was which.

Raspberry Pi does something similar using git.  The build image for every kernel installed in an update is in their repository, but good luck finding the one corresponding to the one running on your particular PI.

One process is documented here toward the end:
As of this post, the --depth of the git clone needed to be 200 (maybe less but over 100) to get the kernel.  I wasn't kidding about the 1000 random numbers.  Then, in something that may take longer than building the kernel, you have to do "git log --patch" and search for the version string that uname -a gives.  You have to find where the string was added as there might be more than one match.  Then search farther to find extras/git_hash which will have another long random string.  You want to do git checkout .

I already noted the kernel itself can generate "easy build" data, but git itself has branching, tagging, and labeling where they could if they wanted to tag certain versions as the "actual release".  Then you would just have to find a release around the time or the version number - a much smaller search, and a simple parameter to checkout.

The other way to get this hash is on the pi, go to /usr/share/doc/raspberrypi-bootloader and read the first entry in changelog.Debian.gz (zless, zcat | head).  There will be a hash there as the 5th column (awk '{print $5}').  That isn't the right hash, but from there you can get:< FIRST HASH >/extra/git_hash 
which contains the magic number for the checkout.  They could copy this file or number somewhere when they install a new kernel. but don't for some reason.

It shouldn't be this hard.

Only after doing a 'git checkout ' do you have the corresponding kernel source.  Cross compiling and the rest are another issue, but known and simple (I've been doing it since the excellent Nokia nSeries tablets - actually earlier back to the days of the DEC Alphas, but not as comprehensively).  And it will be faster on a build machine.

I will continue in later posts with scripts I use to do the pulls and builds to add features, e.g. one to rotate the framebuffer and add CAN.  But for those to work, you need to have the git_hash and the /proc/config.gz

But here is the one I use for the kernel which is current as of this post that just rebuilds the kernel and modules (and the firmware) which should be identical to the stock kernel.  Remember that as time passes, the --depth will need to be increased for the hash to be found.

# kernel hash
# /proc/config.gz from the pi

export BASEDIR=~/pibuild

mkdir $BASEDIR
git clone --depth 250
git clone git://
export CCDIR=$BASEDIR/tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin
export CCPREFIX=$CCDIR/arm-bcm2708-linux-gnueabi-
export KERNEL_SRC=$BASEDIR/linux
mkdir $BASEDIR/pitree
mkdir $BASEDIR/pitree/boot

git checkout $HASH
zcat $CONFIGZ > .config

ARCH=arm CROSS_COMPILE=${CCPREFIX} make oldconfig
cp arch/arm/boot/Image $INSTALL_TREE/boot/

Friday, February 7, 2014

Fedora Fail

I had Fedora 19 on my old (about 10 years) MacBook Pro.  Ok, I used "fedup", but it died halfway during the upgrade, though it still booted.  But yum was completely confused listing both F19 and F20 packages with no way to tell it to fix, finish, whatever, and running fedup again didn't help.  There was no apparent way to clean the mess up - I couldn't even find a way to do "yum remove fc19-version-of-a-package" leaving the fc20 intact.

Yum is well named being one piece of morbidly obese, slow, bloated python.  When you hit control-c, usually nothing happens for the better part of a minute.  Even when you've typed the wrong thing.  And if you forget to specify -C, it will spend several minutes refreshing the repo data - and is too stupid to keep the old one around and only when successful replace it, so the moment the first download has started, you may as well get coffee.  And it seems to want to refresh every few hours.  Yum eats memory, cpu cycles and time.

OK, I didn't have any real data, so reinstall would be simple, right?  No.

First, I'm running 64 bit everywhere, but apparently the Linux Distro meisters are worried about something other than actually being able to install their distros.  You can get past the dead boot select screen if you clean up the image.  I'm not sure on the 32 bit since I'm doing some other maintenance and need to wait until it finishes.  I should note the live 64 bit redo does work.

Here is my version of his script

mkdir -p /mnt/sr0
#omit "-o loop" if doing so directly from a cd and not a DL image
mount $1 -o loop /mnt/sr0
mount /dev/sr0 /mnt/sr0
rm -rf isotmp
cp -a /mnt/sr0 isotmp
LABEL=`grep LABEL isotmp/EFI/BOOT/grub.cfg | head -1 | sed -e "s/^.*LABEL=//g" -e "s/ ro .*//g"`
mkisofs -r -b isolinux/isolinux.bin -c isolinux/ -no-emul-boot -boot-load-size 4 -boot-info-table -V $LABEL -o $LABEL-Mac.iso isotmp

That gets you to the snake god that demands you follow the liturgy of the sacrifice precisely.  In this case although I already had an ext3/4 partition, it was already formatted (and I could redo-it in another console), it refused to install there.  I don't know why.  There is some brokenness in the EFI/MBR magic Apple uses and a known bug with FC20 that I tried a bypass.  But I could still access all of it from the console.  There was only a hiccup with GPT.

But the snake demands I use it, and not bypass any step even if for my case it ends up being buggy and broken and I know exactly what is going wrong.

I also tried the even more broken text mode that could not find a mirror although I could access the web fully in the X session.  It refused to install from the (live) CD.  It couldn't find http:// or https:// URLs.

I should also point out anaconda is another aptly (pun intended) named huge, slow, piece of python bloatware.

And there are no instructions on how to manually install.  I think I just need to redirect yum and the list of base RPMs and run grub2 (will grub2 ever get out of beta?).  I've also literally copied all the files off a Fedora 20 bootable USB stick and used grub2 and a bit of editing.  But not for the older Macs.

If I get it running, I will try to document it, but much of the promise of opensource is getting broken by the complexity.  The bling interfaces have become not merely a shell around an engine you can make work, they are now an end unto themselves.  The opensource community has done better.  And can do better.

Thursday, February 6, 2014

I'm in the process of documenting the differences in my setup, so I'm recreating it starting with the latest raspian wheezy.

I only use the raspi-config to set the keyboard (I'm in the US and all those command line and regex chars are elsewhere).  Then I exit.

First, I do "apt-get -y update"

Then one command I found here explained how to setup a bluetooth keyboard but not include the cups drivers for every printer.

He recommends:
sudo apt-get install --no-install-recommends bluetooth
sudo apt-get install bluez-utils blueman
But I just do the first. Then "apt-get install -y `cat tzpiadd`"  or do them individually using "for i in `cat tzpiadd`; do apt-get -y install $i; done" in case some are missing.

There are more things I manually installed or built, but these are from "dpkg -l".

Here is my list of the additional packages:

apache2-utils astyle at-spi2-core avahi-daemon avahi-discover avahi-dnsconfd avahi-ui-utils avahi-utils bc bind9-host blueman bluetooth bluez bluez-utils cadaver cgroup-bin cmake cmake-data davfs2 dnsmasq dnsmasq-base dnsutils doc-base edbrowse emacsen-common epiphany epiphany-browser epiphany-browser-data epiphany-data evince evince-common firmware-linux-free freepats ftp fusedav geoip-database gir1.2-atk-1.0 gir1.2-clutter-1.0 gir1.2-cogl-1.0 gir1.2-coglpango-1.0 gir1.2-freedesktop gir1.2-gdkpixbuf-2.0 gir1.2-gstreamer-0.10 gir1.2-gtk-3.0 gir1.2-json-1.0 gir1.2-pango-1.0 gnome-accessibility-themes gnome-desktop3-data gnome-icon-theme-symbolic gnome-js-common gnome-themes-standard gnome-user-guide gpm gstreamer0.10-pulseaudio:armhf gtk2-engines-pixbuf:armhf hexedit hostapd hwdata ifmetric imagemagick imagemagick-common isc-dhcp-server liba52-0.7.4 libaa1:armhf libao4 libao-common libapr1 libaprutil1 libasound2-plugins:armhf libass4:armhf libatk-bridge2.0-0:armhf libatspi2.0-0:armhf libavahi-core7:armhf libavahi-gobject0:armhf libavahi-ui-gtk3-0:armhf libavc1394-0:armhf libavcodec53:armhf libavformat53:armhf libavutil51:armhf libbind9-80 libcanberra0:armhf libcanberra-gtk3-0:armhf libcanberra-gtk3-module:armhf libcap-ng0 libcddb2 libcdparanoia0 libcgroup1 libchromaprint0:armhf libclutter-1.0-0:armhf libclutter-1.0-common libcogl9:armhf libcogl-common libcogl-pango0:armhf libdc1394-22:armhf libdca0 libdirac-decoder0:armhf libdirac-encoder0:armhf libdjvulibre21 libdjvulibre-text libdns88 libdv4:armhf libdvbpsi7 libdvdnav4 libdvdread4 libebml3:armhf libenca0 libevdocument3-4 libevview3-3 libexiv2-12 libfaad2:armhf libfam0 libflite1:armhf libfluidsynth1:armhf libfribidi0:armhf libftdi1:armhf libgeoip1 libglu1-mesa:armhf libgme0 libgnome-desktop-3-2 libgpm2:armhf libgraphite2-2.0.0 libgsm1:armhf libgxps2:armhf libiec61883-0 libilmbase6 libisc84 libisccc80 libisccfg82 libiso9660-8 libjpeg8-dev:armhf libjson-glib-1.0-0:armhf libkate1 libkpathsea6 liblensfun0 liblensfun-data liblircclient0 liblqr-1-0:armhf liblua5.1-0:armhf liblwres80 libmagickcore5:armhf libmagickcore5-extra:armhf libmagickwand5:armhf libmatroska5:armhf libmimic0 libmms0:armhf libmodplug1 libmozjs10d libmp3lame0:armhf libmpcdec6:armhf libmpeg2-4 libmpg123-0:armhf libmtp9:armhf libmtp-common libmtp-runtime libnautilus-extension1a libneon27-gnutls libnetfilter-conntrack3:armhf libnetpbm10 libnspr4:armhf libnss3:armhf libnss-mdns libofa0 libopenal1:armhf libopenal-data libopencore-amrnb0:armhf libopencore-amrwb0:armhf libopencv-calib3d2.3 libopencv-contrib2.3 libopencv-core2.3 libopencv-features2d2.3 libopencv-flann2.3 libopencv-highgui2.3 libopencv-imgproc2.3 libopencv-legacy2.3 libopencv-ml2.3 libopencv-objdetect2.3 libopencv-video2.3 libopenexr6 libopenobex1 libopus0 libpam-ck-connector:armhf libpcap0.8:armhf libpoppler-glib8:armhf libpostproc52:armhf libpulse-mainloop-glib0:armhf libraw1394-11:armhf libresid-builder0c2a libschroedinger-1.0-0:armhf libseed-gtk3-0 libserf1:armhf libshout3:armhf libsidplay2 libsoundtouch0:armhf libsox2 libsox-fmt-all libsox-fmt-alsa libsox-fmt-ao libsox-fmt-base libsox-fmt-ffmpeg libsox-fmt-mp3 libsox-fmt-oss libsox-fmt-pulse libspandsp2 libspectre1:armhf libspeex1:armhf libspeexdsp1:armhf libsrtp0 libsvn1:armhf libswscale2:armhf libsystemd-daemon0:armhf libt1-5 libtag1c2a:armhf libtag1-vanilla:armhf libtar0 libterm-readkey-perl libterm-readline-perl-perl libtheora0:armhf libtwolame0 libupnp6 libusb-1.0-0-dev libuuid-perl libv4l-dev:armhf libva1:armhf libva-x11-1:armhf libvcdinfo0 libvisual-0.4-0:armhf libvisual-0.4-plugins:armhf libvlc5 libvlccore5 libvo-aacenc0:armhf libvo-amrwbenc0:armhf libvpx1:armhf libwavpack1:armhf libwebrtc-audio-processing-0:armhf libwildmidi1:armhf libwildmidi-config libwmf0.2-7:armhf libwnck-3-0 libwnck-3-common libx264-123:armhf libxcb-composite0:armhf libxcb-keysyms1:armhf libxcb-randr0:armhf libxcb-xv0:armhf libxmlrpc-core-c3 libxvidcore4:armhf libyaml-tiny-perl libyelp0 libzbar0 libzvbi0:armhf libzvbi-common lighttpd lighttpd-mod-webdav lirc lsof lynx lynx-cur morse netpbm notification-daemon obex-data-server privoxy pulseaudio pulseaudio-module-bluetooth pulseaudio-module-x11 pulseaudio-utils python-avahi python-cairo python-gconf python-gdbm python-glade2 python-gobject-2 python-gobject python-gtk2 python-notify python-picamera resolvconf rtkit samba samba-common-bin socat sox spawn-fcgi speex srtp-utils sshfs subversion synergy tcpdump tdb-tools telnet tightvncserver ttf-dejavu ttf-dejavu-extra ufraw-batch vim vim-runtime vlc vlc-data vlc-nox vlc-plugin-notify vlc-plugin-pulse vnc-java x11-xserver-utils xfonts-base yelp yelp-xsl

Sunday, February 2, 2014


I've been busy but have been doing a few things.

My Pi experiments continue.  I saw a post on removing the ethernet/usb chip and thought it would be nice to have the extra ram (for only about 5mA, more if the processor and swap doesn't have to thrash).


I've also replaced the regulator with a 3.3v switcher from Adafruit. Without the external hub, it uses 122mA with HDMI on, 109 with TV off.   I'm leaving the USB on top as passthru to charge or power the USB hub.

I also tweaked the sdlocker-tiny to use USI - the result is up on, forked from the orignal.

In my sparkfun section of Github, I have added lock and password calls to the SD card interface.  fat32cli is the demo code, but fat32lib has the access code for the SD.  Highly optimized SPI port code.  It also supports 64Gb SDXC on openlog.

I had some Neopixels for a while and just a few hours ago I saw a post about an ATtiny lib.  So I started breadboarding.  Note you can chain the "breadboardable" neopixels by using the shorting jumpers like on PC  Motherboards.  Also, the "Tiny Programmer" from sparkfun has a problem with the surface mount connectors - you tend to push on them when inserting the board, and they break right off.  I used a spare 6 pin to replace it - beneath the board is ground and reset to the two side pins, so I can go to a full ISP.

One of my longer "cleanup" projects concerns getting all my disks collected and backed up properly, all my media in one place, etc.  But I need to run spinrite periodically for the disks to keep them in shape.  It doesn't work well (and neither will the upcoming 6.1) without a true SATA port. 

I was thinking of buying a used PC, but NewEgg had a Shell-Shocker for a Foxconn "book" computer (think netbook but desktop).  This has a SD slot,  two USB3 ports - yes 5G, wifi, and most of the standard stuff - and hdmi so I can plug it into most TVs.  Fedora20 works with a few hiccups which are easy to address (HDMI needs to be Auto, not the "correct" resolution which is the same but the left side is offscreen).  It is terrible at encoding and bzip2 compressing, but really fast at moving data.

Memory not included, but wasn't expensive.  (

See my review under - search for "spinrite".

But the SATA is only 5v, for notebook PCs.  I have eSATA hard drive cases  (

So boot Spinrite from the USB or SD card, and convert disk-drive SATA connection to eSATA.  The hardest part was finding the cable.   - and I had to break off the side tabs on the disk connector and you have to do something to make sure it stays put as it easily twists out due to the stiff cable.

But it is running right now working on a big drive.

It also has a mini-pci slot, I could put an expensive hard drive, but I think a bluetooth or 80211a or something else would be a better value.

Friday, November 15, 2013

Random PI tips

To turn on HDMI AFTER boot with it unplug, you can use "/opt/vc/bintvservice -p; fbset -depth 8; fbset -depth 16".  "tvservice -o" shuts the HDMI off.  You can alias them if needed.

You can append things to /boot/cmdline.txt to change the font and such.  You can also change things in /etc/default/console-setup.  Rotate isn't available (not set in the kernel).

Other things alter cmdline.txt and config.txt in /boot, so back them up.

I expanded the main partition to 3.75Mb so I can use any size SD cards (including 128Gb SDXC).  I add a /data ext4 partitioni, and moved the swapfile (via symlink) and put anything like images or videos there.  This way I can clone the setup easily without copying the entire card.  /var/cache and /var/log are also good candidates.

I don't use scratch and it is one of the biggest items, so it got a lot smaller when I removed it.  I'm not quite down to the beaglebone black 2G, but am getting closer.

One of the key tricks to doing the wpa-roam is to give "functional" ids, like id_str="usedhcp" for the APs that need dhcp (probably all outside your net) - and then for /etc/network/interfaces, remove the "iface default inet dhcp" and replace it with "iface usedhcp inet dhcp".  This will prevent loopback problems with the dhcp server.

You need to add something to /lib/udev/rules.d if you use an external ethernet like my jetpack and want it to always be eth1, even if you plug in other ethernet adapters to the hub (or the one on the model B which will probably always be eth0).  They are enumerated semi-randomly - I have two 7 port hubs, one is two four ports cascaded, and the more remote hub is probed later (lsusb -t), but on a true 7 port hub (Manhattan, and microcenter have them), it goes from a higher to lower port number.
10-network-device.rules contains the following line:
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="xx.xx.macaddress.xx", NAME="eth1"
Note I don't want to mess with eth0 since it will be the "other", and would need to do something else if I ever used an eth2.  I'm also not bothering right now with the wlanN but might if I put different antennas or something else, but then I will have to reread UDEV so I don't have to worry about the mac address, but the manufacturer or something else.  "udevadm info -a -p `find /sys -name eth1` | less" proved helpful to find attributes

iptables just worked for NAT, though I had to duplicate rules to MASQUERADE both ethernet and wifi interfaces.

I disabled hostapd and isc-dhcp-server in the normal bootup and put them (/usr/sbin/service X restart) in rc.local so I could insure they were delayed enough for the wifi to fully configure.  I had problems with them failing when in the "normal" boot order since the interface might not be fully configured or ready when they are started.

I needed the patched (see hostapd for the tiny wifi adapters.

From a BT keyboard tip, you can avoid installing printer drivers which will probably not be used by doing:
sudo apt-get install --no-install-recommends bluetooth
sudo apt-get install bluez-utils blueman
bluez-simple-agent works from the command line.

gpm (mouse to copy/paste the console) also works.  If all you do is open a terminal in X, this makes it easier to just do console only.  Note that raspivid/still will overlay the framebuffer.  You can get away with a smaller graphics processor split, but the preview might look strange and zoom in and out if you try it on a full 1920x1080 screen.

The Manhattan hub has a 2A adapter, and using it I can plug my modded A (3.3v switcher from Adafruit replacing the linear regulator) into one of the ports and it will start and run fine.

"chattr -i /etc/resolv.conf" will make the file "immutable", since I'm using either google or openDNS servers, and really don't want dhclient to edit it, and I tried changing the configuration but didn't manage to find the magic combo.

UPDATE - 11/16

Adding dnsmasq - you don't even need to do anything but increase the cache size - will speed up almost everything.  I've left isc-dhcp-server since I already had it configured, but changed the nameservers from google's to /etc/resolv.conf that has google's and opendns *after* the localhost entry.  I'm still trying to figure how to get /etc/resolv.conf to behave (the "resolvconf" package is supposed to work but all it does it wipe the extra entries, I would need it to add and remove the dhclient nameservers).  For now, it is still "chattr +i /etc/resolv.conf" after I insured it wasn't a symlink.

Sunday, November 10, 2013

Long ride, longer story: Raspberry Pi-Roam-Mania

I was working on some projects back in September, on another trip out west, and I didn't zip up my tour pack and everything spilled out.  I got most of it back, but my Raspberry PI, a camera, and my Valentine1 were run over and smashed (and I didn't find the SDXC card - 128G do work!).  Also my Toshiba Thrive got its screen smashed, but I had a spare and transplanted the flash chip.

I'm back up.

I'm currently working on turning the PI into the ultimate mobile roaming router.  I have a Mifi Jetpack (from - with static route so I can be a server and do other things!)  I have a powered hub with two wifi connections, and of course eth0.

I have the Jetpack on eth1 - it seems to require one of the direct USBs or I get a kernel panic when it routes heavily.

wifi0 uses wpa-roam in the declaration and I do go through the hassle of adding the network {} entries to wpa_supplicant, though might switch to wicd if it gets too tedious.

wifi1 is the exported wifi  connection which my other devices connect to.

Note most gadget ethernet adapters like the one that works for my Toshiba Thrive work and will enumerate.  So for now "eth0" now is a DHCP server with fixed address so when I get home, I can just plug it in and my network is connected.  I'd have to do the dhcp client and default route.

The idea is to have a failover.  When I'm out, I want to stay connected, but not use my Jetpack if I have a good connection.  So wpa-roam will try to find APs I've been to or qualify, and it will override the mifi for routing.  But if it disconnects, the mifi will handle things.

I need to add some kind of VPN - I hope that will preserve connections where they have timed wifi.  Even so, if there is a bounce, "you must agree" page, the Pi will register, so all my local devices will automatically get connected and not have to go through that.

Another help might be to add something like a squid proxy to save bandwidth.  But those are in the future.

I already have my skytraq GPS doing time and (userland) PPS, but I need to work on modding the kernel.  I want to add GPIO edge timestamping so I can see if I can do J1850 directly on the Pi.  (And I'm looking for a CAN interface for my car, then there's the camera...).

So I have a lot of little things done and more to do.  I'll publish when things are more finished, I'm also adding a battery backup with timer, and a 12v in, 19v charge / 5v charge and run the Pi and whatever else ( has a tiny buck to 5v 7A converter).

Wednesday, August 14, 2013


I've had a Raspi for a while, but my original system worked enough and waiting for things like the camera pushed things out.

But right now webgpsd is running (though without J1850 at the moment), and I'm getting the rest done.  I have the PPS going into a GPIO but will need to tweak a few things since gpsd and webgpsd can't easily coexist.

A 128G SD works on the Pi so I should have space for larger or more time-lapse or other recordings.

Also, my new works "out of the box", so I can serve data across it.  I'm using one from - they have great prices and service.  I got mine through the which also has all the accessories I'll need as well as handling activation.  I got a static IP - that caused some confusion but everything is working now.

Then my Samsung player will just use the browser again.

Friday, September 7, 2012

To Butte and Back, the most useful apps and hardware

I took a trip from here in Michigan to Butte, Montana last week.  3600 miles.  It was a blast.  In the case of western South Dakota (near Wall), it was a blast of hot air.  It is bad when it is in the triple digits, worse when they are all the same digit (111F).  Several of my key apps came in useful, and I have a few other recommendations.  I was using my Samsung Galaxy Player 5.0 with my Mifi.  Several areas were below 3G so some of the things loaded slowly (you don't want the weather radar map animations), but the streaming radio worked fine.

Of course I'm running HarleyDroid and my SkyTraq AGPS app, but there are other logging navigation apps.

MyCast Weather - The radar maps kept me from either uselessly waiting for dark non-rainclouds to clear or getting soaked.  The "lite" version works, but it is worth getting the paid version, and you can then have a radar widget on the app screen.  One negative - the contrast in the roads and borders background is low-contrast, which isn't bad indoors, but not as good glancing at the handlebars.  And they don't have a combined cloud-radar map.

Astro Player - Best podcast, audiobook, and music player.  Bar none.  (I don't know of a difference between the regular and Nova - both work, and the unlock will unlock both) You can adjust the playback speed (but keep the pitch) so those sloooow hour of discussions go by in 40 minutes or less.  The auto playlist pointed at downloads (and the editable menu so Delete from SD is on top when I'm done) makes things so easy.  You can create homescreen icons for the different playlists.  One negative - I can't assign a playlist default speedup-slowdown, so if I switch to my music I have to change back to 1.0x playback, and then go back to 1.5x on a podcast.

Tune In Radio (pro) Keep up with your favorite radio or tune in local.  You can pause and it will save the broadcast so if you stop you won't miss anything.  You can even record (Pro version) a particularly interesting broadcast to listen to again later.

Google Maps Location and traffic - sometimes the slowdown is just for a half mile, sometimes the backup is very long so you should get off at the next exit and use some other road.  And you have navigation - where is the nearest restaurant chain with wifi?  Go right there.  Know if you need to be in the left or right lane.

Gas Buddy I could do a search on Google Maps, but this is faster and easier, just use the map view and you find fuel with some idea if it is cheaper at the next exit.

Mapdroyd Doesn't do routing, but you have full OFFLINE maps, so if you go so far off the beaten path that there are no cell towers to do the internet, you can still map out where you are.

GPS Test Displays GPS speed in big letters.  There is a paid "Plus" version that is probably worth getting but I haven't yet mainly because I'm thinking about redoing the displays on HarleyDroid.

Bluetooth GPS Since my HarleyDroid interface uses a 20Hz GPS, sometimes I need to check the reception, signal, and this will do it and even override the internal GPS.

Memory foam earphones These are what I use to listen.  They have different size in-ear cushions.  If they aren't blocking noise they are old - I have the same thing happen with ordinary foam earplugs.  These have a volume control inline so I can turn up the player and pull it back by moving the slide on the cord.  Broadcasts and podcasts don't have consistent volume.

One thing I don't have is a good app or widget that would give me time until sun/moon rise/set/phase - continually updating since going west or east will change the time.  I tried some, and even myCast gives the sunrise/set and moon phase in the currents screen, but there is nothing simple, direct, immediate.

I didn't have my camera mount so I didn't take a time-lapse on my Samsung HMX "flip" style camcorder.  Next time.

Thursday, August 16, 2012

Waterproofing supertape and super rubber bands

Silicone tape

The board is now under my speedometer, but if you were interested in how I encased it, simple.  I wrapped it in (clear) silicone self-fusing tape.  This is good for a lot of things.  Very heat resistant (I have some on my exhaust pipes to avoid scorching myself).  Weatherproof.  Coldproof.

One other very useful thing I use everywhere are silicone rubber bands, but they are in the kitchen department.

Silicone "rubber" bands

These can work as simple rubberbands, I have them holding my mifi to the power supply and to the handlebars, my saddlebags as tiedowns.

I haven't found anything that will erode them, they don't get weak, they work hot, cold, dry, wet.

Sunday, July 22, 2012

Reflections, or lack there of, on Black Shirts

If you were to check my closet, you would notice I have mostly black shirts.  T-shirts mostly.  And that drove the rest of my wardrobe to the dark side to make laundry easier.  There is a simple reason.

For a very long time I was sitting in front of computer monitors that when there were dark areas on the screen, you could see the reflection of whatever was in the room, and typically it would be me and whatever I was wearing, usually my shirt.  I've always avoided patterns or logos, picking primary colors, but they would still show up.  Basic black doesn't.  Even the backscatter from a brightly lit room can create problems.

On my motorcycle, a similar problem presented itself with the Samsung.  The original angle would show my face and the background - blue sky or clouds.  Or the sun.  The Samsung is fairly bright but not enough.  So I got a door screen hinge (they would go flush) and put the 3m superlock fasteners so I could position the screen nearly vertical, where it would reflect my (black) shirt.    After positioning it I braced it and used some ShoeGoo on the vertex of the hinge to hold it at that angle.  Now it is much easier to read, unless I'm turning and it reflects the road, but then it depends on if it is a "black top".  The angle makes things a bit less easy to read in general, but much clearer in sunlight or other bright conditions.

Saturday, July 7, 2012

The HarleyDroid Setup

The contrast was too high on the dial version of HarleyDroid.  If you look closely, on the right side of the top pic you can see my Mifi in plastic (the green power light).

I've done some mods on the code to add the GPS so that it will log, but need to do a few more things.  But I'm getting the bluetooth logs.  I don't really need the 20Hz GPS for the display as the GalaxyPlayer has one and it works very well, but when reviewing the data it helps having TPVs at 50mS intervals.  I may post some KMLs or logs if I have time to clean up the converter.  Apparently the Android verison of google earth can do SOME KML, but apparently this doesn't include those with time information ("When" XML).

The bottom pic shows the clip-on "case" I got at Best Buy.  On the back is some of those 3M locking "velcro-on-steroids" strips.  It isn't going to come off from any amount of vibration or shock, at least not unless it is sufficient to damage the Galaxy Player.  The wrist strap is connected to an S-biner so if it does it won't fall more than a few inches and hang.

Saturday, June 23, 2012

Rev3, I'd rather switch than fight

The current schematic, layout, and gerbers are at under the HarleyJ1850GPS section.

I replaced ONE of the power supplies with a switcher, which required larger caps and an inductor, but it works great.  Over 80% efficiency so when ON it draws less current.  It does not even get warm.  When it shuts off it drops to about 200uA, and over a few minutes drops to under 100uA.  update:  The GPS has a 0.2F capacitor as a second backup source but it is charged (and the GPS clock and static memory are kept alive) via the always on power source, so the current was probably an artifact of recharging the capacitor as it was unplugged for a while.

The left are the bare rev 3 boards.  Top right is rev2, you can see the heatsink, but probably not the large amount of solder and copper.  Bottom right is the rev 3 ready for my ride.

I can make it go lower and cut the part count  since there is a way to get the shutdown pin on the switcher to act as a latching toggle, e.g pull to ground with a 10K, up to the 3.3v out with a 10k.  When on, the 3.3v will keep it on, when off, it will be grounded.  Then use a transistor to isolate and amplify incoming J1850 5v levels  to turn it on by putting it in series with the ground resistor, so it becomes "open" when J1850 happens.  Then use a/the ATtiny pin to pull it strongly to ground to turn it off.  I have some of this breadboarded, but I don't think I will do so for now

One alteration is I can put either a ceramic resonator or a crystal in the same space (with two capacitors adjacent for the crystal).  Using a 10ppm crystal from digikey, the PPS happens right at 1000 milliseconds, where the resonator (at room temp, etc.) was 1001.  This is probably overkill, but the cost difference is slight.

The earlier revision worked well enough, but got warm enough that if I did something like a conformal coating or even put it in a water-resistant box I would worry.  How do I get airflow around the heatsink and/or board.

One particular feature is you can use this as a pure bluetooth GPS (though you would need to remove the ATtiny to prevent shutdown).

The six pins are arranged as:

AtTiny TransmitAtTiny Receive
Bluetooth ReceiveGPS Transmit
Bluetooth TransmitGPS Receive

Normally the connections are BT TX to GPS RX, BT RX to AT TX, AT RX to GPS TX, so the GPS goes through the ATTiny to the bluetooth, but the BT transmit can control the GPS (to allow updating AGPS as an example). Without connectors, it allows it to be reprogrammed, e.g. name or pin changes or even baud rate on the bluetooth, or various configuration on the GPS. The jumper pattern for that (see the silkskreen) is:

| |

To configure as direct bluetooth to GPS:

x x

One final discovery on another topic - some other things I take on my rides.  My 3g Mifi wouldn't charge except with special adapters.  I finally found out why.  I need to short the data lines on the USB going in for it to actually charge.  There may be some other USB magic if attached to a computer, but a dumb 5v charger needs them shorted.  The funky ID resistors like for the Apple iPod/Pad/Phone chargers won't work.

Monday, June 4, 2012

Rev2, Doh repeated.

Somehow when I checked the second revision of the GPS/J1850 I still managed to have the connector too far apart for the GPS, but I corrected that a bit by bending a header so it would go sideways and up.  I fixed it but probably did an undo somewhere.

The other big change was lots of copper so the board would act as a heat sink, and it seems to work, though I don't think I should try it if I'm going to be in Yuma, AZ.

Ultimately I need to use a buck switcher, and have one, but while researching, it is interesting that both have different quiescent or off current needs.  The L1211 is very low, much lower than a 7833 style, so I will probably keep that although I don't have to turn it off for the ATtiny.

The GPS module surprisingly takes 100mA.  The GPS unit itself should take under 50mA (more if in fast scan, but that is off).  The powered antenna takes 10mA, the rest might be from the LEDs or other things.

The Bluetooth module takes 40mA while paring, but it says it would drop to 8mA after it is communicating.  I can shut off the GPS until the bluetooth is paired if I wanted, but I worry about maintaining lock and the time a warmstart would take after the Bluetooth is back on.

The switcher should fix this anyway.

Monday, May 28, 2012

And more, now with Android

I modified BlueTerm to add logging the received data to a gzipped file (in downloads named BT-datetime.txt.gz).  I didn't originally have a WAKE_LOCK to keep the CPU on so it kept cutting out, and I had a hardware problem on the one board I built that gives the BT module apoplexy on occasion - the LED doesn't blink, it just goes off but the GPS is still working.

I think I resolved it and am getting good logs.  Still some rare J1850 errors.  And I need to port my KML converters and such, and sync the J1850 data with the GPS position data (the fix comes out some random number of milliseconds - usually in the hundreds - after the event given the PPS location).

I'm also using a 7805 to drop the voltage so the regulator on board won't overheat at the moment while I sort out the alternatives.  I can't just use a resistor since during crank the voltage drops too far and it shuts off long enough to stop the GPS and break the BT connection.  The 7805 leaks so instead of 100nA, it draws 2.5mA when idle.  I have a few ideas but it would be nice if there was a 3.3v switcher that efficiently downconverted 12v and would work with nanoAmps up to 150mA.

Wednesday, May 23, 2012

And it works, so far.

Adding some physically large resistors to drop the voltage helps, but I may need to adjust it as it seemed to dropout when the engine started.

There were still more bus errors than I like - it may be the handlebar gear display.  But I'm getting nearly all RPM messages which are around 60 milliseconds apart.  The GPS worked too, until near the end when the antenna was loose and it wouldn't get a lock.  The sparkfun heatsink worked.

I might have to break down and put a 7805 or some other regulator in front, but I hope the extra copper on the new boards will work.

One reason I don't care as much about the bluetooth latency is because it isn't very large and I'm including accurate timestamps.  The NMEA sentences from the GPS often have over 100mS delay from where they should be if the PPS was being used to sync them.  Now I have higher precision and can locate a J1850 message close to the physical point it occurred at.

That is one ride but it is as good as I was getting before.

Monday, May 21, 2012

Problems, Hard and Soft

I've been working on the GPS interface and finally sent out the next rev board.  The main difference is I put a lot of copper near the pins to keep the regulator for the bluetooth and GPS units cool.  I also got some heat sinks from Sparkfun.

I get a few bad J1850 messages in an hour's data - it is probably just a glitch on the bus, and there isn't really a pattern.  Many messages actually look good but the CRC is off, and I wrote a program to flip one bit at a time to see if maybe I should change the split for the pwm.

The bluetooth module failed yesterday in the middle of the ride, but the day before the connector came loose and blew the fuse (engine going off in the middle of a ride was disturbing).  I'm not sure what might have caused it, and the GPS still works.  I will be swapping something.

On the software end, the millisecond timestamp had a problem.  Every so often when computing the timestamp it would be far enough off so it would reset in the middle of the second.  Mostly near where the count would overflow, so it was probably a race condition between the timer overflow interrupt, so the high time counter might be out of sync.  I'm going to fix this by monitoring the TCNT and when the current one is less than the original, then increment the high time.  The TOVF interrupt will do a check as well as the COMPB interrupt set to 32768 so without any other traffic the upper time will increment.  Even if the interrupts are delayed, the values will be monotonically increasing until overflow so there won't be multiple increments.

Other than that the timestamp was very stable (though the resonator was slightly fast).

Sunday, May 20, 2012

Harley GPS/J1850: HW and SW probs, the art of embedded

SoftwarI am having a problem with the high word of the timing clock.   This is where the art of embedded comes in.  I plan on adding an OC2 that will do a fake check at 1024 and 32768+1024.  Increment the high word if it would result in an inversion (TCNT1 overflowed).  This will replace the TOVF1.

There are many race conditions, but most are not serious, unless you rely on the interrupt.

The hardware problem is that the power supply, dissipate-ing the drop frolm 12+ V to 3.3.v is causing problems.  The next layout has lots of copper for the hot tne to spread to.

So there will be a rev.  I've added a lot of copper, but need to add VIAs .  This will make soldering a problem.

The last two days were fun for riding - and for testing.  But remembering the logo, I blew a fuse (in the middle of nowhere), but had a spare.  I'm getting a lot closer.