Using E-TREX with Linux


A few years ago I bought a Garmin eTrex Legend HCx. This article records my experiences with the device including terminology, procedures and Linux compatibility.


  • GPS coordinate: representation of a geographical location in numeric format, specified as degrees north of the equator and east of the Greenwich meridian (e.g. N40.829656,E-73.926198)
  • GPS receiver or just GPS: the equipment (e.g. Garmin eTrex Legend HCx) for receiving GPS data (e.g. the device’s current GPS coordinates, its current altitude)
  • point of interest or POI: a geographical location which is of general interest (e.g. the Kempinski Hotel Munich, the police station on the Boulevard du Palais on the Ile de la Cite, the Natural History Museum in London, the Volpetti Rosa pizzeria in Rome)
  • waypoint: a geographical location which is on a route; this is normally a POI or a more personal point of interest (e.g. corner of School Street and Province Street in Boston, your friend’s house, the peak of Mount Everest, N52.524183,E13.412437)
  • map: data about a region; it includes locations of roads, altitude information, POIs
  • basemap: a basic map that comes preloaded on the receiver; it is not deletable; the lack of detail on the map means it is pretty useless unless you’re making a long intercity journey (see here)
  • Americas, Atlantic or Pacific Recreational: Garmin’s base maps
  • OpenStreetMap or OSM: a free worldwide map, “created by people like you”
  • route: a manually or automatically calculated set of instructions for getting from somewhere to somewhere created before a journey
  • manually calculated route: a route where the set of instructions is defined by a person. Typically, this involves creating a sequence of waypoints (perhaps at road junctions) or downloading from the internet a track that somebody else has traveled and using software to convert it to a route
  • automatically calculated route: a route where the set of instructions is defined by a computer (e.g. MapSource, Google Maps, your GPS). Typically this involves requesting the computer to calculate a route from the start waypoint to the end waypoint (e.g. from Paris, possibly via Zurich to Prague or from home, possibly via the dentist’s surgery, to work)
  • track: location data created during a journey (e.g. now, at 4pm the device is at N52.52344,E13.411399 and now, at 4pm and 10 seconds it is at N52.523788,E13.4119 and now at 4pm and 20 seconds it is at N52.524183,E13.412437, etc).
  • navigation mode: the method by which the route between the waypoint on a route are calculated; note that even in a manually calculated route navigation mode is still relevant
  • off-road navigation mode: straight lines are drawn between the waypoints on a route on the map; it is assumed this is enough for your purpose (e.g. you might specify enough waypoints so as not to need more than straight lines
  • follow-road navigation mode: the GPS will calculate the route between waypoints using roads; if no roads are available then it will tell you to turn back so that it might approach the next waypoint from another direction
  • GPS navigation software: software for browsing maps, preparing routes, transferring maps, routes, waypoints to and from the GPS
  • MapSource: Garmin’s GPS navigation software
  • Trip & Waypoint Manager: MapSource and one of Garmin’s base maps bundled together on CD and distributed with the GPS
  • Navit, QLandkarte GT, …: open source GPS navigation software

Procedure: Firmware upgrade

  1. Insert the SD card
  2. Put the device into “USB storage” mode (System->Interface->USB storage)
  3. Attach the device to a Linux box and check of the GPS is seen as a new drive of the correct size.
  4. If it is then the firmware does not need to be upgraded.
  5. Attach the device to a real Windows system (not Wine)
  6. Perform a firmware upgrade.

Procedure: Granting access to the hardware

  1. Attach the device and run:
    lsusb | grep -i garmin

    and note the vendor and product IDs (these are the four digit numbers on either side of the colon, respectively). In what follows, we’ll assume those IDs are ’091e’ and ’0003′, respectively.

  2. Edit /etc/modprobe.d/blacklist.conf and if the following line is not already present then add it:
    blacklist garmin_gps
  3. Edit /etc/udev/rules.d/51-garmin.rules to contain the following:
    SYSFS{idVendor}=="091e", SYSFS{idProduct}=="0003", GROUP:="plugdev", MODE:="660"
  4. If you are not already in the ‘plugdev’ group, then edit /etc/group and add youself to it.
  5. Reboot (or log out and in again to have your login processes added to the supplementary groups and run:
    udevadm control --reload-rules

    but honestly, it’s easier just to reboot.)

Procedure: Installing MapSource

  1. Insert “Trip & Waypoint Manager” CD-ROM or mount its ISO image.
  2. Attach the GPS and put it in USB storage mode; wait until Linux has automatically mounted the device and you can browse it in a file browser.
  3. Run:

    and set:

    1. the Windows version to ‘Windows XP’
    2. the drive type to ‘floppy’ (failure to do this will result in the Wine seeing the drive, but MapSource software not seeing it when run on newer versions of Wine!) as illustrated here:
  4. Run:
    cd <mountpoint-of-cd-or-iso-image>
    wine Setup
  5. At the “Trip & Waypoint Manager” window, click “Install Trip & Waypoint Manager”. If the following error message appears:
    err:msi:copy_package_to_temp failed to copy package L"TWPT_ENU.msi"
    fixme:msi:MSI_OpenDatabaseW open failed r = 80030002 for L"TWPT_ENU.msi"


    wine: cannot find L"D:\\Setup.exe"

    then just exit and rerun:

    wine Setup
  6. At the “Trip and Waypoint Manager v4 Setup” window, when prompted “Welcome …”, click “Next”.
  7. At the “Trip and Waypoint Manager v4 License Agreement” window, when prompted “SOFTWARE LICENSE AGREEMENT”, tick the “I accept the Software License Agreenent” checkbox, and click “Next”.
  8. At the “Trip and Waypoint Manager v4 Setup” window, when prompted “Installing to the default location …”, set the installation directory to C:\Garmin (under Debian squeeze I found that drive C: could not be seen despite it having been correctly set up by winecfg earlier and I had to set the installation directory to it explicitly … twice!) (Failure to set it to C:\Garmin will cause a lot of registry-based problems later) and click “Install”.
  9. At the “Trip and Waypoint Manager v4 Setup” window, when prompted “Garmin Trip and Waypoint Manager v4 is successfully installed …”, click “Finish”.
  10. At the “Trip & Waypoint Manager” window, when prompted “… Get Adobe Reader …”, move cursor back into the terminal window from where you launched wine and press CTRL-C.
  11. Under Debian squeeze, I found that the MapSource software was installed in ~/Garmin (which Wine called H:\Garmin) and the Trip and Waypoint Manager software (i.e. the basemap) was installed in ~/.wine/drive_c/Garmin (which Wine called C:\Garmin), despite the fact that I specified everything to be installed in C:\Garmin. To correct this I ran:
    mv ~/Garmin/* ~/.wine/drive_c/Garmin
    rmdir ~/Garmin

    (MapSource.exe seemed to be able to find all its other components without problems after this move.)

  12. If you want to set up your window manager’s or panel’s menus to run MapSource then the command to run is:
    sh -c 'wine ~/.wine/drive_c/Garmin/MapSource'

    and here is a little icon to use: mapsource-logo

Procedure: Installing maps in MapSource from OpenStreetMap

Installing maps from MapSource is documented at OpenStreetMap, which I have attempted to collate and expand below.

In outline, the procedure is:

  1. download and install prerequisite software (needed for splitting and compiling OSM data)
  2. download OSM data either:
    1. small amounts from
    2. larger amounts from
  3. assign variables used later in the procedure
  4. split large OSM data files (to make them more manageable)
  5. convert small OSM data files to Garmin’s IMG format
  6. register IMG files in MapSource
  7. use MapSource to select map regions and download to your GPS

For more detail, see the corresponding sub-sections below.

1. Download and install prerequisite software

In order to keep binary installations clean, I choose to install each software package into a separate directory and create one-line scripts to ease access to them. If you want to do something different then adjust this section accordingly.

  1. If not already installed, install a Java Runtime Environment; how you do this depends on what Linux distribution you use and whose Java you choose to install. Depending on these factors you might run one of the following commands:
    #  Install Sun's Java on a Debian lenny system
    apt-get install sun-java6-jre
    #  Install OpenJDK's Java on a Debian squeeze system                             
    apt-get install openjdk-6-jre-lib                           
    yum install ...
    zypper install ...
  2. If not already installed, install unzip.
  3. Set some variables required for this procedure:
    MY_BIN_DIR=<dir-where-you-save-single-commands>             #  E.g. MY_BIN_DIR=$HOME/bin
    MY_OPT_DIR=<dir-where-you-save-whole-packages>              #  E.g. MY_OPT_DIR=$HOME/opt
    MY_ARC_DIR=<dir-where-you-save-downloaed-sources>           #  E.g. MY_ARC_DIR="$HOME/My Downloads"

    (It is assumed that $MY_BIN_DIR is already in your $PATH.)

  4. Set some variables defining versions to be installed (the procedure probably works for newer versions, but was tested with these versions):
  5. Download the software as follows:
    mkdir -p $MY_ARC_DIR
    cd $MY_ARC_DIR
  6. Unpack the binary distributions as follows:
    mkdir -p $MY_OPT_DIR/splitter-$SPLITTER_VER/distrib
    cd $MY_OPT_DIR/splitter-$SPLITTER_VER/distrib
    unzip $MY_ARC_DIR/splitter-$
    mkdir -p $MY_OPT_DIR/mkgmap-$MKGMAP_VER/distrib
    cd $MY_OPT_DIR/mkgmap-$MKGMAP_VER/distrib
    unzip $MY_ARC_DIR/mkgmap-$
  7. Make them accessible by creating one-line wrapper scripts as follows:
    mkdir -p $MY_BIN_DIR
    echo -e "#"'!'"/bin/bash\n\nJAVA_OPTS=\"\"\nexec java \$JAVA_OPTS \
        -jar $MY_OPT_DIR/splitter-$SPLITTER_VER/distrib/splitter-$SPLITTER_VER/splitter.jar \
         \"\$@\"" \
         > $MY_BIN_DIR/splitter
    echo -e "#"'!'"/bin/bash\n\nJAVA_OPTS=\"\"\nexec java \$JAVA_OPTS \
        -jar $MY_OPT_DIR/mkgmap-$MKGMAP_VER/distrib/mkgmap-$MKGMAP_VER/mkgmap.jar \
        \"\$@\"" \
        > $MY_BIN_DIR/mkgmap
    chmod 755 $MY_BIN_DIR/splitter $MY_BIN_DIR/mkgmap

    (Note to self: I set MY_BIN_DIR to be the package-specific value $MY_OPT_DIR/<package>-<version>/bin and then add both <package-version>s to ~/.matrix/$HOSTNAME and then run matrix.)

2. Download OSM data

OpenStreetMap state:

To download large quantities of OpenStreetMap data, see Planet.osm. If you then want to create your own webmap from this, see Deploying your own Slippy Map for some pointers. Remember data may only be exported from OpenStreetMap (in any format) in accordance with the OpenStreetMap License.

Therefore consider whether you want a small or a large quantity of OSM data. (Personally, I would say a single town or small city is a small amount of data; anything more is a large amount of data.)

OpenStreetMap state:

To get address search working mkgmap needs precompiled bounds tiles to evaluate the city, zip code, region and country of each POI, line and polygon. You can create the precompiled bounds tiles yourself or you can download them from In this case extract them and put the extracted files to a subdirectory named bounds.

But beware: with bounds available, mkgmap will require a lot more memory.

  1. To download a small amount of data, visit OpenStreeMap, click the “Export” link at the top of the page and set the format to export to “OpenStreetMap XML Data”, scroll and zoom around the map until you have the area you wish to download data for, click the “Export” button; when prompted then save a .osm file to your computer.
  2. To download larger amounts of data visit Planet.osm and follow the links to a suitable source (I have found to be particularly clear). It is preferrable to download .osm.pbf files because the next step can process those faster than plain .osm files.
  3. If you downloaded a gzipped or bzipped .osm file then uncompress it. (If you downloaded a .osm.pbf file then there is no need to uncompress it because the splitter understands this format.)
  4. If you want to have a street index on the GPS, then download and unpacked the bounds files by running:
    mkdir bounds
    cd bounds

    (You might want to do this into a different directory and then either make a ‘bounds’ symlink to it or use mkgmap’s --bounds option.)

3. Assign variables

Map families installed in MapSource must have different map family ID numbers, otherwise the installation of one will hide the installation of the other (files are not overwritten, but windows registry entries are). The same applies to individual map product ID numbers. (I don’t know if a map family ID number can clash with a map product ID umber so it is safest to assign new numbers that are unique across both map families and map products.)

Other variables are set here in order to make the procedures below more copy-and-paste-able.

  1. Run:

    and browse the registry.

  2. Note the map family ID numbers of all already installed map families; they can be found at Software\Garmin\Mapsource\Families\<map-family-id>.
  3. Note the map product ID numbers of all already installed map products; they are in the ‘ID’ node at oftware\Garmin\Mapsource\Products\<map-product-description>.
  4. Decide upon a new map family ID; e.g. 123
  5. Assign the following variables as below:
    FAMILY_ID=<map-family-id>                     #  E.g. FAMILY_ID=123
    SOURCE_FILE=<path-to-your-download>           #  E.g. SOURCE_FILE=europe.osm.pbf
    COUNTRY_NAME=<country-name>                   #  E.g. COUNTRY_NAME="Europe"
    COUNTRY_ABBR=<iso3166-country-abbreviation>   #  E.g. COUNTRY_ABBR=EUR  #  see the country's wikipedia entry for help
    OVERVIEW_MAME=<country-name>                  #  E.g. OVERVIEW_NAME=europe  #  lower case, max 8 chars
    INSTALL_DIR=<install-dir>                     #  E.g. INSTALL_DIR=Garmin/OSM-europe-2012-07    #  relative to ~/.wine/drive_c
  6. The next variables to set can be derived from the previous ones; run the following:
    REG_SERIES_NAME=$(echo "$SERIES_NAME" | sed -e 's/[^A-Za-z0-9_ ]//g')
    FAMILY_ID_LSB=$(printf "%02x\n" $(($FAMILY_ID % 256)))
    FAMILY_ID_MSB=$(printf "%02x\n" $(($FAMILY_ID / 256)))
  7. Finally set the name for the first map tile filename. This can be chosen randomly and formatted by running:
4. Split large OSM data files

Large downloads will need splitting into smaller files. Attempting to split files which are already small does no harm. So in the interests of a unified procedure, it is suggested you run the commands in this section for any sized download.

  1. Run:
    splitter --mapid=$MAPNAME $SOURCE_FILE

    This can take several hours and can run out of memory.

  2. If it runs out of memory then:
    1. Look at messages it displayed before crashing relating to memory usage, e.g.
      Elapsed time: 2m 0s   Memory: Current 551MB (1012MB used, 1MB free) Max 1013MB

      (Note those values are in MB.) Look for the last such message and note the “Max” value.

    2. Determine how much memory your machine has e.g. by running:
      head -1 /proc/meminfo

      (Note that value is in KB.)

    3. Decide a sensible higher maximum amount of memory to grant to java, e.g. for the example output above on a 8GB machine then maybe 2400MB. If in doubt, then allocate as much as you can.
    4. Edit the wrapper script and set JAVA_OPTS accordingly. e.g.:

      (See the java(1) man page for a full explanation of the -Xmx option.)

  3. Verify that at the end of this step, regardless of whether your download was compressed or not, regardless of whether your download was a .osm file or a .osm.pbf file, that running splitter has created areas.list, template.args and several .osm.pbf files.
  4. Remove areas.list and template.args; they will not be needed again.
5. Convert small OSM data files to Garmin’s IMG format
  1. Convert the just-generated .osm.pbf files to the format Garmin devices and software understands by running:
    mkgmap --code-page=1252 --latin1 \
        --route --remove-short-arcs --road-name-pois --add-pois-to-areas \
        --index --location-autofill=bounds --tdbfile \
        --gmapsupp \
        --max-jobs=8 \
        --mapname=$MAPNAME --country-abbr=$COUNTRY_ABBR --country-name="$COUNTRY_NAME" \
        --family-id=$FAMILY_ID --family-name="$FAMILY_NAME" \
         --overview-mapname=$OVERVIEW_NAME \
        --series-name="$SERIES_NAME" --description="$DESCRIPTION" \
6. Register IMG files in MapSource
  1. Backup the registry!
  2. Generate a registry file by running:
    cat > $OVERVIEW_NAME.reg <<EOF
  3. Move the generated files to the right place by running:
    mkdir -p ~/.wine/drive_c/$INSTALL_DIR
    mv *.img $OVERVIEW_NAME.mdx  $OVERVIEW_NAME.tdb $OVERVIEW_NAME.reg \
  4. Add the registry entries so that MapSource knows of the map’s existence by running:
    regedit ~/.wine/drive_c/$INSTALL_DIR/$OVERVIEW_NAME.reg
  5. Test by running MapSource and verifying:
    1. there are no registry errors
    2. you can zoom to a very low level without error
7. Use MapSource to select map regions and download to your GPS

This procedure is described in the official documentation, e.g. here. See the section entitled “Procedure: Pushing maps to the GPS” for a short description.

Procedure: Installing maps in MapSource from packaged by Lambertus

Installing a map makes inaccessible any previously installed map that has the same product ID. All Lambertus’s maps share the same product ID. Therefore only one of Lambertus’s maps can be installed in MapSource at a time.

  1. Ensure MapSource is not running.
  2. Visit and follow the instructions there.
  3. Continue only once you have the following files:
    • osm_routable_mapsource.exe
  4. Run:
    wine osm_routable_mapsource.exe
  5. Start MapSource and verify that the new map appears in the pull-down menu of maps.

Procedure: Installing maps in MapSource from other sources

  1. Different maps need to be installed in different ways.
  2. Regedit may be needed to load .reg files.
  3. If regedit refuses to load a .reg file by running:
    regedit <filename>

    then it may be necessary to change the first line of .reg files from:

    ��Windows Registry Editor Version 5.00



    or to convert from Unicode to ASCII by cat-ing the file and then using the mouse to copy it and paste it into a new file or by running:

    iconv -f UNICODE -t ANSI_X3.4 <old-reg-file> -o <new-reg-file>
  4. Unlock the maps from within MapSource.

Procedure: Pushing maps to the GPS

This procedure covers selecting which maps should go on the GPS, merging those maps into one file, transferring them to the GPS. It does not cover transferring waypoints, routes and tracks.

  1. Power on the GPS, connect it to the computer, and put the GPS in “USB storage” mode.
  2. Make sure the device is now mounted and browsable with your file browser.
  3. Run MapSource.
  4. Select the map tool (either from the ‘Tools’ menu or from the toolbar).
  5. Switch to a product (either from the ‘View’ menu or from the toolbar).
  6. Use the mouse to select from the grid of maps those maps you wish to download to the GPS.
  7. Repeat the last two steps for other products (e.g. to select south-east England and London).
  8. From MapSource’s ‘Transfer’ menu, select ‘Send to device …’; the device should be listed (e.g. as D:\); click ‘Send’; if it is not listed then run:

    and make sure that the drive type is set to ‘floppy’.

  9. Wait. (The merging of maps and the subsequent download are quite slow; the fewer map segments you select the faster it will be.)

Procedure: Pushing waypoints and routes to the GPS

  1. Power on the GPS, connect it to to the computer, make sure it is not in “USB storage” mode (and therefore not mounted).
  2. Run:
    gpsbabel -r \
        -i gpx -f <gpx-file-containing-routes>.gpx \
        -o garmin -F usb:
    gpsbabel -w \
        -i gpx -f <gpx-file-containing-waypoints>.gpx \
        -o garmin -F usb:
  3. If this does not work then repeat as root.

Procedure: Pulling tracks from the GPS

  1. On the GPS, save any tracks (ideally, do this on the same day you made the track, then it will be named after that date).
  2. Put the GPS in USB mass storage mode, mount the device and copy over the GPX files (don’t use gpsbabel to retrieve the tracks as, for some reason, the track will only contain 500 track points) and then unmount the device.
  3. Load each file into MapSource and delete any 1- or 2-point tracks (such as are created if the GPS starts recording tracks before it has acquired satellites).
  4. If any of the tracks have odd points in them (such as are created if the GPS starts recording tracks before it has acquired satellites) then right-click on the track, select ‘Properties’ and try to work out which point needs deleting, and then edit the GPX file and reload it).
  5. Run the command:
    eval gpsbabel \
        -i gpx $(for X in $GLOB; do echo -f $X; done) \
        -x track,merge \
        -o gpx -F mergedfile.gpx
  6. Some sites restrict the size of GPX uploads so it may be necessary to run something like this:
    gpsbabel \
        -i gpx -f mergedfile.gpx \
        -x simplify,count=2000 \
        -o gpx -F simplifiedfile.gpx
  7. If you merge tracks or perform other operations using gpsbabel and try to load the resulting files into MapSource then you may encounter:gpsbabel-data-in-mapsource-errorthen run:
    perl -0777 -pi -e 's@(?<=<trkseg>\n)<extensions>.*?</extensions>\n@@ms' \
        file-1.gpx file-2.gpx ...

    which will delete any <extensions> sections which are inside any <trkseg> sections. There is no need to delete <extensions> sections which are inside <trk> sections but not inside deeper <trkseg> sections.

  8. Uploading that to GORP results in images like this:
    so be sure to use the track viewer, not the route viewer.

What they didn’t tell you

  • You definitely need more maps! Note that country maps don’t include cities; city maps are a bundled as a separate product! E.g. I needed to install the following products:
    1. Topo Deutschland
    2. City Navigator Europe NT 2008
  • The maps are expensive! Check out their prices on Amazon or wherever.
  • if you are only using the basic “Trip & Waypoint Manager” map and you are doing on-road routing, then a route from your house to the corner shop will go via the autobahn!
  • Any off-road routing will go “as the crow flies” – in an absolutely straight line.
  • Since on-road and off-road routing can be useful (straight lines are useful for manually calculated routes over fields and small tracks, but obviously not when you’re going from Paris to Prague), it is possible to set the default routing method to ‘prompted’, meaning that whenever you follow a track or a route or go to a waypoint, then you’ll be asked to specify if it should be on-road or off-road. I keep mine on this setting because I use both routing methods about equally.
  • If you want to navigate somewhere and you have no satellite reception you’ll get no instructions because the GPS doesn’t know where you are; if it doesn’t know where you are then it can’t possibly begin to work out how to get to your destination.
  • When looking at the map, a quick press of the joystick creates a waypoint where the cursor is, but a long press of the joystick creates a waypoint where the GPS/you is/are.
  • If you move the cursor on top of a waypoint in order to get it automatically selected and click then you’ll be brought into the waypoint menu (delete, show on map, navigate to). If you choose ‘map’ to show it on the map things look just as they did before, but now if you get the same waypoint automatically selected and click then you’ll be able to move it (correct its position I mean)
  • There are two sorts of compasses: magnetic compasses and GPS compasses; not all models have magnetic compasses. GPS compasses can only tell which way is north when you are moving. This means if you are standing still then north will probably wander around and you should not rely on it.
  • When playing games the cursor is moved by you moving with the GPS, not by moving the joystick
  • Remember to enable track logging before starting a journey. If you do so and then later you don’t want the track you can delete it. If you don’t do so and later you do want the track you’re screwed.
  • Routes in MapSource can contain as many points as you like. Routes in the GPS are limited to 250 points.
  • If you buy a mounting clip to put your GPS on your bicycle, then watch out: there is a package which includes the clip and a replacement back-panel for the GPS, but this back panel does not fit on the GPS models which have a slot for an micro SD card. If in doubt, take your GPS to the shop and and actually try it before you leave!


Overall, I am extremely happy with this device and would recommend it to any cyclist, mountain hiker or city walker.

It does everything I need (I want to plan on- and off-road routes for cycling, off-road routes for hiking, get GPX data for my tracks, and use it when I get lost in a foreign city), it works reasonably well with Linux using Wine and gpsbabel, the display is bright and easy to read, a couple of its screens can be configured to display the information you prefer (e.g. on one screen I have a large compass/heading-arrow and current time and on another display I have time to next waypoint, distance to next waypoint, time to destination, distance to destination, current time, current speed, …).

One bad point is that, if this is to be your first GPS, then the documentation is woefully inadequate!

One feature i miss, and I suspect this is something not available on any GPS, is a panel indicating the heading after the next way point; I can see what heading I should be on up until the next route point, but I cannot see what my heading should be after that. Yes, I can look at the map screen but, generally I’m looking at the configurable screens (to see speed, distance covered, current time, etc).

Andy Allan wrote a good review.

See also