Setting up MultiTech LoRaWAN gateway on Ubuntu

As the convener for the Adelaide community of The Things Network, I am frequently setting up Multitech Conduit Gateways. Depending on your PC or notebook hardware you might have some problems with the Exar USB-UART driver on Linux.

Here are the steps to getting this unit setup from an Ubuntu (should work for any other Linux distro) machine.

lsusb

Should show something like this:

Bus 002 Device 006: ID 04e2:1410 Exar Corp. XR21V1410 USB-UART IC

Download the driver for the Exar site: https://www.exar.com/design-tools/software-drivers

unzip xr_usb_serial_common_lnx-3.6-and-newer-pak.zip
cd xr_usb_serial_common_lnx-3.6-and-newer-pak
make
sudo insmod ./xr_usb_serial_common.ko

Ensure driver is loaded at startup

sudo vim /etc/modules
#Add the following
xr_usb_serial_common

ls /dev/tty*

should now show another USB port ttyXRUSB0

For the rest you just need to follow the excellent instructions by Jac Kersing who maintains the Multitech TTN installer and documentation here:
https://www.thethingsnetwork.org/docs/gateways/multitech/mlinux.html

Get EUI of your gateway

mts-io-sysfs show lora/eui 2> /dev/null | sed 's/://g'

Moving to KVM virtual machines

Installing VirtualBox is getting increasingly painful on Ubuntu due to the problems with UEFI Secure Boot and the VirtualBox kernel modules. Another reason for an alternative is that running VirtualBox VM’s completely in the background is not as straightforward as it could be.

From the available alternatives I looked into (VMWare, Xen & KVM) it was KVM that fitted my needs (casual VM usage with mostly headless VM’s for testing purposes). Main reasons:

  • Well supported by Ubuntu
  • Easy, straightforward install
  • Background VM’s are simple as
  • Moving VM’s from one host to another is a breeze

Checking system

To check if the CPU can actually support

egrep -c '(svm|vmx)' /proc/cpuinfo

If the number returned is > 0 your systems should be capable to run.

You will also enable your BIOS for virtualisation (in Security settings of most BIOS’s) if that has not already be done. You will get an error if not enabled if you are trying to run an install. The Install of KVM will work fine.

Installation

sudo apt-get install qemu-kvm libvirt-bin bridge-utils virt-manager
sudo addgroup libvirtd
sudo adduser libvirtd
sudo service libvirtd start
sudo service libvirtd status
sudo virt-manager

Moving VM’s to another host

Source Host

virsh shutdown VMNAME
virsh dumpxml VMNAME > /tmp/VMNAME.xml
scp /tmp/VMNAME.xml TARGETHOST:/tmp/VMNAME.xml
scp /var/lib/libvirt/images/VMNAME.qcow2 TARGETHOST:/var/lib/libvirt/images/VMNAME.qcow2

Target Host

virsh define /tmp/vm.xml
virsh start vm

Once you have confirmed operation you probably want to remove the source VM from the Source Host.

virsh undefine VMNAME
rm /var/lib/libvirt/images/VMNAME.qcow2

Microchip LoRaWAN Development Utility on Ubuntu

Having just wasted a few hours on getting this Java software running on Linux I am documenting this for future reference and hopefully saving other LoRa / TTN folks some time.

Prerequisites

Install a Java JDK + JavaFX. This should work with the default OpenJDK 8 or 9 which comes as part of the Ubuntu repositories. I ended up installing Oracle JDK 8 as well as I thought the error might be related to OpenJDK.

sudo apt install openjdk-8-jre-headless openjfx

Download & install utility

Download location:
LoRa® Technology Evaluation Kit

cd ~/Downloads/
chmod +x LoRaSuite-linux-1.0.run
./LoRaSuite-linux-1.0.run

Fix User Preferences

This step is required for the Utility to run. Unfortunately, this is documented NOWHERE…

Change the following files to include the FilePath entry. The map is empty by default.

  • /home/USERID/.java/.userPrefs/dfu/prefs.xml
  • /home/USERID/.java/.userPrefs/fed/prefs.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE map SYSTEM "http://java.sun.com/dtd/preferences.dtd">
<map MAP_XML_VERSION="1.0">
  <entry key="FilePath" value="/home/USERID/"/>
</map>

If you chose the default install location you can now start the utility

java -jar ~/Microchip/LoRaSuite/Applications/LoRaDevUtility/LoRaDevUtility.jar

A big thank you goes to The Things Network user JBI – who provided this answer in a TTN forum post.

No thanks to Microchip as their forum and firmware release policy is a bit of a shocker. There are several reports of such problems in the forum with no answers. Unfortunately, this seems to be no exception with electronics manufacturers (Hello Kerlink!).

Display your Flickr Favourites as Screensaver Slideshow

Install XScreenSaver and remove Gnome default

sudo apt remove gnome-screensaver
sudo apt install xscreensaver xscreensaver-gl xscreensaver-gl-extra

Run the Screensaver UI and configure

In the “Advanced” section enter your Flickr RSS URL in “Choose Random Image”

XScreenSaver Ui
XScreenSaver Ui

https://api.flickr.com/services/feeds/photos_faves.gne?id=YOURFLICKRUSERID #replace with your Flickr User ID

Create a systemd user service to autostart

mkdir -p ~/.config/systemd/user/
vim ~/.config/systemd/user/xscreensaver.service

Past the following
[Unit]
Description=XScreenSaver
[Service]
ExecStart=/usr/bin/xscreensaver -nosplash
[Install]
WantedBy=default.target

Start and enable systemd user service

systemctl --user enable xscreensaver
systemctl --user start xscreensaver

To copy the settings (including RSS URL) onto other PC’s or re-install it might be a good idea to backup or copy the contents of ~/.xscreensaver

Install Hugo on Ubuntu to generate static websites

Whilst there is a .DEB installer to download from the GoHugo sites I get all matter of warnings that the package is of bad quality and I am not comfortable to run these kinds of installers.

Hugo Logo

I rather install from sources in this case which is very straight forward since the main dependencies (largely GO) are in the Ubuntu main repositories.

Install dependencies

sudo apt-get install golang git mercurial python-pygments

Create environment variables

vim ~/.bashrc
#add the following 3 lines
export GOROOT=/usr/lib/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

Update Bash Environment Variables without logging out.

source ~/.bashrc

Install Hugo

go get -u -v github.com/spf13/hugo

Start using Hugo

#create new site
hugo new sitename /path/to/sitename
#change directory to site
cd /path/to/sitename
#create content page
hugo new about.md
#edit content page
vim content/about.md

Good bye Android ? Hello Ubuntu ! Not yet unfortunately …

As a long-term Ubuntu user I am extremely interested in what Canonical and the Ubuntu community are doing on the mobile front. Their convergence strategy (I am testing Snappy Core on IoT devices as well) seems very well thought through and once the the Meizu MX4 phone was released I got myself an invite and ordered a unit. It took a while to ship and then also had to make it’s way down under as Meizu only ship to Europe (and Asia I believe).

Meizu MX4 Ubuntu

Having played with Ubuntu on the phone a while ago on an old Nexus 4 as well as a Nexus 7 unit it was a much more pleasant initial experience and I was really hoping to make this my day-to-day phone. After the initial excitement and a few days of use (including with my main SIM card) however it is clear that we’re not at this stage yet. I am quite prepared to forego some conveniences I got used to on CyanogenMod (Android) over the years, but at this stage there are just too many things not working consistently. On the surface most of the critical components are there, but there is just too many bugs and inconsistencies in heavy usage left to make this a solid experience unfortunately. The single button hardware also doesn’t seem to work with the UI as in a lot of places you are searching for a back button and there ain’t one. And to my surprise the browser feels pretty horrible and lacks a lot of functionality. If the browser would work solidly a lot of the missing apps would be bearable. But this coupled with lack of stability prevent me from taking the plunge I was hoping to make and ‘de-google’ a little more….

It might work if you use your phone for voice calls and occasionally browsing. But as a very heavy user relying on the phone for work the overall stability is some way off.

The Great

  • A phone where you don’t have to jump through unreasonable hoops to get under the hood
  • Refreshingly different & pleasant UI
  • Very developer friendly
  • Terminal – it just works …
  • All Linux CLI programs (armhf) at your fingertips

The Good

  • All pre-installed crap-ware such as Ebay & Amazon apps easy to remove (would be nice not to have them – but they need to make some money)
  • Phone functions are solid and good voice quality
  • Camera on the MX4 is pretty decent
  • Familiar to Ubuntu users
  • Great selection of Reddit clients & German IPTV apps ;-)

The Bad

  • The inbuilt browser is very under-cooked – missing basic functionality plus not very intuitive rendering
  • Sharing between apps not working well – plus lack of apps that support intents – something extremely useful that Android really shines at
  • Calendaring
  • UI still seems sluggish for the computing power available on MX4

The Ugly

  • Stability – lots of apps (web-apps) refuse to display randomly
  • Home screen lock-ups with no other options than reboot
  • Many of the apps that are available are of very questionable quality – mostly websites with wrapper

I will keep a very close eye on what’s happening with the next releases (OTA6 release is due in 5 weeks) and in the meantime will help out with testing & debugging. I have been really pleasantly surprised by the responsiveness of the developers (for example the missing WIFI Hotspot functionality – it will be available next release and the devs sent me an invite to the pre-release after asking a question on Reddit). I don’t want this to be seen as dismissal of Ubuntu on phones. Just some realism as I feel selling this phone as a ‘finished’ product by Meizu is a mistake that could damage the overall aim. I still hope to settle there eventually. The community is working very hard and it’s just a question of time…

Views ‘under the hood’ of Ubuntu Phone

Here are some initial notes on how to get “under the hood” access to the Ubuntu phone.

Enable Developer mode

System Settings –> About this phone –> Developer Mode

Ubuntu Phone - Developer Mode

Install tools on the desktop / notbook device

sudo apt-get install phablet-tools

Connect via SSH

vim .android/adb_usb.ini
#add the following line to allow adb access to device
0x2a45

sudo vim /etc/udev/rules.d/51-android.rules
#Meizu MX4
SUBSYSTEM=="usb", ATTR{idVendor}=="2a45", ATTR{idProduct}=="0c02", MODE="0664" OWNER=""

phablet-shell

Important note: the phone needs to be unlocked for this (and other phablet-tools commands) to work. If the phone is locked you will get a series of adb error messages.

Change Ubuntu Touch Channel

adb shell
sudo system-image-cli --switch ubuntu-touch/rc-proposed/meizu.en

More info on channels here: https://developer.ubuntu.com/en/start/ubuntu-for-devices/image-channels/

Make filesystem writable

DISCLAIMER: Proceed with caution ! You can do some serious damage if you don’t know what you are doing. But on the other hand you have the whole power of apt-get install available to install armhf packages that might be useful.

phablet-config writable-image

Disable writable mode

sudo rm /userdata/.writable_image

Screenshots

Taking screenshots is something I commonly like to do for documentation purposes.

Via commandline

phablet-screenshot

Via phone

Hold volume up and volume down until you hear the picture sound and see the screenshot flash.

In both cases your screenshot will be saved in /home/phablet/Pictures/Screenshots and you can view them using the gallery app or download via USB.

Ringtones

Currently there is no way to change you ringtones in the UI and I fully agree that the focus should be on much more important functions. But I got used to my ringtone and don’t respond to others anymore.

sudo cp /home/phablet/Downloads/ringtones/GoodBadUgly.ogg /usr/share/sounds/ubuntu/ringtones/

Note: the sudo password for the “phablet” user is the same as you set for your screen-lock.

Finding Notebook Hardware for Ubuntu – 2015 Edition

Unfortunately it is still much harder than necessary to find notebook hardware to use with Ubuntu (or other Linux variants). This blog is full of past experiences (some of them quite time-consuming) on finding notebook hardware that will work without too much fiddling. This short note is to document my recent research on that front to help others who want to do the same (as there doesn’t seem to be a lot of good current info around).

There are some vendors that do ship with Ubuntu, however they are generally all based in the US and their pre-sales communications are pretty horrible (I am talking to you ZaReason – still waiting for reply email as well as tweet). Then there is Purism Librem, but unfortunately they have still not shipped their 15″ version and I need a tool now. The jury on this is still out and I don’t really have the time to be a guinea-pig. Maybe next time (as I like what they are doing) …

There was one option from one of the top-tier manufacturers (Dell XPS 13 – Developer Edition) which ships with Ubuntu. But as – per usual – NOT in Australia. However there was a lot of conflicting evidence I found that the Windows Version had some issues with current Ubuntu versions (Dell ship 14.04 LTS – which makes sense from their point).

I ended up buying the Lenovo X1 (3rd Generation) and after the install of Ubuntu I have to say this is the first notebook I just had to plug in the Ubuntu USB (Version 15.04 Vivid Vervet 64bit) and install and everything just worked. No fighting with UEFI firmware, no function keys not working and no issues with sound or other drivers. To be fair – there is one thing I noted (which is irrelevant to me) – the fingerprint reader does need some additional driver installed & configured.

It was also the first notebook I didn’t even bother booting up and create a repair disk first. There is no way I would ever restore something to Windows 8 – however if you are not sure that you will stick with Ubuntu – that’s probably not advisable.

Thank you Lenovo for developing a very decent piece of hardware that just works with Ubuntu ! However I would like to note that the recent Superfish debacle http://support.lenovo.com/us/en/product_security/superfish really left a sour taste and nearly made me take Lenovo off the evaluation list.

Some conversations that might be useful:

https://www.reddit.com/r/Ubuntu/comments/37ukqe/dell_xps_13_vs_lenovo_thinkpad_x1_carbon_3rd_gen/
https://www.reddit.com/r/Ubuntu/comments/37t4re/ubuntu_notebook_hardware_available_in_from/

SShuttle – quick and temporary VPN over SSH

Every once in a while you find a gem. One of these for me is SShuttle – until now I have not known about this one.

Sometimes you need to quickly forward all your traffic via a remote server quickly. And while you can do all of this manually using OpenSSH it’s not a quick one-step process (https://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding). Dynamic SOCKS5 proxies are great if all you need is browser traffic, but there is always software that won’t play ball with SOCKS.

Use-case: I just been trying to get Ubuntu Make to install Eclipse IDE and the local AARNET download mirror is just refusing to cooperate (https://github.com/ubuntu/ubuntu-make/issues/90). A quick forward to a remote VPS fixed the issue without headaches

Install

sudo apt-get install sshuttle

Run

sshuttle -r username@servername.tld 0.0.0.0/0 -vv

That’s all – it sets up routing & iptable rules transparently and removes them after use. Kudos goes to https://github.com/apenwarr – thank you. A VERY useful utility !!!

Source link: https://github.com/apenwarr/sshuttle

Installing Ubuntu Phone (Touch) on Nexus 7 LTE

ubuntu phone

Add SDK repository

sudo add-apt-repository ppa:ubuntu-sdk-team/ppa
sudo apt-get update
sudo apt-get install ubuntu-device-flash

Enable USB Debugging on the device

  1. Make sure you have developer mode enabled (see http://developer.android.com/tools/device.html if you are unsure).
  2. Navigate to Settings > Developer options
  3. Enable USB Debugging. When a device is connected, you will be prompted in Android to authorize it.

Unlock Bootloader

adb reboot bootloader
fastboot oem unlock
fastboot reboot

Check that you have the right device

adb shell grep ro.product.name /system/build.prop > mydevicedata \
&& adb shell grep ro.product.device /system/build.prop >> mydevicedata \
&& adb shell grep build.id /system/build.prop >> mydevicedata

ro.product.name=razorg
ro.product.device=deb
ro.build.id=KTU84P

Check which channels are available

ubuntu-device-flash --server="http://system-image.tasemnice.eu" query --list-channels --device=deb

ubuntu-device-flash –server=”http://system-image.tasemnice.eu” query –list-channels –device=deb
ubuntu-touch/ubuntu-rtm/14.09
ubuntu-touch/ubuntu-rtm/14.09-proposed
ubuntu-touch/utopic
ubuntu-touch/utopic-proposed
ubuntu-touch/vivid
ubuntu-touch/vivid-proposed
ubuntu-touch/devel (alias to ubuntu-touch/vivid)
ubuntu-touch/devel-proposed (alias to ubuntu-touch/vivid-proposed)
ubuntu-touch/ubuntu-rtm/devel (alias to ubuntu-touch/ubuntu-rtm/14.09)
ubuntu-touch/ubuntu-rtm/devel-proposed (alias to ubuntu-touch/ubuntu-rtm/14.09-proposed)

In my case I am going for the currently stable ‘ubuntu-touch/vivid’ channel.

Install Ubuntu Touch

ubuntu-device-flash --server="http://system-image.tasemnice.eu" touch --channel="ubuntu-touch/vivid" --bootstrap

References
Ubuntu Devices: https://wiki.ubuntu.com/Touch/Devices

Install Ubuntu 14.04 on a Chromebook

There are plenty of sites out there that give advise on this topic, unfortunately most of them are highly ad-infested to the point of being unreadable as well as only containing single bit rather that an overall picture. This is a collection of useful links to source materials as well as steps necessary to install.

Resource Links

Crouton Github: https://github.com/dnschneid/crouton – Thank you David Schneider for the excellent work !!!
Developer Info for Chromebooks: https://www.chromium.org/chromium-os/developer-information-for-chrome-os-devices

Put Cromebook into “developer mode”

  1. Back up any data as the process wipes the system
  2. Create a restore image for Chrome OS (install the Restore Image Chrome Extension for this task)
  3. Enter Developer Mode – hold down ESC and Refresh (F3) keys and press the Power button

Download Crouton Script

Download link for installer: https://raw.githubusercontent.com/dnschneid/crouton/master/installer/crouton

Installing Crouton

CTRL+Alt+t to open Cronos Prompt + type “shell” to enter proper bash shell.

To see the list of supported releases:
sh -e ~/Downloads/crouton -r list
To see a list of the supported desktop envoironments (target names):
sh -e ~/Downloads/crouton -t help
I generally install LXDE on ‘resource-challenged’ devices.

shell
sudo sh -e ~/Downloads/crouton -r RELEASENAME -t TARGETNAME -e

The ‘-e’ at the end is optional to encrypt the chroot. Which is probably a good idea as the Chromebook in developer mode is completely open and allows any user to access. If you do not specify the Release it defaults to Ubuntu 12.04 (precise)

My default install would be:
sudo sh -e ~/Downloads/crouton -r trusty -t lxde -e

Removing Crouton

The proper way to remove the chroot environment created by Crouton is as follows

sudo delete-chroot CHROOTNAME

CHROOTNAME could be ‘precise’ or ‘trusty’ depending on the installed version and can be found by

ls /mnt/stateful_partition/crouton/chroots/

Run Ubuntu

Depending on your installed shell.
sudo startlxde

Replace with ‘startxfce4’ or ‘startkde’ or ‘startunity’ depending on your target release.