Howto easily update GPS-A data on a Sony Alpha 65/77/99 and others on Linux/Mac

In order to speed up GPS locking on a Sony Alpha 65 (or similar) SLT camera, it's possible to update the GPS-A data (also called almanac data). Like on any other modern GPS device, the almanac data is used to give the device a hint where the satellites are located. The data usually is valid for only some weeks,then it needs to updated again.

The common way to get the almanac data on a Sony Alpha is to use Sony's Software, so no go for Linux users. But there are other ways to do it.

Manual download

The almanac data file can be downloaded directly from Sony here: http://control.d-imaging.sony.co.jp/GPS/assistme.dat. Simply put it into /PRIVATE/SONY/GPS/ on the SD-card (just create the subfolder GPS if it doesn't exist yet).

Then check Menu -> Settings 1 -> GPS-Settings -> GPS-assist data. The data should be valid for 6 weeks from the day you downloaded it. But this also means you need to update the file manually every 6 weeks.

Automatic approach when mounting the SD card

To automate the process, the file could be updated automatically each time the SD card is mounted on the PC.

Mac OS X

For Mac there is a tool called GPSAssist Update. When you insert the card in the card reader, it checks if an update is required and downloads fresh data when necessary.

Linux

A similar solution is possible on Linux using udev and a small BASH script.

I created a github repo here: https://github.com/gimpel/sony-gpsassist-update

ArchLinux Users can use this: https://aur.archlinux.org/packages/sony-gpsassist-update-git/

Anyways, here it is step by step:

1. Create the file /etc/udev/rules.d/99-sony-gps-update.rules

SUBSYSTEM=="block", ACTION=="add", ENV{DEVTYPE}=="partition", ENV{UDISKS_PARTITION_NUMBER}=="1", RUN="/usr/bin/sony-gpsassist-update"

This will call the following script whenever there is an "add" event of a disk partition with number 1. A usual SD-card only has one partition, so this should do it.

2. Create the script /usr/bin/sony-gpsassist-update

Note: the latest version can be found on github.

#!/bin/bash

PROG_NAME="`basename $0`"
TMP_MOUNT_DIR="/tmp/${PROG_NAME}_$$"
LOGGER_CMD="logger -t $PROG_NAME"
PROBE_OUT_FILE="${PROG_NAME}_$$_env.txt"

if [[ -r "/etc/`basename $0`.cfg" ]]; then
  . /etc/`basename $0`.cfg
else
  ${LOGGER_CMD} "ERROR: no config file found"
  exit 1
fi

if [[ -z "$SONY_FS_UUIDS" ]]; then
  ${LOGGER_CMD} "WARN: no SONY_FS_UUIDS configured, running in probe mode. Plug your SD card and check ID_FS_UUID from /tmp/$PROBE_OUT_FILE"
  env > /tmp/$PROBE_OUT_FILE
  exit 0
fi

ERR=0

function run_update {
  if [[ "$SONY_FS_UUIDS" =~ "$ID_FS_UUID" ]]; then
    ${LOGGER_CMD} "Device with known FS UUID added. Mounting ..." 
    mkdir $TMP_MOUNT_DIR
    mount $DEVNAME $TMP_MOUNT_DIR
    if [[ $? -ne 0 ]]; then
      ${LOGGER_CMD} "Mount failed. Exiting."
      return 5
    fi

    if [[ -d "${TMP_MOUNT_DIR}/PRIVATE" ]]; then
      ${LOGGER_CMD} $PROG_NAME "Sony-formatted partition found. Good. Updating GPS-A data now"
      test -d ${TMP_MOUNT_DIR}/PRIVATE/SONY/GPS || mkdir -p ${TMP_MOUNT_DIR}/PRIVATE/SONY/GPS
      cd ${TMP_MOUNT_DIR}/PRIVATE/SONY/GPS
      wget http://control.d-imaging.sony.co.jp/GPS/assistme.dat -O assistme.dat.tmp
      if [[ $? -ne 0 ]]; then
        ${LOGGER_CMD} "Failed to download assistme.dat. Exiting."
        return 10
      else
        mv assistme.dat assistme.dat.old
        mv assistme.dat.tmp assistme.dat
      fi
      ${LOGGER_CMD} $PROG_NAME "Update successful."
      cd ${TMP_MOUNT_DIR}/..
    else
      ${LOGGER_CMD} $PROG_NAME "No Sony formatted card. Ignoring."
    fi
  else
      exit 0
  fi
}

run_update
ERR=$?
if [[ $ERR -ne 5 ]]; then
  umount $TMP_MOUNT_DIR
  if [[ $? -ne 0 ]]; then
    ${LOGGER_CMD} "WARNING: failed to unmount $TMP_MOUNT_DIR"
    ERR=15
  else
    rmdir $TMP_MOUNT_DIR
  fi
fi

exit $ERR

3. Make the script executable

chmod +x /usr/bin/sony-gpsassist-update

4. Plug your card, and see /var/log/messages.log (or journalctl or whatever)

2013-10-15T21:13:52+02:00 sirius sony-gpsassist-update: WARN: no SONY_FS_UUIDS configured, running in probe mode. Plug your SD card and check ID_FS_UUID from /tmp/sony-gpsassist-update_17918_env.txt

So check the file /tmp/sony-gpsassist-update_17918_env.txt

ID_FS_UUID="6238-3031"

5. Edit /etc/sony-gpsassist-update.cfg

SONY_FS_UUIDS="6238-3031"

6. Re-Plug your SD card and check /var/log/messages or journalctl.

2013-10-01T20:16:21+02:00 sirius sony-gpsassist-update[25316]: Device with known FS UUID added. Mounting ...
2013-10-01T20:16:21+02:00 sirius udisks-daemon[8085]: **** /proc/self/mountinfo changed
2013-10-01T20:16:21+02:00 sirius sony-gpsassist-update[25319]: Sony-formatted partition found. Good. Updating GPS-A data now
2013-10-01T20:16:24+02:00 sirius sony-gpsassist-update[25324]: Update successful.

Works. Nice!

Some notes: 

  • Sometimes the /PRIVATE folder is actually called /Private. Not so on my Alpha 65, on all cards it got created as /PRIVATE. 
  • On a freshly Sony-initialized card there was no /PRIVATE/SONY folder here, which is why I test on /PRIVATE only and use mkdir -p for SONY/GPS if it doesn't exist.

 

Comments

Hi, I am trying this on elementary OS, but cannot find any UUID for my SD card.. it is being mounted as mmcblk0.. any idea, what I am doing wrong?