Friday, April 1, 2016

Flashing Recovery to the Reach RTK from Emlid

When I received my anxiously awaited Reach RTK GPS units, I immediately had a problem with one of them - it initially didn't boot properly to a green light which initially means "I have made a Wifi hotspot" or later in the procedure "I have joined your Wifi network"...

In the quickstart section of their documentation I saw how to reflash with the latest firmware and as there wasn't anything I could loose at this point I decided to give it a try.

I downloaded the latest Reach image from their site and followed the directions. I have Windows 10, and had no problems flashing the image initially - you run the flashall.bat file they provide and it all happens automagically; you unplug and replug the Reach unit and the flashing starts.

However I did not end up with a usable Reach. I forget the exact sequence of events but eventually I ended up with the flashing process suggesting that I run "flashall --recovery" and then when I did so suggesting that I install xFSTK tools. Which on further investigation are only available on Linux.

I next tried my daughter's Linux desktop - she is getting into programming etc - and looked into compiling and installing xFSTK tools. Not easy for someone who doesn't use Linux. I read through Ubuntu's "easy" guide for compiling a program and followed it with some success, also following other guides online re installing xFSTK in particular - installing what seemed an interminable number of packages needed to support this software and still failing: as near as I can tell because I was running Linux 15.10 and the xFSTK was expecting 14.04.

I then found a guide for installing Ubuntu to a thumb drive for the purpose of reflashing an Intel Edison which I followed not without some headache and here regurgitate for you because I found so many things referenced that I had to find out myself I thought it would be helpful to list them in one place.

  • Find a USB thumb drive, at least 8GB, faster is better unless you are patient.
  • Download Ubuntu 14.04.4 32-bit ISO. - Although they recommend 64-bit ignore them, it needs to be 32-bit!
  • Download and install Universal USB Installer
  • Using the universal-usb-installer, create a live-boot USB key. Check the format drive option, and make sure you give it plenty of persistent storage in step 4 of the dialog, as you'll need that to extract your flash images. Recommend 4GB.
  • Download and unzip it and copy it to the thumb drive.
  • Unzip (if you haven't already) the Reach 1.2 image and copy that to the thumb drive. I'll be referring to it as being in the directory "reach_image"
  • Now boot a computer using the USB stick. You'll be pressing a key when the computer display first comes on that will give you boot options, then choosing the thumb drive. Check out this page for various hotkeys... When booting, select the "Try Ubuntu" option. The persistent storage we selected when creating the bootable USB key will allow us to make changes that persist across boots, so we don't have to re-do everything every time we boot.

Once you boot up Linux you need to open a Terminal window. I found that pressing the Windows key shortcut brings up a search bar, type "terminal" and you find the shortcut.

You will also need to be connected to the internet - so connect to wifi or whatever is necessary to do this. Test in pre-installed firefox browser...

Now you need to mount the thumb drive as a disk so you can see it. You'll need to know what the drive is called to mount it. To do that, type the following (followed by enter) into terminal. It really helps to use copy and paste so you may want to open this page in a browser...:

sudo fdisk -l

You're looking for a partition that should look something like: /dev/sdb1. Remember what it's called.
Create a new directory in /media so you can mount the drive onto the filesystem:

sudo  mkdir /media/usb

Mount disk:

sudo mount /dev/sdb1 /media/usb 
note that your disk might not be /dev/sdb1 - replace as needed!

Now change directory to the thumb drive:

cd /media/usb

Now you can install the xFSTK tools -

dpkg -i xfstk-downloader-_0.0.0_all.deb

(If you get errors at this point just move on to these next steps anyway.)
The apt-sources need to be tweaked to give us access to the dfu-util package, it's not present in the live-boot image, so:

sudo nano /etc/apt/sources.list

Now you are in the Nano text editor where you can navigate using the arrow keys. Add the line:

deb trusty universe

...and then exit using ctrl-x, pressing Y to save changes on your way out.

Now update packages:

sudo apt-get update

followed by

sudo apt-get install dfu-util

At this point try to flash recovery:

cd reach_image

Now run the flashall script (leave Reach unplugged, plug in after the script starts to tell you it can't find the device...):

./ --recovery

Note: it is important to have the "./" in front of, it is also important to note that there are 2x dashes in front of "recovery"...

You should see feedback indicating that the flashing was successful.

If, however you see that you still need to install xFSTK tools, something must have gone wrong in the steps above! If the "dpkg" line didn't work but the subsequent installation of packages did, it might be worth trying to "dpkg" again and hopefully end up with a successful installation.


Now for an interesting footnote: I was able to flash recovery no problem by this method BUT when, after recovery, I used
to write the Reach image 1.2 although it appeared to write correctly I was still left with a Reach that did not boot correctly - still booted to solid red light!!!!!

I found that to write the image successfully I had to:
1) flash recovery from Linux
2) use flashall.bat to flash the reach image from Windows 10
Then I finally had a working Reach unit!

If I had any previous experience working with the Intel Edison I could tell you which bits of this complicated mess are just par for the course for this particular micro computer - and which bits are due to the Reach software running on it. But I don't...

I'm still having another problem with my Reach units that is as yet unresolved, but I live in hope:)

Good Luck!