Garmin Forerunner 405 - A Linux Solution

I was interested in purchasing a Garmin Forerunner 405 but I was a little hesitant because of the lack of Linux support.  A quick search of the internet showed that some people have had success downloading files off the watch, so I took the plunge.  I am glad I did.  The watch is a great training tool whether it is for running, biking, or hiking.

The next step was figuring out how to download the files off the watch and put them on the Garmin Connect website.  I was able to find the resources I needed by searching the web, but the simplicity of the final solution was critical if I expected by wife to upload her runs.  By leveraging the groundwork laid by others, I was able to download activities off the watch and upload to Garmin Connect with the push of a button.

This page is to document what I did and provide others with the bits to implement a similar solution.

A quick web search brought me across gant*, an opensource driver for the Garmin Forerunner 405. While gant was responsible for the communication with the watch, The Floating Frog blog was what helped me get everything set up initially.  This allowed me to download the workouts, but the process was a little cumbersome because of frequent segmentation faults.

*at the time of this writing, the gant website was down.  No worries, I have all the necessary code in the files section.

Additional searching led me to a fork of the gant code made by a Garmin Forum user.  After downloading and compiling this code, the stability improved dramatically.  This worked out well for downloading the workouts, but I still had to do a manual upload to the Garmin Connect site.  I went searching for a way to automate this step and came across a pretty close solution here.  A few tweaks to the upload code, a script, and a desktop icon later I had a way to simple way to automatically download new activities from the watch and upload them to the Garmin Connect website.

NOTE:  I have tested out these steps on Ubuntu 11.10 32-bit and 64-bit.  Some of the steps may need to be adapted if your are using a different distribution.  If you just want to try things out, this works just fine with a Live CD.

Step 0:  Try the watch out as intended
My first step was to understand how the process is supposed to work. I used my Windows XP virtual machine to install the Garmin software and download a workout from the watch. I setup an account with Garmin Connect and installed the plugin for Firefox. The whole process went smoothly.

This wasn't really needed, so I listed it as Step 0.  You may not have access to a Windows machine and/or you don't plan to use the Garmin Connect website to manage your workout data.

Step 1:  Make sure Linux can "see" your ANT module
If everything is working properly, there should be an entry is dmesg when the ANT module is plugged into your computer.  This will show up as a ttyUSB device like so:

$ dmesg | grep "ttyUSB"

  [1417702.818194] usb 5-1: generic converter now attached to ttyUSB0

In this case, the device is listed at ttyUSB0.  If grep doesn't find a match, then there is something wrong!  This was the case for me when using Ubuntu 11.10.  For whatever reason, the proper module is not being added to the kernel when the ANT module is plugged in.  To fix this problem, follow instructions below.  Otherwise, skip ahead to Step 2.

 Detour:  The device wasn't found! 

You can get a list of all the USB buses and the devices connected to them by using the lsusb command.  

$ lsusb

  Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
  Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
  Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
  Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
  Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
  Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
  Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
  Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
  Bus 001 Device 002: ID 04f9:0023 Brother Industries, Ltd HL-5170DN series
  Bus 002 Device 002: ID 0bda:0151 Realtek Semiconductor Corp. Mass Storage Device (Multicard Reader)
  Bus 008 Device 002: ID 045e:0014 Microsoft Corp. Digital Sound System 80
  Bus 002 Device 068: ID 0424:a700 Standard Microsystems Corp.
  Bus 005 Device 018: ID 0fcf:1008 Dynastream Innovations, Inc.

The ANT module for the 405 shows up under "Dynastream Innovations."  For this module, the vendor ID is 0fcf and the product ID is 1008.  To add this module to the kernel, use the modprobe command:

sudo modprobe usbserial vendor=0x0fcf product=0x1008

At this point, you should be able to "see" the device in dmesg.  To make it so that this module loads at boot, edit /etc/modules and add the device:

sudo gedit /etc/modules

add this line to the flle and save:

usbserial vendor=0x0fcf product=0x1008

Step 2:  Download and compile gant
Next, you'll want to download and compile the gant driver so you can talk to the watch.  I have provided instructions for the package I have provided.  If you choose to download the driver from the gant project or the Garmin Forum, the compilation steps will be similar (the package I have provided contains the code from WWBELL's forum post).

Download and extract
Go to the files section and download gant-jmf.tar.gz to your desired location.  Open a terminal, navigate to the directory where you downloaded the package, and issue the following commands:

tar -xjf gant-jmf.tar.bz2
cd gant-jmf

When using the other packages, the make command gave me an error which seemed to indicate it was having trouble linking some of the included libraries.  Since I didn't see this issue raised by other users in my searches, I figured it might be something with my setup.  Rather than use the Makefile, I just complied the individual files myself.  To do the same, just enter these commands:

cc -g -Werror -c -o antlib.o antlib.c
cc -g -Werror -c -o gant.o gant.c
cc gant.o antlib.o -o gant -pthread -lm

Step 3:  Pair to the watch
First, you want to make sure the 405 is willing to talk.  On the watch, follow the menu structure below and make sure the computer interface is enabled.  If this is set to No, the watch will not transfer data to/from any computer, even a paired computer.

Menu > Settings > ANT+ > Computer > Enabled > Yes

Next, make sure the watch is willing to Pair with a new computer by turning Pairing on:

Menu > Settings > ANT+ > Computer > Pairing > On

Now that you have made sure the 405 is willing to talk, it's time to initiate the pairing:

./gant -f garmin -a auth405

If everything is working properly, your watch should ask if you'd like to pair with "garmin."  You do.  Accept the pairing.  Note that you can use a different name instead of "garmin" if you'd like.

NOTE:  For both pairing and downloading data, you need to make sure gant knows where the device is located.  In step 1, I showed my watch was connected to ttyUSB0 which is where gant looks for the device by default.  If your ANT module is located at a different location, you need to pass this along to gant.  Let's assume your ANT module is listed as ttyUSB1, you'd pair with the device using:

./gant -d 1 -f garmin -a auth405

After you have gone through these initial setup steps, you should not need to go through them again.  Any time you want to download new activities off the watch, you can start at the next step.

Step 4:  Download Activities
Once everything is set up, you can download activities by running gant again:

./gant -Dnza auth405 > output

You will see status messages while it is trying to connect to the watch.  It may take the watch a little while to respond.  Gant has a habit of throwing segmentation faults and exiting.  If it does, run the program again.  Sometime it will take 4 or 5 attempts before it can successfully complete a download.

I got around this annoyance by calling the gant program from a script which would automatically retry if there was a segmentation fault.  The script also checks to see if the ANT module is installed and at which address.  To download activities with this script, simply run:


Whether you call gant directly or use the script, any activities which were downloaded should show up in the same directory as gant.  Each activity will have it's own .TCX file.  

NOTE:  By default, the watch will only transfer new activities to the computer.  If you're doing testing or would like to transfer all your activities to the computer, you can tell the watch to send over all the stored activities:

Menu > Settings > ANT+ > Computer > Force Send > Yes

At this point, you can take the activity files and import it into whatever you are using to track your workouts.  If you are using Garmin Connect, you can upload these files using their website or you can read on for a way to automate that task.

Step 5:  Prep for Upload
An stated before, the .TCX files will be downloaded to the same directory as gant.  The upload script will be looking for these files in the ./pending directory.  The following script simply moves the files to the correct location (and announces what it's doing):


Step 6:  Upload Activities
Now that the files are in the correct location, we are ready to upload to Garmin Connect.  To do so, simply enter the line below (substituting your Garmin Connect username and password):

USER=garminConnectUsername PASSWORD=garminConnectPassword ./

 This script uses curl to login and upload the data.  If you need to install curl, enter the following command:

sudo apt-get install curl

I ended up automating steps 4 through 6 with a script.  This allows me to go from watch to website with one command.

Save your Garmin Connect Credentials
Before you call the script, you'll want to enter your Garmin Connect username and password.  If you try to run the script without doing this step, it will kick you out and ask you to enter the missing values.  To enter your info, edit the script:


find the following lines, enter your credentials, and save the file.

#Enter your Garmin Connect credentials here

Everything should now be set up.  To automate the whole process, simply call:


I made a shortcut on my desktop (and the icon in the ./resources directory) to make it dead simple.  After a run, I just drop the watch on my desk and hit a button.  A minute later, the activities are on the Garmin Connect website!

I haven't had too many problems with this setup.  I have noticed that the transfer seems to initiate faster if the watch is not sleeping.  I usually hit the start/stop hard button to bring the watch into a more talkative state.  It's sleeping if the watch is only displaying the time.  If it is showing the time and date, you should be good to go.

I ran into an issue one time where the script was waiting and waiting to make contact with the watch.  After several minutes of waiting to make contact (it usually takes 5-20 seconds) I quit and tracked down the problem.  Somehow Pairing was turned off (see Step 3).  Turning it on fixed my problem.

If you are calling the script with a Launcher,  I'd recommend changing the type to Application in Terminal so you can have feedback as to what's going on.

These are the steps that worked for me.  Hopefully they work for you.

Subpages (1): files