Headless Raspberry Pi configuration

Settings up a Raspberry Pi it’s easy when you have an HDMI display, a USB keyboard and mouse in oder to access the terminal or you favourite Desktop, but can be quite a challenge when you don’t have any of these or at least no keyboard.

Everything in this blog post should be done from you host computer, with you microSD card connected and mounted, assuming the microSD is mounted at /Volumes/boot.

cd /Volumes/boot
Raspberry Pi 4 with Hyperpixel 4.0 display

Enable SSH over LAN / WiFi

The SSH server is not enable by default as a user it’s expected that you access your Raspberry using a KVM. Not a Linux Kernel but a Keyboard, (VGA) Display and Mouse. This can be easily done by creating an empty file named ssh.

touch ssh

Preconfigured a WiFi network

If you are going to connect to Raspberry to your network using an Ethernet cable, you can skip this part. But if a WiFi network (even your mobile phone as a hotspot) it’s you only option, you can set your default WiFi network config in a file called wpa_supplicant.conf

sudo vi wpa_supplicant.conf
network={
    ssid="<< your WiFi's SSID >>"
    psk="<< your WiFi's password >>"
}

Take into consideration that this configuration uses your password in plain-text! If you want to encrypt your password in this configuration file do the following:

wpa_passphrase "<< your WiFi's SSID >>" "<< your WiFi's password >>"

On a Linux distribution wpa_passphrase is installed, but on macOS or Windows not. the following Ruby script will use OpenSSL in order to create the content of the configuration file.

vi /tmp/raspi_wifi.rb
require 'openssl'
ssid = '<< your WiFi SSID >>'
psk  = 'ID >>" "<< your WiFi password >>'
puts 'country=AR'
puts 'ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev'
puts 'update_config=1'
puts ''
puts 'network={'
puts '  ssid="' + ssid + '"'
puts '  psk=' + OpenSSL::PKCS5.pbkdf2_hmac_sha1(psk, ssid, 4096, 32).unpack("H*").first
puts '  key_mgmt=WPA-PSK'
puts '}'

Then run the script and copy the output to /Volumes/boot/etc/wpa_supplicant/wpa_supplicant.conf

ruby /tmp/raspi_wifi.rb > /Volumes/boot/wpa_supplicant.conf

Accessing your Pi using SSH

Now when your Raspberry completes its boot process, you will be able to access your device using SSH even without knowing its IP address.

Raspberry exposes a host in your local domain, so the following command with let you know it IP address.

ping raspberrypi.local

The default Raspberry user and password are pi and raspberry, so the following command will establish a SSH connection

ssh pi@raspberry.local 
Leap Motion

Using Leap Motion in an Objective-C project

I have started learning about Leap Motion and decided to make a simple app in Objective C in order to test it. The first thing I realise it is that there is no template for Objective C, nor a guide of how to integrate the lib and setup the project. So here I will show how to set up an OS X project, and also I will provide a template.

  1. Once you create your project, drag and drop Leap.h LeapMath.h LeapObjectiveC.h LeapObjectiveC.mm into your project and check “Copy items into destination group’s folder (if needed)”. Also check that files are added to your main target and “Create groups for any added folders” is selected.
  2. Copy libLeap.dylib into your project folder.
  3. Select your project and add libLeap.dylib as a required framework.
  4. Now let’s create a new Build Phase in order to copy libLeap.dylib into the executable. Go to your main target, click on “Build Phases” and add a “Copy Files Build Phase”. The destination must be set to “Executables”.
  5. Last, but not least, go to “Build Settings”, look for “C++ Standard Library” and make sure “libstdc++ (GNU C++ standard library)” is selected.

The class EALeapMotionController implements the interface LeapDelegate where all the events are handled.
Download template project

ADB over Ethernet in BeagleBoard

Setting up device

First of all we need to ensure that we have an Ethernet connection up and running. Connect your PC to the Beagleboard using a USB to Serial converter. USB side on your host and Serial on the RS232 debug port of the Beagleboard.
Then connect using minicom (or any other term program) at 115200bps 8N1. This will let you access a simple linux shell. At the prompt type:
root@android:/ # netcfg
You should see something like

lo   UP      127.0.0.1/0
sit0 DOWN
usb0 UP      192.168.1.118/24

if not, try running netcfg eth0 dhcp or netcfg usb0 dhcp in order to obtain a connection.
Once the connection is established, we will change the ADB TCPIP port and then restart ADB Daemon (adbd)

root@android:/ # setprop service.adb.tcp.port 5555
root@android:/ # stop adbd
root@android:/ # start adbd

Setting up host

Back on your host machine, start ADB in TCPIP mode and then connect to your device like this

$ sudo ./adb tcpio 5555
$ sudo ./adb connect 192.168.1.118

Once you are connected you can check that everything is working running an adb command like:

$ sudo ./adb devices
List of devices attached
192.168.1.118:5555 device

or

$ sudo ./adb logcat