TheMaxus

Installing OpenStreetMap maps on Garmin satnav devices

Maps on my satnav (Garmin nüvi 40) were really ancient (close to 10 years old) and of course Garmin charges quite a lot of money for newer maps and I didn't really want to pay, so my only option was using OSM maps. There's nothing wrong about OSM and I actually really like using the service, because it often actually has better map data than Google Maps, but every time I've tried using pre-built OSM maps in Garmin specific format (gmapsupp.img), for some reason they didn't seem to work quite well as there always were some problems or quirks. (Building maps that work on all models is actually pretty difficult so don't blame pre-built map providers for this.) This time I was determined to get them working.

First attempt (Pre-built maps once again)

I've opened up OSM Wiki and looked for places where I could get pre-built maps. Userbeam.de seemed like a good place, so I downloaded the map for my region, renamed it to gmapsupp.img, put it into the Garmin folder on the microSD card, inserted the SD card into the slot on my satnav and... just as always the navigation was a bit wonky and search didn't work properly. The only way I could search for something was if I typed one letter of the city and pressed done, then it would display a long list of cities the names of which started with this letter. (The wonky navigation part I will discuss later in the blog.) Because pre-built maps weren't working for my particular satnav I've decided to build the maps myself from the OSM data.

Second attempt (mkgmap to rescue)

Things we need:

To run mkgmap and splitter you're also going to need Java RE

The OSM wiki actually has a really decent guide on how to build the maps yourself, but in my case it was missing a few things and that's why I've decided to make this guide/blog post. (I may look into adding this information to the wiki at some point.)

Step 1: Splitting the map

This is the easiest step, unzip the splitter archive, open up the folder with splitter.jar file and run:

java -jar splitter.jar <your_map>.osm.pbf

Now we have lots files with names 6324*.osm.pbf.

Step 2: Actually compiling the maps.

After splitting the map we need to move the files to the mkgmap folder. We can do this with a single command:

mv 6324*.osm.pbf <mkgmap folder>

Next we need to move the bounds archive to the mkgmap folder, to make out lives a bit easier.

Now to the actual mkgmap part. Mkgmap has lots of different switches and you can find the whole listing from the documentation.

We can already get a mostly working map using the command form the OSM Wiki guide:

java -jar mkgmap.jar \
    --route \
    --add-pois-to-areas \
    --bounds=bounds-latest.zip \
    --index \
    --gmapsupp \
    6324*.osm.pbf

But at least on my satnav when using those command options search functionality doesn't work. After a bit of research it seems like the text encoding is the problem.

Mkgmap has two flags for encodings --latin1and --unicode and which one to use depends on your device. Mine can easily display letters like ü, ö and ä, so I'm fairly confident it supports Unicode.

Also I've found a few other switches that make your life a bit easier: --improve-overview which seems to optimize map rendering a bit and --max-jobs=<nuber of jobs> which enables multi-core processing, if no value is specified it uses all available CPU cores.

So here's our final command:

java -jar mkgmap.jar \
    --route \
    --add-pois-to-areas \
    --bounds=bounds-latest.zip \
    --index \
    --improve-overview \
    --unicode \
    --max-jobs \
    --gmapsupp \
    6324*.osm.pbf

The program can take quite a bit of time to finish, but in the end (along with lots of other .img files) we should have gmapsupp.img in the folder with the program. Now we need to move it into the Garmin folder on the microSD card, go to Map settings on the device, press Info, disable the OEM maps and enable OSM maps.

Step 3: Profit?

So after lots of trial and error with mkgmap I've got the search to work properly and now maps should work flawlessly. Right? Right? So after a bit of testing the navigation was still acting weirdly. To some nearby cities it gave me a path 2x longer than it should have and to some far away cities it couldn't calculate a path at all. At this point I started wondering if OSM data had some errors in it or my satnav just wasn't 100% compatible with maps produced by mkgmap.

As I was trying to figure out the source of the problem, I opened the navigation settings on my device and here was the source of all of my problems. In the navigation settings there is a menu, where you can tell the satnav to avoid some things like U-turns, customs, commuter lanes and among all things highways. And of course avoiding highways was enabled facepalm (Most likely by me at some point when I was playing around with settings). Finally after disabling this setting I had perfectly working OSM maps on my satnav.