Marc's Public Blog - Linux Hacking


vvv Click on the categories below to see other topic specific pages vvv



This page has a few of my blog entries about linux, but my main linux page is here
Picture of Linus

Here is a list of older linux event reports I made before my blog was started, then the rest are below
1996/11/18-21:Linux Pavillion Comdex Fall 1996 (photos only). I've been going since then to help at the linux pavillion.
1997/11/18-21: Linux Pavillion Comdex Fall 1997 (photos only)
1998/05/28-30: Linuxexpo 1998 (photos only)
1998/11/16-20: Linux Pavillion Comdex Fall 1998 (full report)
1998/11/11: Silicon Valley Tea Party (report with pictures)
1999/02/15: Windows Refund Day (report with pictures)
1999/03/20: SVLUG KTEH night (photos only)
1999/03/01-04: LinuxWorld Expo Winter 99 (complete report with many pictures)
1999/03/31: Mozilla Party one year anniversary (photos only)
1999/05/18-22: Linuxexpo 1999 (complete report with many pictures)
1999/06/07: June 99 Balug meeting with Linus
1999/08/09-12: LinuxWorld Expo Summer 99 (complete report with many pictures)
1999/11/15-19: Linux Business Show at Comdex Fall 1999 (full report with pictures)
2000/08/14-17: LinuxWorld Expo Summer 2000 (complete report with many pictures)
2001/01/17-20: Linux.conf.au/LCA 2001 (complete report with pictures)
2001/07/25-28: OLS 2001 (photos only)
2001/08/25: Linux 10th Anniversary (report with pictures)
2001/09/27-30: LinuxWorld Expo Summer 2001 report with pictures)
2001/11/05-10: ALS 2001 (photos only)
2002/06/26-29: OLS 2002 (photos only)
2003/01/20-25: LCA 2003 (photos only)
2003/07/23-26: OLS 2003 (photos only)
2004/01/12-17: LCA 2004 (photos only)
2004/07/21-24: OLS 2004 (photos only)
2005/04/18-23: LCA 2005 (photos only)
2006/01/24-28: LCA 2006 (photos only)
2007/01/17-21: LCA 2007 (photos only)

Here is a list of all the talks I've given:

And below are my blog posts:

Table of Content for linux:

More pages: July 2002 February 2004 March 2004 November 2004 April 2005 August 2005 January 2006 July 2006 August 2007 November 2007 December 2007 January 2008 October 2008 November 2008 December 2008 January 2009 May 2009 July 2009 August 2009 September 2009 November 2009 December 2009 January 2010 March 2010 April 2010 June 2010 August 2010 October 2010 January 2011 July 2011 August 2011 December 2011 January 2012 March 2012 May 2012 August 2012 December 2012 January 2013 March 2013 May 2013 September 2013 November 2013 January 2014 March 2014 April 2014 May 2014 October 2014 January 2015 March 2015 May 2015 January 2016 February 2016 March 2016 June 2016 July 2016 August 2016 October 2016 January 2017 September 2017 January 2018 March 2018 December 2018 January 2019 August 2019 January 2020 May 2020 January 2021 September 2021 March 2023 April 2023 December 2023 June 2024 September 2024 November 2024 July 2025 August 2025 October 2025 November 2025 April 2026 October 2026



π 2026-10-15 01:01 in Electronics, Hiking, Linux

Making Garmin MTP units like Montana 710 not immediately shut down when plugged into a linux machine

This is a bit of a long page, so the TLDR, is:
Create /etc/udev/rules.d/99-garmin-passthrough.rules with
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="091e", ATTR{power/control}="on", ATTR{power/autosuspend}="-1"

save and run "udevadm control --reload-rules; udevadm trigger"

this ensures linux will not autosuspend the port which in turn causes the montana not to shut down, allows virtualbox to grab the port, hand it over to windows, and have basecamp work again. Yeah!

So many Crashes and Bugs with Montana 700

I have been a Garmin GPS user for over 20 years, starting with a Vista, upgraded to Oregon 700 and stayed with that for many years until they were discontinued, and my last one died. From there the Montana was the only Garmin GPS with a touchscreen and reasonable on screen keyboard to create new waypoints on the fly when I travel, so despite its size and weight (both too big compared to a more capable cell phone), I went with that.

The Montana 700 worked just like the ancient Vista HCx, it emulated a usb storage drive when you plug it in USB and I could mount it on linux as a drive, move files around like gmapsupp_xxx.img files when I had too many and wanted to hide some to avoid overwhelming the GPS. Also, it was easy to just copy all the tracks to linux and store them forever (I have all my tracks from the last 20+ years, you never know, haha).

This is also the time garmin introduced garmin explorer that was meant to sync all the tracks and waypoints of your GPS to the garmin cloud. It's a great idea in principle, in practise it was written poorly and never fixed in the last 2 years I've seen it, so with lots of tracks and 4000+ waypoints, I got:

  • over 24H to sync the waypoints to the cloud through some inefficient one by one copy with huge latency between each. Sad...
  • the copy/compare/sync is unreliable so it eventually duplicated all my waypoints both in the cloud and on my unit. Terrible....
  • at the same time, it likely had bugs or a memory leak that caused my GPS to shut down while I was recording tracks, leaving me with lost tracks when the GPS shut down, even more sad
  • I unfortunately confirmed that anything that causes an OS or serious application error that can cause a coredump (I'm going to guess it's not a memory protected OS and dates back to windows 3.1 memory management days), the unit shuts down and stops recording instead of rebooting
  • during that time the web explorer cloud site never had a properly working export mode where I could download all my data in a simple GPX file. The file would miss track names, or waypoints, or waypoint types. It's really not so hard to write something like this but as of this writing it's still broken in different ways and apparently not a priority to fix
  • turning off garmin explore fixed many of the crashes with the Montana 700, even if it brought it back to the level of an Oregon 700, however I found another vexing bug where when recording a track for multiple days while plugged in, usually a moving diving boat, the unit would shut down on its own after a day or two and stop recording too, losing part of my track.
  • I even got the unit/software to be wedged enough that the power button would register a beep as normal, but refuse to shut down the unit, to the point that I had to remove the battery to force a shutdown.
  • During all of these issues, I got coredumps, but while I was hopeful they would allow garmin to fix their software and OS (even with bad/corrupted maps or unexpected data, the unit should never crash). Unfortunately, since it's probably not a full OS with full memory protection and the software is not written to withstand imperfect data, as far as I know, nothing I reported, ever got fixed. It's also possible that they were just memory overflows with no protection either, and this example below clearly shows code was allowed to corrupt data (here sprites):

    All that said, while nothing I reported got fixed, not even the unit rebooting after a crash instead of just shutting down, garmin support did their best to help, even if nothing may have happened in the end. As part of that, they did rule out bad hardware by replacing my 700 twice, and after I still got more problems, all the way to the unit refusing to shut down, they gave me one more swap to a garmin 710 which is new hardware and upgraded to USB-C (I was indeed surprised that the 700 upgraded from super obsolete mini-USB to pretty obsolete micro-USB, and didn't have USB-C yet).

    Stopping using 3rd party openstreetmap gmapsupp.img files and moving to Garmin Topoactive data

    Unfortunately none of the coredumps gave any clue if we were hitting hardware bugs, or software bugs, and whether they were linked to the openstreetmap maps I was using when travelling in other countries. This is where I have to thank Leslie and Elizabeth from garmin support for pointing out that topoactive maps that were added in the last years are actually free repackaging of openstreetmap data in a way that has been verified not to crash the garmin software. This is not to say that the openstreetmap maps I was used to getting from the net, were crashing the montana, but it's technically possible. Big bummer that the many coredumps I gave never got anyone to say why the unit was crashing and whether it could be linked to bad map data. That said, the new topoactive data is much simpler to get than what I was doing manually and moving to the sdcard in a bunch of gmapsupp_country.img files, so I happily switched to that. Links:
  • https://support.garmin.com/en-US/?faq=24WYX2WS2aAJvm5lYQgAM7
  • https://support.garmin.com/en-US/?faq=UXl1PP15829qvEX6jdqekA
  • Upgrading from Montana 700 (usb-storage) to Montana 710 (MTP)

    At the same time, Garmin kindly authorized upgrading me to a Montana 710 at their cost, which I assume they did without ever being able to figure out if the 700 hardware was it fault. At the same time, I vouched to fully switch to topoactive maps, which is actually one great thing garmin implemented and that I'm happy to switch to.

    However, I still need to get the data off it (tracks and waypoints) and cannot use garmin explorer as explained above due to how broken it is, so I still need to use garmin basecamp in virtualbox with my windows 7 image, the last ok-ish windows :)
    When switching to USB-C garmin also switched from USB-storage (drive emulation) to MTP, which is reasonable. Linux has supported MTP for over 10 years, and it also works in windows 7, so no problem in theory. In practise, everytime I plugged the GPS in and activated storage mode (when using garmin spanner mode so it asks me before doing so), the GPS said it was switching to usb-storage mode, and then would shut down.
    When plugged in a real windows machine (not through virtualbox), it worked perfectly fine, and I tried with 7 other linux machines, including one 15 years old with a very old linux kernel, and each time it shut down, bummer.

    By then, I was pretty screwed because I did need basecamp and virtualbox to work, and eventually google gemini looked at the logs before shutdown:

    kernel: [94868.932764] usb 3-5: new high-speed USB device number 34 using xhci_hcd
    kernel: [94869.136992] usb 3-5: New USB device found, idVendor=091e, idProduct=0003, bcdDevice= 0.01
    kernel: [94869.136998] usb 3-5: New USB device strings: Mfr=0, Product=0, SerialNumber=0
    kernel: [94869.740855] usb 3-5: reset high-speed USB device number 34 using xhci_hcd

    Turns out the problem was this, as explained by The entire crash and shutdown loop was driven by the kernel's runtime USB autosuspend dropping link power at the 2-second mark.

    When no host kernel driver binds to the interface, the kernel suspends the port. The Montana firmware interprets that link drop as a physical cable disconnect, terminates storage negotiation, executes an emergency waypoint flush, and turns off. Keeping the link energized via ATTR{power/autosuspend}="-1" completely resolves the failure mode, allowing any VM to claim the device without racing against link power down.

    The montana is wrong, but garmin support made it clear that because it works on windows, they were not super interested in diagnosing or fixing it. Maybe with this page, they'll consider a fix, but in the meantime, the workaround is this:

    Create /etc/udev/rules.d/99-garmin-passthrough.rules with ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="091e", ATTR{power/control}="on", ATTR{power/autosuspend}="-1"

    save and run "udevadm control --reload-rules; udevadm trigger"

    this ensures linux will not autosuspend the port which in turn causes the montana not to shut down, allows virtualbox to grab the port, hand it over to windows, and have basecamp work again. Yeah!

    now it works
    now it works

    basecamp loading maps via MTP in virtualbox on linux
    basecamp loading maps via MTP in virtualbox on linux

    MTP shows both filesystems, the built in storage and sdcard
    MTP shows both filesystems, the built in storage and sdcard

    π 2026-10-18 01:01 in Diving, Linux
    Subsurface is the best dive log software as it works on everything and was co-authored Linus Torvalds and Dirk Hohndel, both I've had the pleasure to dive with: https://subsurface-divelog.org/ .


    On top of being open source and working on linux, both important to me, a huge plus is it works with a huge amount of dive computers and you keep your logs in the same software across all your computers and phones, synced in the cloud, and for free. If the dives have GPS locations, they are shown on a world map with a little red flag, and getting a world map full of little red flags, makes me happy :)

    After my last dive trip in French Polynesia, I was 6 dives short of 1000, but I had hundreds of dives in subsurface that didn't have GPS locations. My Dive computers (all 3 of them) do not log GPS data, and ever since the old subsurface android client that would log GPS locations and sync them against dives in the cloud after the fact, went end of life, none of my dives had GPS locations anymore.

    And yet, I had 40+ GPS GPX files from my garmin that is always running on my dive trips, so I knew just like I used to geotag my pictures with GPX files and date/time matching from the pictures EXIF data, the same was clearly possible with Subsurface, but when I asked, no one had done it (and to be fair, it's tedious code to write by hand).
    Also, Subsurface does not keep track of timezones, but stores times in local time as this is what dive computers do (without storing timezone along with it, and even cameras took maybe more than 10 years before finally storing timezone data in the EXIF tag...).

    So my goal was to just have most of my dives have a location on the map, I just wanted those little flags all over the world:


    Now, I need to state right now, I didn't really care if the location was exact, hell if it's off by 12h and maybe 100km from the actual site for a few dives because the time was wrong on my dive computer, or the GPS info wasn't present around that hour, I'm still happy to have the little flag in the general location where the dive happened. I do of course prefer exact data and most of it is very precise, but I'm not going to be super sad if a few added red flags added 10 years later, are not exactly in the right place.
    If this is not good for you, you can play with the --max-hours flag, and hope you never forgot to change the time in your dive computer each time you went to a different timezone (I know a few times, I did a few dives with the wrong time from the last part of the world I used to be in, but as I just said, I'm fine with close enough, as in just the correct side of the world :)

    Ok, so now let's talk about the code. We now live in the word of AI, gemini came to the rescue (used in pro high mode). I did use my brain for a single good idea that we didn't know timezones for the times in subsurface, but we could use the GPS locations and with a timezone database (timezonefinder python module in pip), and convert UTC times in the GPS file to local times for each location, which will happily match with the local time in subsurface. For the rest, I spent about 1h with gemini to have it figure out the somewhat non obvious dive location and global site location meanings of the subversion ssrf files, and within 1h, got the end result below.

    So no, I didn't write the code, all I had to do is make symlinks to all my GPX files that contained dive locations over the last 15 years, and run the code (did that a few times with testing revisions of the code until I was happy wit the end result)

    You can get the code here: https://github.com/marcmerlin/ai-misc/tree/main/subsurface_divelog_dive_gps_sync_auto

    sauron:~/gps/data/diving$ l *.gpx | head -3 lrwxrwxrwx 1 merlin merlin 27 Oct 18 22:06 20080202_Fiji_Diving.gpx -> ../20080202_Fiji_Diving.gpx lrwxrwxrwx 1 merlin merlin 33 Oct 18 22:09 20090811_Hawaii_Maui_Kauai.gpx -> ../20090811_Hawaii_Maui_Kauai.gpx lrwxrwxrwx 1 merlin merlin 32 Oct 18 22:13 20100529_Belize_Aggressor.gpx -> ../20100529_Belize_Aggressor.gpx*

    sauron:~/gps/data/diving$ subsurface_divelog_dive_gps_sync_auto.py ~/marc.ssrf --gpx "*.gpx" --max-hours 12 Loading GPX files from pattern: *.gpx Initializing offline timezone engine... Calculated local timezones for 1398219 GPS points.

    Dive #275 (Belise Aggressor III - Day 3) matched to Local GPX time 2010-05-31 07:09:36 [diff: 0:02:36]. Assigning GPS: 17.2137829 -87.6143720 Dive #276 (Belise Aggressor III) matched to Local GPX time 2010-05-31 10:34:57 [diff: 0:02:03]. Assigning GPS: 17.2134649 -87.6143339 Dive #279 (Belise Aggressor III - Day 4) matched to Local GPX time 2010-06-01 04:35:19 [diff: 0:04:41]. Assigning GPS: 17.2036230 -87.5416109 Dive #283 (Belise Aggressor III - Day 5) matched to Local GPX time 2010-06-02 04:33:53 [diff: 0:01:53]. Assigning GPS: 17.2156519 -87.6123730 (...) Dive #967 (Rangiroa Tiputa Pass) matched to Local GPX time 2026-09-30 14:44:48 [diff: 0:00:02]. Assigning GPS: -14.969145153 -147.623316413 Dive #981 (Fakarava South Pass) matched to Local GPX time 2026-10-06 09:10:00 [diff: 0:00:04]. Assigning GPS: -16.518651769 -145.460582804 Dive #983 (Fakarava North Pass) matched to Local GPX time 2026-10-07 08:16:54 [diff: 0:00:08]. Assigning GPS: -16.077915374 -145.713441521

    Successfully auto-matched and added GPS data to 339 dive(s).

    --- Dives Still Missing GPS Tags --- Dive #296: Heron Island Dive #297: Heron Island Dive #298: Heron Island Dive #328: San Diego Marissa Charters Dive #329: San Diego Marissa Charters Dive #330: San Diego Marissa Charters Dive #331: San Diego Marissa Charters Dive #332: San Diego Marissa Charters Dive #333: San Diego Marissa Charters Dive #458: Alore 11-1: Amet Knoll Dive #459: Alore 11-2: Pombo Island Dive #716: Dubai Aquarium

    --- Unique Locations Missing GPS --- - Alore 11-1: Amet Knoll - Alore 11-2: Pombo Island - Dubai Aquarium - Heron Island - San Diego Marissa Charters

    Total unique missing locations: 5

    ================================================= VERSION: v7 OUTPUT_FILE: updated_divelog.ssrf ================================================= sauron:~/gps/data/diving$

    As a reminder, you can get the code here: https://github.com/marcmerlin/ai-misc/tree/main/subsurface_divelog_dive_gps_sync_auto


    More pages: July 2002 February 2004 March 2004 November 2004 April 2005 August 2005 January 2006 July 2006 August 2007 November 2007 December 2007 January 2008 October 2008 November 2008 December 2008 January 2009 May 2009 July 2009 August 2009 September 2009 November 2009 December 2009 January 2010 March 2010 April 2010 June 2010 August 2010 October 2010 January 2011 July 2011 August 2011 December 2011 January 2012 March 2012 May 2012 August 2012 December 2012 January 2013 March 2013 May 2013 September 2013 November 2013 January 2014 March 2014 April 2014 May 2014 October 2014 January 2015 March 2015 May 2015 January 2016 February 2016 March 2016 June 2016 July 2016 August 2016 October 2016 January 2017 September 2017 January 2018 March 2018 December 2018 January 2019 August 2019 January 2020 May 2020 January 2021 September 2021 March 2023 April 2023 December 2023 June 2024 September 2024 November 2024 July 2025 August 2025 October 2025 November 2025 April 2026 October 2026

    Contact Email