Thursday, May 22, 2014

Null Modem DB9 cable

When connection the i.MX6 micro-computer "Debug" cable to Mac's Serial to USB I need to use DB9 cable with female on both ends. As I found out a simple "Mini Gender Changer" (gender-bender) will NOT do, you need a "Null Modem" cable. 

I will provide pin-put diagram shortly, but as I understand at least pins 2 and 3 are reversed. Later I will Ohm-out the pins and build myself a smaller version of what is pictured above.

Tuesday, May 20, 2014

Connecting to i.MX6 with Ethernet

The first way you will probably connect to i.MX6 is via "Debug" Serial-to-USB cable, which is covered by one of my previous posts.

Connect i.MX6 to Ethernet, if you are using WiFi, you can share the connection with your Mac as shown in the picture below:

Go to your CootTerm, or whatever you use to connect Serial to USB:

root@imx6qsabrelite:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 1e:ed:19:27:1a:b3
          inet addr:  Bcast:  Mask:

Now open Terminal and you can

$ ssh  root@

CAN bus software for Mac OSX


It is quite a hunt to try to monitor CAN bus traffic on Mac.

I started with this list:

Monica by DominantBit - FAIL

  • page comes up empty!

CanTrace - FAIL 

  • requires to provide name, company and email
  • takes forever
  • downloads CANtrace PC

I will update this article once I find a reliable tool.

Any comments?


Here is a Java JNI wrapper project for socket-can C++.

$ git clone

Sunday, May 18, 2014

BeagleBone Black: shutdown

Done working with your Beagle? You don't want to to just yank on the cord, you can shutdown your BBB in couple ways:

1) press "power" button for about 8 seconds. The button is located right next to Ethernet port.
2) execute command

root@beaglebone:~# shutdown
Shutdown scheduled for Sat 2000-01-01 00:04:41 UTC, use 'shutdown -c' to cancel.
Broadcast message from root@beaglebone (Sat 2000-01-01 00:03:41 UTC):
The system is going down for power-off at Sat 2000-01-01 00:04:41 UTC!
Connection to closed by remote host.
Connection to closed.

WAIT until all LEDs are OFF and unplug the USB cord.

BeagleBone Black: updating

root@beaglebone:~# opkg update
root@beaglebone:~# uname -a
Linux beaglebone 3.8.13 #1 SMP Wed Sep 4 09:09:32 CEST 2013 armv7l GNU/Linux

Saturday, May 17, 2014

Mac fails to connect to BBB

The BeagleBone Black is running fine via USB on Mac.
I can see the mounted BEAGLEBONE disk... 

$ pwd
uki@ BEAGLEBONE $ ls -alt
total 1075
drwxrwxrwx  1 uki   staff     512 May 17 22:01 .fseventsd
drwxrwxrwt@ 8 root  admin     272 May 17 22:01 ..
drwxrwxrwx@ 1 uki   staff    1024 May 17 21:35 .
drwxrwxrwx  1 uki   staff     512 May 17 21:35 .Spotlight-V100
drwxrwxrwx@ 1 uki   staff     512 May 17 21:35 .Trashes
-rwxrwxrwx  1 uki   staff    4096 May 17 21:35 ._.Trashes
-rwxrwxrwx  1 uki   staff      30 Mar 18  2013 ID.txt
-rwxrwxrwx  1 uki   staff   41174 Mar 18  2013 LICENSE.txt
-rwxrwxrwx  1 uki   staff     292 Mar 18  2013
-rwxrwxrwx  1 uki   staff   16827 Mar 18  2013 START.htm
-rwxrwxrwx  1 uki   staff     223 Mar 18  2013 autorun.inf
drwxrwxrwx  1 uki   staff     512 Mar 18  2013 Drivers
drwxrwxrwx  1 uki   staff    2048 Mar 18  2013 Docs
drwxrwxrwx  1 uki   staff     512 Mar 18  2013 App
-rwxrwxrwx  1 uki   staff  379428 Mar 18  2013 u-boot.img
-rwxrwxrwx  1 uki   staff      26 Mar 18  2013 uEnv.txt
-rwxrwxrwx  1 uki   staff   99976 Mar 18  2013 MLO

Trying to connect to BeagleBone Black fails.

$ ping
PING ( 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
SSH fails

$ ssh -vvv root@
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /Users/uki/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: /etc/ssh_config line 102: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to [] port 22.
debug1: connect to address port 22: Operation timed out
ssh: connect to host port 22: Operation timed out

I think it is related to me having some USB to Serial drivers installed, but not sure.

Uninstalling previous FTDIUSBSerialDriver

uki@ Extensions $ pwd
uki@ Extensions $ ls -alt | grep FTDI

drwxr-xr-x    3 root  wheel   102 Apr 19  2013 FTDIUSBSerialDriver.kext
uki@ Extensions $ sudo rm -r FTDIUSBSerialDriver.kext
$ cd /Library/Receipts
$ sudo rm -r ftdi*

I searched for the NEWEST Mac OSX 64 bit drivers here (2.2.18):

$ cd /usr/local/lib
uki@ lib $ sudo cp /Volumes/release/D2XX/bin/10.5-10.7/libftd2xx.1.2.2.dylib .


Make symbolic link
uki@ lib $ sudo ln -sf /usr/local/lib/libftd2xx.1.2.2.dylib /usr/local/lib/libftd2xx.dylib
uki@ lib $ 

uki@ lib $ sudo cp /Volumes/release/D2XX/bin/ftd2xx.h /usr/local/include/ftd2xx.h

uki@ lib $ sudo cp /Volumes/release/D2XX/bin/WinTypes.h /usr/local/include/WinTypes.h
uki@ lib $ 

I tried to follow steps outlined here, but I got lost:!topic/beagleboard/gKQtFpdpB6k

in the end... Works Fine WTF!

Making CAN bus

Part List

  • Soldering Iron: I had a cheap 30W iron that came together with RadioShack kit, it is worthless!
  • Buy quality soldering gun and make yourself a fine copper tip out of 12 gauge copper wire.
  • Wire 24 gauge; 20 feet - I did not find any standard for CAN bus colors, in fact I have seen the same manufacturer using different colors in different products.
  • 2x Resistors 120 Ohm (brown, red, brown)
  • several DB9 connectors both male and female so you have plenty of connection points to your CAN bus (sensors, Serial-to-USB, etc.)

When you you go thru dozens of resistors, it is much faster to find them by COLOR, then connecting to multimeter. 

Wiring s/n P397 USB to CAN dongle

Fortunately this part has pretty good documentation about how to wire it

  • PIN #2 white - CAN_L
  • PIN #7 green - CAN_H
  • PIN #1 not connected red - 3.3V DC
  • PIN #6 not connected black - ground

  • When you choose pins make sure you look at the MALE plug from user end, not wires end, they should be marked.

    Wiring iMX.6 board

    The iMX.6 MicroComputer has a 3 pin CAN bus socket that can be used with optional plug part featuring following cables:

    • brown
    • red
    • orange
    The i.MX6 Hardware Manual specifies the following:
    FlexCAN1 module is implementing full CAN specification 2.0b (11/29bit IDs @ 1Mb/s)

    • pin#: X2A4, Signal: X_CAN0_TXD, ST: O, transmit
    • pin#: X2A5, Signal: X_CAN0_RXD; ST: I, receive
    • pin#: X2A7, Signal: 3.3V reference voltage; 
    Unfortunately it does not tell the ORDER, or COLOR of the wires.
    I could not find anything online, so it will be a trial and error. I used an easy screw on connector just so it is easy to switch polarity.

    Here is an image of finished can bus:

    • connects to i.MX6 board
    • it runs over 2 pairs of green/white wire
    • ends with DB9 connectors (one male, one female)
    • it is terminated with DB9 connectors that have 120 Ohm resistors across pins 2 and 7

    Friday, May 16, 2014

    Thrift: language independent communication of Android to Linux box


    This document describes programming language-independent, e.g.:

    • Java to C++, 
    • Java to Python, 
    • Java to Java 
    communication between Android and Linux server (i.e. Mac, Raspberry Pi, BeagleBone Black).

    Installing Thrift Compiler

    On Debian Linux:
    apt-get install thrift-compiler

    On Mac:

    $ brew install thrift
    ==> Installing thrift dependency: boost...==>
    Summary /usr/local/Cellar/thrift/0.9.1: 89 files, 4.8M, built in 2.8 minutes

    Creating Thrift Definition File

    namespace java
    service MyService {
        bool enableMethod();
        bool disableMethod();

    Generate Sources from Thrift Definition File

    $ thrift --gen java -out gen ./src/main/thrift/definition_file.thrift

    This line tells Thrift
    • --gen java - generate Java files (change for C++, etc.)
    • -out gen - put output files in "gen" folder
    • ./src... .thrift - use this definition file

    Gradle Integration for Eclipse

    Open URL:

    Click "Install"and drag it to your open Eclipse.

    this easy.

    ShellEd - Eclipse Shell Script Editor plugin

    I am writing Bash shell scripts very often along with my Java, Android projects, instead editing in TextWrangler I sometimes prefer to open them in Eclipse.

    The plugin supports

    • syntax coloring
    • some completion

    Eclipse Plugin Installation

    Eclipse > Help > Install New Software...
    Add... > Location:

    and follow the instructions.

    Tuesday, May 13, 2014

    Using CAN BUS for automation projects using Raspberry Pi and more

    Why would you want to use the Automotive CAN bus in your automation projects using Raspberry Pi, BeagleBone Black, or more powerful computer?

    1) the computer can control only a LIMITED number of IO pins and your project can have dozens of things to be controlled

    2) you don't want to route dozens of cables back to controller, CAN bus needs only two.

    3) ...

    To find out more come to my mini-workshop on May 14, 2014

    or email me at

    Sunday, May 11, 2014

    Mounting Microcomputer with LEGO

    Let's face it, electronic projects are a workbench tangle of components. 

    I have experimented with multiple techniques to mount my projects:
    - plexiglass with elements screwed to it
    - plexiglass with double sided tape
    - plastic containers, eg. tapperware

    But for modular building nothing is better than LEGO blocks. The construction is very solid and reconfigurable while on the bench and can be glued together with solvent when completed. And looks fun, too.

    I was pulling my hair out how to mount a microcomputer like this I.MX6 as it does not fit in LEGO grid very well. I considered screws and silicon and rubber mounts, but it was not simple, nor elegant.

    What is found out to work the best was to cut a notch in corners of LEGO with Dremel cutting disk. Very simple and fast. You can put a drop of silicone inside the LEGO to work as a rubber dumper, if you have any wiggle/play.

    I am sure someone has done that before, but this technique was my original idea, and I am very pleased with the results.

    #lego #make #bbb #pi

    Friday, May 9, 2014

    Mac: USB to Serial conversion to read i.MX6 SL board using PL2303 chipset cable


    Ability to control i.MX6 board from Mac using USB port.


    I have a following configuration:

    - Mac USB <-> DB9 Serial <-> "DEBUG" DB9 <-> i.MX6 SL board's "J17" (UART)


    I downloaded CoolTerm

    Uninstalled previous versions:
    $ sudo rm -rf /System/Library/Extensions/ProlificUsbSerial.kext
    $ sudo rm -rf /var/db/receipts/*PL2303*.*

    $ sudo rm -rf /var/db/receipts/*ProlificUSbSerial*.*

    Downloaded and installed new DRIVER:
    /Applications/USB_to_Serial/Prolific_PL2303/Mac/Mac\ OS\ 10.6-10.10/PL2303_MacOSX_v1.5.1.pkg


    You may need to click Re-Scan Serial Ports to detect "usbserial"
    The only change you have to make it to change speed to 115200.

    Friday, May 2, 2014

    Raspberry Pi: update packages

    Update packages:

    pi@raspberrypi ~ $ sudo apt-get update
     ... long time...
     pi@raspberrypi ~ $ sudo apt-get upgrade
     ... long time...

    Installing Java on Raspberry Pi

    Installation of Java on Pi is easy, you can ssh to your Pi remotely and just execute:

    pi@raspberrypi ~ $ sudo apt-get update && sudo apt-get install oracle-java7-jdk
    ... long time...
    pi@raspberrypi ~ $ java -version
    java version "1.7.0_40"
    Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
    Java HotSpot(TM) Client VM (build 24.0-b56, mixed mode)

    Formatting CODE SAMPLE in Blogger

    To display my code in Blogger I use this snippet of CSS in my HTML

    <pre style="border: 1px dashed rgb(153, 153, 153); color: black; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; margin: 5px; width: 90%;">    

    and it looks like that:


    Raspberry Pi: find IP address and SSH

    To find the IP address of your Raspberry Pi:

    pi@raspberrypi ~ $ sudo ip addr show | grep inet
    inet scope host lo
    inet 1AA.XXX.YYY.ZZZ/24 brd scope global wlan0

    Then you can log in from another computer:

    uki@.. $ ssh pi@1AA.XXX.YYY.ZZZ
    pi@1AA.XXX.YYY.ZZZ's password: 
    Linux raspberrypi 3.6.11+ .. yada, yada..