Tag: raspberry_pi

13 March 2014 » Run socat for Arduino IO

Run socat for Arduino IO

A key element of using a Raspberry Pi for a moteino gateway is how to talk to /dev/ttyUSBX for the serial communication.

Problems

  • /dev/ttyUSBX is only available if the USB/Serial connection is there.
  • Need to guarantee that socat is running if /dev/ttyUSBX is available.

Survey of approaches.

  • Run socat from inittab.
  • Start socat at boot with /etc/rc.d
  • Start socat at boot with supervisor.d
  • Run socat from the JRuby gateway script.

Run socat from the JRuby gateway script.

Fork/exec management from JRuby seems to be best done with spoon

What do the JRuby experts say?

fork and exec on the JVM? JRuby to the Rescue!

JavaWorld - fork and exec on the JVM? JRuby to the Rescue!

  • By Charles Nutter
  • JavaWorld May 13, 2009 11:01 PM

As you should know by now, JRuby ships with FFI, a library that allows you to bind any arbitrary C function in Ruby code. So getting fork+exec to work was a simple matter of writing a little Ruby code:


            require 'ffi'
            
            module Exec
             extend FFI::Library
            
             attach_function :my_exec, :execl, [:string, :string, :varargs], :int
             attach_function :fork, [], :int
            end
            
            vim1 = '/usr/bin/vim'
            vim2 = 'vim'
            if Exec.fork == 0
             Exec.my_exec vim1, vim2, :pointer, nil
            end
            
            Process.waitall
            

Update: The biggest problem with using fork+exec in this way is that you can’t guarantee nothing happens between the fork call and the exec call. If, for example, the JVM decides to GC or move memory around, you can have a fatal crash at the JVM process level. Because of that, I don’t recommend using fork + exec via FFI in JRuby, even though it’s pretty cool.

However, since this post I’ve learned of the “posix_spawn” function available on most Unix variants. It’s basically fork + exec in a single function, plus most of the typical security and IO tweaks you might do after forking and before execing. It’s definitely my recommended alternative to fork+exec for JRuby, and to make that easier I’ve bundled it up as the “spoon” gem (gem install spoon) which provides spawn and spawnp to JRuby users directly. Here’s an example session using Spoon to launch JRuby as a daemon. If you just need fork+exec on the JVM, posix_spawn or the Spoon gem are the best way to do it.

headius / daemonize.rb

headius / daemonize.rb


             require 'rubygems'
             require 'spoon'
             
             Spoon.spawnp 'jruby', *ARGV
            

            ~/projects/jruby ➔ jruby daemonize.rb -e "puts 'starting'; while true; sleep 1; puts 'still going'; end"
            
            ~/projects/jruby ➔ starting
            still going
            still going
            still going
            still going
            
            
            ~/projects/jruby ➔ still going
            still going
            still going
            ps
              PID TTY           TIME CMD
              342 ttys000    0:00.06 -bash
              421 ttys000    0:00.49 /usr/bin/java -d32 -client -Djruby.memory.max=500m -Djruby.stack.max=1024k
              363 ttys001    0:00.02 -bash
            still going
            ~/projects/jruby ➔ 
            kistill going
            llstill going
            still going
             421still going
            
            
            ~/projects/jruby ➔
            
github gem - headius / spoon

github gem - headius / spoon

A fork/exec replacement for FFI-capable implementations

Spoon is an FFI binding of the posix_spawn function (and Windows equivalent), providing fork+exec functionality in a single shot.


            Gem::Specification.new do |s|
              s.name = "spoon"
              s.version = "0.0.4"
              s.authors = ["Charles Oliver Nutter"]
              s.date = "2013-03-29"
              s.description = s.summary = "Spoon is an FFI binding of the posix_spawn function (and Windows equivalent), providing fork+exec functionality in a single shot."
              s.files = `git ls-files`.lines.map(&:chomp)
              s.require_paths = ["lib"]
              s.add_dependency('ffi')
              s.license = "Apache-2.0"
            end
            

/usr/bin/socat http://linux.die.net/man/3/posix_spawn http://ruby-doc.org/core-1.9.3/Signal.html

include

def self.posix_spawn(path, file_actions, spawn_attr, argv, env = ENV) int posix_spawn( pid_t *restrict pid, const char *restrict path, const posix_spawn_file_actions_t *file_actions, const posix_spawnattr_t *restrict attrp, char *const argv[restrict], char *const envp[restrict]);

int posix_spawnp( pid_t *restrict pid, const char *restrict file, const posix_spawn_file_actions_t *file_actions, const posix_spawnattr_t *restrict attrp, char *const argv[restrict], char * const envp[restrict]);

http://ruby-doc.org/core-1.9.3/Process.html#method-c-waitpid2

https://github.com/headius/spoon/blob/master/examples/ls.rb

require ‘spoon’

# # Do a recursive ls on the current directory, redirecting output to /tmp/ls.out #

file_actions = Spoon::FileActions.new file_actions.close(1) file_actions.open(1, “/tmp/ls.out”, File::WRONLY | File::TRUNC | File::CREAT, 0600) spawn_attr = Spoon::SpawnAttributes.new pid = Spoon.posix_spawn(‘/usr/bin/env’, file_actions, spawn_attr, %w(env ls -R))

Process.waitpid(pid)

https://github.com/ffi/ffi/issues/336 «««««««««««< wrong, should be issue on JRuby Fail on Raspberry Pi ARM linux JRuby. FFI not available

https://github.com/jruby/jruby/issues/1561 Fail on Raspberry Pi ARM linux JRuby. FFI not available


19 February 2014 » Raspberry Pi Radio Gateway Build

Overview

A Raspberry Pi based gateway to distributed Moteino radio connected Arduinos.

  • Moteino USB attached as radio interface
  • Raspberry Pi hosted gateway based on a JRuby/JVM/Reel based HTTP server

Looking for a minimal server install

Raspbian Wheezy armhf Raspberry Pi minimal image

After the Debian Wheezy armel image I made a new one based on Raspbian armhf. This one is compiled with hard float support, so basically floating point operations are MUCH faster because they are done in hardware instead of software emulation :)

Features include:

  • A minimal Raspbian Wheezy installation (similar to a netinstall)
  • Hard Float binaries: floating point operations are done in hardware instead of software emulation, that means higher performances
  • Disabled incremental updates, means apt-get update is much faster
  • Workaround for a kernel bug which hangs the Raspberry Pi under heavy network/disk loads
  • 3.6.11+ hardfp kernel with latest raspberry pi patches
  • Latest version of the firmwares
  • Fits 1GB SD cards
  • A very tiny 118MB image: even with a 2GB SD there is a lot of free space
  • ssh starts by default
  • The clock is automatically updated using ntp
  • IPv6 support
  • Just 14MB of ram usage after the boot

Other Linux images passed over

The most interesting on here is the raspbian-ua-netinst. There is Github repo for it:

Github repo with raspbian-ua-netinst

I had previously used the Raspbian net installer here: RaspbianInstaller

But the notes now say: Currently we reccomend using hifi’s raspbian-ua-netinst instead if you want to use an installer rather than a pre-installed image.

Dark Basic install notes

Dark Basic install page

Dark Basic Raspbian SDHC Boot image

Start with the Dark Basic install notes

You will have to extract the image with p7zip:


            7za x raspbian_wheezy_20130923.img.7z
            

Then flash it to your SD with dd:


            $ sudo dd bs=1M if=raspbian_wheezy_20130923.img of=/dev/sdc
            

Finally, if you have an sd larger than 1GB, grow the partition with gparted (first move the swap partition at the end).


            $ sudo gparted /dev/sdc
            

At this point install the SDHC card on the RPI, plug in the ethernet cable, plug in the USB terminal cable which will power up the RPI.

Now use screen to watch the boot up messages.

Able to use screen to connect on laptop:


            $ sudo screen /dev/ttyUSB0 115200
            

When connected check the stty values.


             $ stty -a
            

Attempts to use socat instead of screen


             $ sudo socat - /dev/ttyUSB0,b115200
             $ sudo socat - /dev/ttyUSB0,b115200,raw # no
             $ sudo socat - /dev/ttyUSB0,b115200,cs7 # no
             $ sudo socat - /dev/ttyUSB0,b115200,parenb,cs7 # no
             $ sudo socat - /dev/ttyUSB0,b115200,parenb,cs8 # no
             $ sudo socat - /dev/ttyUSB0,b115200,raw,cs7 # no
             $ sudo socat - /dev/ttyusb0,b115200,raw,cs8,start=1,stop=1 # no
             $ sudo socat - /dev/ttyusb0,b115200,parenb=false,raw,cs8,start=1,stop=1 # no
             $ sudo socat - /dev/ttyUSB0,b115200,raw,cs8 # no
             $ sudo socat - /dev/ttyUSB0,b115200,raw,cs7 # no
             $ sudo socat - /dev/ttyUSB0,b115200,raw,cs8 # no
             $ sudo socat - /dev/ttyUSB0,b115200,cs8,parenb=0 # close, but not exact
             $ sudo socat - /dev/ttyUSB0,b115200,cs8,parenb=0,stop=0 # close
             $ sudo socat - /dev/ttyUSB0,cs8,parenb=0,stop=0,ixon=1,ixoff=1 # close
             $ sudo socat - /dev/ttyUSB0,cs8,parenb=0,stop=0,ixon=1,ixoff=1,echo=0
             
             $ sudo screen /dev/ttyUSB0 115200
             $ sudo socat /dev/ttyUSB0,raw,echo=0,crlf
             
             $ socat -d -d -d -d -x TCP:localhost:7758 FILE:/dev/ttyUSB0,b9600,raw
            

Found the IP address on the router: 192.168.88.223

ssh into the RPI and have a go. The root password is raspberry.


             $ ssh root@192.168.88.223
            

Change the root password


            passwd
            

You will have to reconfigure your timezone after the first boot:


             # dpkg-reconfigure tzdata
            

The keyboard layout:


             # dpkg-reconfigure console-data
            

And the localization:


             # dpkg-reconfigure locales
            

Some docs

And proceed

Change the hostname

Edit /etc/hostname to have the hostname.


            $ cat /etc/hostname
            pika
            

Edit /etc/hosts and a line with the new hostname.


            $ cat /etc/hosts
            127.0.0.1	localhost
            127.0.0.1	pika       <<< added this line with hostname
             ...
            

Add a user


            # adduser craig
            
            Note that from now on:
            # prompt means run as root. 
            $ prompt means run as user craig
            

            # su - craig
            

Generate a key pair for the new user


            $ ssh-keygen
            

Check the Debian version


            $ cat /etc/debian_version
            7.2
            

Update the system


            # apt-get update
            # apt-get dist-upgrade
            

Install python, vim, tmux, git


            # apt-get install python
            

            # apt-get install vim tmux git
            

Personalize git


            # git config --global user.name "Your Name Here"
            Sets the default name for git to use when you commit
            
            # git config --global user.email "your_email@example.com"
            Sets the default email for git to use when you commit
            

Set up the vim dotfiles and vundle.


            $ git clone git@github.com:CootCraig/dotfiles_again.git
            
            $ cd dotfiles_again/linux
            $ bash ./install.sh 
            
            cd ~/dotfiles_again/windows/vimfiles/bundle
            git clone https://github.com/gmarik/vundle.git
            

There are some notes on using vundle in the file ~/.vim/bundle/Readme.txt The Raspbian vim does not have python support, so disable UltiSnips vim script. Comment out the following line in ~/.vimrc


            Bundle 'vim-scripts/UltiSnips'
              to
            "Bundle 'vim-scripts/UltiSnips'
            

And then run BundleInstall.


            in vim. :BundleInstall
            

password less ssh

These instructions worked fine.

How to set up ssh so you aren’t asked for a password

Add the contents of the public key file into ~/.ssh/authorized_keys on the remote site (the file should be mode 600).

make user a sudoer


            # apt-get install sudo
            # adduser craig sudo
            

Pause and make a backup of the SDHC image

On the Ubuntu host.


            $ sudo dd bs=1M if=/dev/sdc of=pika_20140220_1441.img
            7519+0 records in
            7519+0 records out
            7884242944 bytes (7.9 GB) copied, 446.404 s, 17.7 MB/s
            
            $ 7za a -t7z pika_20140220_1441.img.7z pika_20140220_1441.img
            
            $ ls -l pika_2014*
            -rw-r--r-- 1 craig craig 7884242944 Feb 20 14:49 pika_20140220_1441.img
            -rw-r--r-- 1 craig craig  254215741 Feb 20 15:09 pika_20140220_1441.img.7z
            

Install Compiler tools


            # apt-get install build-essential checkinstall libtool automake uuid-dev
            
            The following extra packages will be installed:
              autoconf autotools-dev binutils bzip2 cpp cpp-4.6 dpkg-dev fakeroot g++ g++-4.6 gcc gcc-4.6 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libdpkg-perl libfile-fcntllock-perl libgmp10 libgomp1 libltdl-dev
              libltdl7 libmpc2 libmpfr4 libstdc++6-4.6-dev libtimedate-perl m4 make
            Suggested packages:
              autoconf2.13 autoconf-archive gnu-standards autoconf-doc gettext binutils-doc bzip2-doc cpp-doc gcc-4.6-locales debian-keyring gcc-4.6-doc libstdc++6-4.6-dbg gcc-multilib manpages-dev automake1.9 flex bison gdb gcc-doc
              libmudflap0-4.6-dev libgcc1-dbg libgomp1-dbg libquadmath-dbg libmudflap0-dbg binutils-gold libtool-doc libstdc++6-4.6-doc automaken gfortran fortran95-compiler gcj make-doc
            The following NEW packages will be installed:
              autoconf automake autotools-dev binutils build-essential bzip2 checkinstall cpp cpp-4.6 dpkg-dev fakeroot g++ g++-4.6 gcc gcc-4.6 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libdpkg-perl
              libfile-fcntllock-perl libgmp10 libgomp1 libltdl-dev libltdl7 libmpc2 libmpfr4 libstdc++6-4.6-dev libtimedate-perl libtool m4 make uuid-dev
            0 upgraded, 32 newly installed, 0 to remove and 0 not upgraded.
            Need to get 26.8 MB of archives.
            After this operation, 69.2 MB of additional disk space will be used.
            

Zeromq build and install

Source for stable release 3.2.4

This is supported by ffi-rzmq, the JRuby librar I plan to use. I unpacked for build at:


            # cd /opt/zeromq/zeromq-3.2.4
            

The installation will be to /usr/local/


            # ./configure --help
            Installation directories:
              --prefix=PREFIX         install architecture-independent files in PREFIX
                                      [/usr/local]
              --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                                      [PREFIX]
            

Build and install.


            # ./configure
            # make
            # checkinstall
            

A debian package was left here:


            /opt/zeromq/zeromq-3.2.4/zeromq_3.2.4-1_armhf.deb
            

Set up serial console

From /etc/inittab


            ...
            # Example how to put a getty on a serial line (for a terminal)
            #
            #T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
            #T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
            ...
            

However, this is the device file we see:


            $ ls -l /dev/ttyAMA0
            crw-rw---T 1 root dialout 204, 64 Dec 31  1969 /dev/ttyAMA0
            

So let’s add this line to /etc/inittab


            ...
            # Example how to put a getty on a serial line (for a terminal)
            #
            #T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
            T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
            #T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
            ...
            

Screen User’s Manual

Post to raspberrypi.org/forum about Edimax EW-7811UN

I have failed to get Wifi working and would like some help. I’m not sure how how to troubleshoot from here. Here are some details on my setup.

Using this OS image. I want a minimal install with no X.

Dark Basic Raspbian SDHC Boot image

With this USB wifi plug: Edimax EW-7811UN

Boot time messages include these related to the Edimax plug.


            [    3.232011] usb 1-1.2: new high-speed USB device number 4 using dwc_otg
            [    3.364155] usb 1-1.2: New USB device found, idVendor=7392, idProduct=7811
            [    3.380505] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
            [    3.399033] usb 1-1.2: Product: 802.11n WLAN Adapter
            [    3.411807] usb 1-1.2: Manufacturer: Realtek
            [    3.417625] usb 1-1.2: SerialNumber: 00e04c000001
             ...
            [   15.826605] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
            

System reports as.


            root@pika:~# uname -a
            Linux pika 3.6.11+ #545 PREEMPT Fri Sep 20 23:57:55 BST 2013 armv6l GNU/Linux
            

More evidence the Edimax Wifi is seen


            root@pika:~# lsusb
            Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. 
            Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
            Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. 
            Bus 001 Device 004: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]
            

The wifi driver module is loaded


            root@pika:~# lsmod
            Module                  Size  Used by
             ...
            8192cu                490361  0 
             ...
            

Output of iwconfig


            root@pika:~# iwconfig
            wlan0     unassociated  Nickname:"<WIFI@REALTEK>"
                      Mode:Auto  Frequency=2.412 GHz  Access Point: Not-Associated   
                      Sensitivity:0/0  
                      Retry:off   RTS thr:off   Fragment thr:off
                      Encryption key:off
                      Power Management:off
                      Link Quality:0  Signal level:0  Noise level:0
                      Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
                      Tx excessive retries:0  Invalid misc:0   Missed beacon:0
            

The MicroTik Router is seen.


            root@pika:~# iwlist wlan0 scan
            wlan0     Scan completed :
                      Cell 01 - Address: D4:CA:6D:56:86:59
                                ESSID:"Pirates"
                                Protocol:IEEE 802.11bgn
                                Mode:Master
                                Frequency:2.412 GHz (Channel 1)
                                Encryption key:on
                                Bit Rates:300 Mb/s
                                Extra:wpa_ie=dd160050f20101000050f20401000050f20401000050f202
                                IE: WPA Version 1
                                    Group Cipher : CCMP
                                    Pairwise Ciphers (1) : CCMP
                                    Authentication Suites (1) : PSK
                                Extra:rsn_ie=30120100000fac040100000fac040100000fac02
                                IE: IEEE 802.11i/WPA2 Version 1
                                    Group Cipher : CCMP
                                    Pairwise Ciphers (1) : CCMP
                                    Authentication Suites (1) : PSK
                                Quality=100/100  Signal level=100/100  
            

Contents of /etc/network/interfaces.


            root@pika:/etc/network# cat /etc/network/interfaces
            # interfaces(5) file used by ifup(8) and ifdown(8)
            auto lo
            iface lo inet loopback
            
            allow-hotplug eth0
            iface eth0 inet dhcp
            
            allow-hotplug wlan0
            iface wlan0 inet dhcp
              wpa-ssid Pirates
              wpa-psk thepassword
            

But I have not been able to enable the Wifi.


            root@pika:~# ifup wlan0
            Internet Systems Consortium DHCP Client 4.2.2
            Copyright 2004-2011 Internet Systems Consortium.
            All rights reserved.
            For info, please visit https://www.isc.org/software/dhcp/
            
            [ 1389.028246] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
            Listening on LPF/wlan0/80:1f:02:a2:df:94
            Sending on   LPF/wlan0/80:1f:02:a2:df:94
            Sending on   Socket/fallback
            DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
            DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 8
            DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 11
            DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 15
            DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 18
            DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 4
            No DHCPOFFERS received.
            No working leases in persistent database - sleeping.
            

Note, the MicroTik router Wifi is in use by all the laptops we have tried.

Set up wifi

todo list

done

  • password less ssh
  • make user a sudoer
  • checkinstall and compile tools
  • zeromq compile and install
  • serial console

todo

  • wifi setup
  • fixed IP address
  • Oracle JVM
  • JRuby
  • JRuby/Reel test

05 March 2014 » Raspbian netinst

Net Installer Image

Notes

To flash your SD card on Linux:


            xzcat /path/to/raspbian-ua-netinst-latest.img.xz > glop.img
            sudo dd bs=1M if= glop.img of=/dev/sdc
            rm glop.img
            

Boot with the SDHC and view the HDMI video to see install progress.

First boot

The system is almost completely unconfigured on first boot. Here are some tasks you most definitely want to do on first boot.

The default root password is raspbian.

Set new root password:


            passwd
            

Configure your default locale:


            dpkg-reconfigure locales
            

Configure your timezone:


            dpkg-reconfigure tzdata
            

Install latest kernel and firmware package:


            apt-get update
            apt-get install linux-image-rpi-rpfv raspberrypi-bootloader-nokernel
            
             ...
            update-initramfs: Generating /boot/initrd.img-3.10-3-rpi
            

Replace old kernel.img with latest kernel:


            cp /vmlinuz /boot/kernel.img
            

Reboot to new kernel and firmware:


            reboot
            

Change the hostname

Edit /etc/hostname and /etc/hosts to have the hostname.


            root@pi:/etc# cat hostname
            pika
            root@pi:/etc# cat hosts
            127.0.0.1 localhost pika
            

Set up serial console

Edit /etc/inittab and add a line to enable the serial console.


            #T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
            T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
            #T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
            

After a reboot, check the serial console and hostname.


            $ sudo screen /dev/ttyUSB0 115200
            

            root@pika:~# uname -a
            Linux pika 3.10-3-rpi #1 Debian 3.10.11-1+rpi4 (2014-01-24) armv6l GNU/Linux
            

ssh is working. This is the IP address assigned to eth0


            ssh root@192.168.88.223
            

Archive the image so far

Check the size of file systems. Looks like the whole 8GB SDHC is used.


            root@pika:~# df -k
            Filesystem     1K-blocks   Used Available Use% Mounted on
            rootfs           7399324 302888   6697524   5% /
            /dev/root        7399324 302888   6697524   5% /
            devtmpfs          224292      0    224292   0% /dev
            tmpfs              44876    116     44760   1% /run
            tmpfs               5120      0      5120   0% /run/lock
            tmpfs              89740      0     89740   0% /run/shm
            /dev/mmcblk0p1     48742  22956     25786  48% /boot
            tmpfs              89740      0     89740   0% /tmp
            

            $ sudo dd bs=1M if=/dev/sdc of=pika_20140305_0958.img
            $ 7za a -t7z pika_20140305_0958.img.7z pika_20140305_0958.img
            

set up the wifi Edimax EW-7811UN

I had problems, but got help here.

Post on raspberrypi.org forum - Where to get help on wifi?

So I added 2 packages.


            apt-get install wpasupplicant
            apt-get install wireless-tools
            

Here is the trail Verify the Edimax EW-7811Un is seen.


            root@pika:~# lsusb
             ...
            Bus 001 Device 004: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]
             ...
            

Note that the wpa-psk entry is not the passphrase. With the ssid and passphrase this site can give the psk.

Wireshark - WPA PSK (Raw Key) Generator

Here is the interfaces file.


            root@pika:~# cat /etc/network/interfaces
            auto lo
            iface lo inet loopback
            
            auto eth0
            iface eth0 inet dhcp
            
            auto wlan0
            allow-hotplug wlan0
            iface wlan0 inet dhcp
              wpa-ssid Pirates
              wpa-psk alonghexstringpsk
            

See if iwlist from wireless-tools finds the router.


            root@pika:~# iwlist wlan0 scan
            
            wlan0     Scan completed :
                      Cell 01 - Address: D4:CA:6D:56:86:59
                                ESSID:"Pirates"
                                Protocol:IEEE 802.11bgn
                                Mode:Master
                                Frequency:2.412 GHz (Channel 1)
                                Encryption key:on
                                Bit Rates:300 Mb/s
                                Extra:wpa_ie=dd1a0050f20101000050f20402000050f2040050f20201000050f202
                                IE: WPA Version 1
                                    Group Cipher : CCMP
                                    Pairwise Ciphers (2) : CCMP TKIP
                                    Authentication Suites (1) : PSK
                                Extra:rsn_ie=30160100000fac040200000fac04000fac020100000fac02
                                IE: IEEE 802.11i/WPA2 Version 1
                                    Group Cipher : CCMP
                                    Pairwise Ciphers (2) : CCMP TKIP
                                    Authentication Suites (1) : PSK
                                Quality=100/100  Signal level=100/100  
            

For the wifi interface


            $ ssh craig@192.168.88.218
            

For the wired interface


            $ ssh root@192.168.88.223
            

add a user


            pika# adduser craig
            

Generate a key pair for the new user


            $ ssh-keygen
            

Install python, vim, tmux, git


            pika# apt-get install python
             ...
            The following NEW packages will be installed:
              file libmagic1 libsqlite3-0 mime-support python python-minimal python2.7 python2.7-minimal
             ...
            
            pika# apt-get install vim tmux git
             ...
            The following NEW packages will be installed:
              git git-man libclass-isa-perl libcurl3-gnutls liberror-perl libevent-2.0-5 libgpm2 libldap-2.4-2 libpopt0 librtmp0 libsasl2-2 libsasl2-modules libssh2-1 libswitch-perl patch perl perl-modules rsync tmux vim vim-runtime
             ...
            

Personalize git


            $ git config --global user.name "Your Name Here"
            Sets the default name for git to use when you commit
            
            $ git config --global user.email "your_email@example.com"
            Sets the default email for git to use when you commit
            

Set up the vim dotfiles and vundle.


            $ git clone git@github.com:CootCraig/dotfiles_again.git
            
            $ cd dotfiles_again/linux
            $ bash ./install.sh 
            
            cd ~/dotfiles_again/windows/vimfiles/bundle
            git clone https://github.com/gmarik/vundle.git
            

There are some notes on using vundle in the file ~/.vim/bundle/Readme.txt The Raspbian vim does not have python support, so disable UltiSnips vim script. Comment out the following line in ~/.vimrc


            Bundle 'vim-scripts/UltiSnips'
              to
            "Bundle 'vim-scripts/UltiSnips'
            

And then run BundleInstall.


            in vim. :BundleInstall
            

password less ssh

These instructions worked fine.

How to set up ssh so you aren’t asked for a password

Add the contents of the public key file into ~/.ssh/authorized_keys on the remote site (the file should be mode 600).

make user a sudoer


            pika# apt-get install sudo
            pika# adduser craig sudo
            

Install Compiler tools


            pika# apt-get install build-essential checkinstall libtool automake uuid-dev
             ...
            The following NEW packages will be installed:
              autoconf automake autotools-dev binutils build-essential bzip2 checkinstall cpp cpp-4.6 dpkg-dev fakeroot g++ g++-4.6 gcc gcc-4.6 gcc-4.6-base libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libc-dev-bin
              libc6-dev libdpkg-perl libfile-fcntllock-perl libgmp10 libgomp1 libltdl-dev libltdl7 libmpc2 libmpfr4 libstdc++6-4.6-dev libtimedate-perl libtool linux-libc-dev m4 make manpages manpages-dev uuid-dev xz-utils
             ...
            

Zeromq build and install

Source for stable release 3.2.4

This is supported by ffi-rzmq, the JRuby library I plan to use. I unpacked for build at:


            pika# cd /opt/zeromq/zeromq-3.2.4
            

The installation will be to /usr/local/


            pika# ./configure --help
            Installation directories:
              --prefix=PREFIX         install architecture-independent files in PREFIX
                                      [/usr/local]
              --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                                      [PREFIX]
            

            pika# ./configure
            pika# make
            pika# checkinstall
            

A debian package was left here:


            /opt/zeromq/zeromq-3.2.4/zeromq_3.2.4-1_armhf.deb
            

install socat


            pika# apt-get install socat
            

Install supervisor with python-pip


            pika# apt-get install python-pip
             ...
            The following NEW packages will be installed:
              python-pip python-pkg-resources python-setuptools python2.6 python2.6-minimal
             ...
            
            pika# pip install supervisor
             ...
              Downloading supervisor-3.0.tar.gz (459Kb): 459Kb downloaded
             ...
                Installing echo_supervisord_conf script to /usr/local/bin
                Installing pidproxy script to /usr/local/bin
                Installing supervisorctl script to /usr/local/bin
                Installing supervisord script to /usr/local/bin
             ...
            

install python-pip mentioned apt-utils not installed, so let’s install it.


            pika# apt-get install apt-utils
             ...
            The following NEW packages will be installed:
              apt-utils libapt-inst1.5
             ...
            

supervisor setup - run socat at boot


            for copy and paste
            

Install Oracle jdk 8

extracted jdk-8-fcs-b129-linux-arm-vfp-hflt-06_feb_2014.tar.gz to /opt/java/jdk1.8.0

Made a symbolic link for /opt/java/jdk


            $ ls -l /opt/java/jdk
            lrwxrwxrwx 1 root root 9 Mar  5 22:06 /opt/java/jdk -> jdk1.8.0/
            

Add jdk to the path

  • /etc/profile
  • /etc/sudoers
  • /etc/environment
  • /etc/login.defs

Modify /etc/login.defs


            ENV_SUPATH      PATH=/opt/java/jdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
            ENV_PATH        PATH=/opt/java/jdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
            

Modify /etc/profile


            if [ "`id -u`" -eq 0 ]; then
              PATH="/opt/java/jdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            else
              PATH="/opt/java/jdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
            fi
            

modify /etc/sudoers


            Defaults        secure_path="/opt/java/jdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            

/etc/environment was empty

Verify that java runs and the version.


            $ java -version
            java version "1.8.0"
            Java(TM) SE Runtime Environment (build 1.8.0-b129)
            Java HotSpot(TM) Client VM (build 25.0-b69, mixed mode)
            

install jruby

Unpack the latest jruby tarball to /opt/jruby/jruby-1.7.11

Make a symbolic to this version of jruby.


            $ ls -l /opt/jruby/jruby
            lrwxrwxrwx 1 root root 13 Mar  5 23:06 /opt/jruby/jruby -> jruby-1.7.11/
            

modify the path to add /opt/jruby/jruby/bin

Modify /etc/login.defs


            ENV_SUPATH      PATH=/opt/java/jdk/bin:/opt/jruby/jruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
            ENV_PATH        PATH=/opt/java/jdk/bin:/opt/jruby/jruby/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
            

Modify /etc/profile


            if [ "`id -u`" -eq 0 ]; then
              PATH="/opt/java/jdk/bin:/opt/jruby/jruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            else
              PATH="/opt/java/jdk/bin:/opt/jruby/jruby/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
            fi
            

modify /etc/sudoers


            Defaults        secure_path="/opt/java/jdk/bin:/opt/jruby/jruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            

Define JAVA_HOME in the environment

Add to /etc/environment


            JAVA_HOME=/opt/java/jdk
            

Verify that jruby runs.


            $ jruby -v
            jruby 1.7.11 (1.9.3p392) 2014-02-24 86339bb on Java HotSpot(TM) Client VM 1.8.0-b129 +indy [linux-arm]
            

Change permissions in jruby folder to allow user craig to add gems


            pika# adduser craig staff
            
            pika# cd /opt/jruby/jruby/lib/ruby/gems
            pika# sudo bash -c "find shared -type d |xargs chmod 775"
            pika# sudo bash -c "find shared |xargs chmod g+w"
            
            pika# cd /opt/jruby/jruby-1.7.11
            pika# sudo bash -c "find bin |xargs chmod g+w"
            

gem install bundler


            $ gem install bundler
            Fetching: bundler-1.5.3.gem (100%)
            /opt/jruby/jruby-1.7.11/lib/ruby/shared/rubygems/installer.rb:507 warning: executable? does not in this environment and will return a dummy value
            Successfully installed bundler-1.5.3
            1 gem installed
            

todo

done

  • serial console
  • wifi setup
  • password less ssh
  • make user a sudoer
  • checkinstall and compile tools
  • zeromq compile and install
  • supervisor
  • socat
  • Oracle JVM
  • JRuby

todo

  • fixed IP address
  • JRuby/Reel test