# Garmin gpsmap via USB not get detected



## Mari (Jul 24, 2019)

I installed FreeBSD 11.3. I tried to connect my Garmin gpsmap device via USB, however device not get detected/enumerated. When going through dmesg following error shows. I am new to FreeBSD. Any suggestions would be appreciated 
Thanks in advance.

```
$ dmesg
usb_alloc_device: set address 2 failed (USB_ERR_IOERROR, ignored)
usbd_setup_device_desc: getting device descriptor at addr 2 failed, USB_ERR_IOERROR
usbd_req_re_enumerate: addr=2, set address failed! (USB_ERR_IOERROR, ignored)
usbd_setup_device_desc: getting device descriptor at addr 2 failed, USB_ERR_IOERROR
usbd_req_re_enumerate: addr=2, set address failed! (USB_ERR_IOERROR, ignored)
usbd_setup_device_desc: getting device descriptor at addr 2 failed, USB_ERR_IOERROR
usbd_req_re_enumerate: addr=2, set address failed! (USB_ERR_IOERROR, ignored)
usbd_setup_device_desc: getting device descriptor at addr 2 failed, USB_ERR_IOERROR
usbd_req_re_enumerate: addr=2, set address failed! (USB_ERR_IOERROR, ignored)
usbd_setup_device_desc: getting device descriptor at addr 2 failed, USB_ERR_IOERROR
ugen0.2: <Unknown > at usbus0 (disconnected)
uhub_reattach_port: could not allocate new device
```


----------



## ralphbsz (Jul 24, 2019)

Hard to debug, not enough information. Your problem might be as simple as bad cables or connectors. Since that is very little work to change, try that first.

As the owner of an older Garmin GPS receiver, I suspect that they use a non-standard USB protocol which will only work with their proprietary software, but I'm not sure that applies. The other tricky question is this: there are different classes of USB devices, such as storage devices (memory sticks, disk drives), communications (modems), human interface (mice and keyboard), and so on. Unfortunately, the list of USB device classes is very coarse, so many real-world USB things give the wrong class, and then require specialized software. For example, I have an UPS at home, which pretends to be a keyboard or mouse, and an industrial controller, which pretends to be a modem. Most likely your Garmin also tries to pretend something it isn't, and then a generic FreeBSD driver attaches to it, only to find that the Garmin doesn't work like a real mouse or modem.

To debug this: plug the device in, and run `usbconfig list` first; it will give you an overview of what devices (including ports) exist, and what the OS thinks your Garmin is. Once you have found the device in the list, run `usbconfig -d ugen4.2 dump_all_desc` (substitute the device address for your Garmin instead of ugen4.2). That will tell us pretty much everything we can know about the device, in particular what class it claims to be. Then, try `usbconfig -ugen4.2 show_ifdrv`, which will tell us which USB driver stack FreeBSD is trying to use for this device. In general, read the man page usbconfig(8) for the usbconfig command, and read up on Wikipedia or similar about how USB works in general. Let us know what you find.


----------



## Mari (Jul 25, 2019)

Hi Ralph,

Thank you for quick response. Garmin GPS device will show as USB mass storage device when connected to Linux/windows machine. In FreeBSD, device not even get detected/enumerated.  When first time device plugged it throws the error as such in dmesg.
Again plug out and plug in the device, it shows as follows.

```
ugen0.2: <vendor 0x091e product 0x0003> at usbus0
ugen0.2: <vendor 0x091e product 0x0003> at usbus0 (disconnected)
```

As suggested, the command usbconfig list  shows as follows.

```
usbconfig list
ugen2.1: <AMD EHCI root HUB> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen1.1: <AMD EHCI root HUB> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen0.1: <0x1022 XHCI root HUB> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen1.2: <vendor 0x0438 product 0x7900> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (100mA)
ugen2.2: <vendor 0x0438 product 0x7900> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (100mA)
ugen2.3: <PixArt Dell MS116 USB Optical Mouse> at usbus2, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (100mA)
ugen1.3: <DELL Dell USB Entry Keyboard> at usbus1, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (100mA)
```

Here it shows nothing about the Garmin device details. Attached the entire dmesg as file. Please look into it. Thanks again


----------



## ralphbsz (Jul 25, 2019)

Strange. The USB protocol doesn't even get to the point of communicating enough to identify the Garmin device. No idea why this is happening. You say this works with Linux, but doesn't work with FreeBSD. Is Linux running on the same hardware, with the Garmin plugged into the same USB port? Here's why I'm asking. The IO error for the Garmin happens on USB port ugen0.2. That is connected to a USB host interface that is of type XHCI, meaning USB 3.0. But you also have two USB host interfaces that are of type EHCI, meaning USB 2.0. Try plugging the Garmin into one of those ports, for example the one that is currently connected to the mouse or keyboard. It could be that the Garmin is incompatible with USB 3.0, perhaps only when using the FreeBSD driver. A few years ago, in some earlier FreeBSD version (probably 8.x or 9.x) I had that problem with a USB disk drive, which would only work when connected to a USB 2.0 port, and not on a USB 3.0 port. Upgrading to 11.x (for some value of x which I forgot) fixed that problem, and today I have my external disk on the fast USB 3.0 port.


----------



## Phishfry (Jul 26, 2019)

Mari said:


> vendor 0x091e product 0x0003>


Have you looked at /usr/src/sys/dev/usb/usbdevs to see if this is even supported?
It looks to me like it is not. You can easily add it there to gain support.
You will have to compile a custom kernel with your changes.


----------



## Phishfry (Jul 26, 2019)

After surveying usbdevs I see the vendorID is included but productID is not.
You can add it to the Garmin section around line 2165:
product GARMIN gpsmap    0x0003    gpsmap


----------



## Mari (Jul 26, 2019)

ralphbsz said:


> Strange. The USB protocol doesn't even get to the point of communicating enough to identify the Garmin device. No idea why this is happening. You say this works with Linux, but doesn't work with FreeBSD. Is Linux running on the same hardware, with the Garmin plugged into the same USB port? Here's why I'm asking. The IO error for the Garmin happens on USB port ugen0.2. That is connected to a USB host interface that is of type XHCI, meaning USB 3.0. But you also have two USB host interfaces that are of type EHCI, meaning USB 2.0. Try plugging the Garmin into one of those ports, for example the one that is currently connected to the mouse or keyboard. It could be that the Garmin is incompatible with USB 3.0, perhaps only when using the FreeBSD driver. A few years ago, in some earlier FreeBSD version (probably 8.x or 9.x) I had that problem with a USB disk drive, which would only work when connected to a USB 2.0 port, and not on a USB 3.0 port. Upgrading to 11.x (for some value of x which I forgot) fixed that problem, and today I have my external disk on the fast USB 3.0 port.


Hi,

Irrespective of the port USB 2.0/3.0 the result were same. FreeBSD was not able to get detect/enumerate the device. I tried tuning the USB tunable parameters using sysctl command but nothing helps.

Thanks,


----------



## Mari (Jul 26, 2019)

Phishfry said:


> Have you looked at /usr/src/sys/dev/usb/usbdevs to see if this is even supported?
> It looks to me like it is not. You can easily add it there to gain support.
> You will have to compile a custom kernel with your changes.


Hi,
Thank you for the response. In my case, the hub driver was not able to get detect the Garmin gpsmap device. I am new to FreeBSD, will take time to compile the kernel. I will try your suggestions and revert back with you an update 

Thanks


----------



## Phishfry (Jul 26, 2019)

I am unsure if this is the only file to be modified.
For example to add PID and VID for USB 3G modems you must add them to usbdevs and u3g.c
So I wonder if there is another file you must modify besides usbdevs for GPS device driver.


----------



## Phishfry (Jul 26, 2019)

I think you are good to go. The only thing I can find is a possible usb_quirk(4) for garmin. Only one model though.
Might be worth a shot.





						210544 – USB quirk for Garmin FR230
					






					bugs.freebsd.org
				




Building a new kernel for your GPS device is not hard. The instructions are spot on:








						Chapter 9. Configuring the FreeBSD Kernel
					

This chapter covers how to configure the FreeBSD Kernel. When to build a custom kernel, how to take a hardware inventory, how to customize a kernel configuration file, etc




					www.freebsd.org


----------



## Phishfry (Jul 26, 2019)

I am going to leave you with some links and possible settings once you get the device recognized.:









						Connecting Garmin GPS via serial (gpsman)?
					

Hi all,  I would like to run gpsman to connect to my new Garmin Etrex20. Conventionally, gpsman would like to connect to /dev/cua, but modern GPS's plug via USB ports. I am not sure where to even start with this -- I have no experience working with serial ports or doing anything with USB ports...




					forums.freebsd.org
				




https://kenyonralph.com/~kenyon/Time_server/
I really don't know if this is needed currently.
/etc/devfs.conf
`link cuau0 gps0`

He is a quirk to try using your VID and PID:
/boot/loader.conf
`hw.usb.quirk.0="0x091e 0x0003 0 0xffff UQ_MSC_NO_INQUIRY"`

Using a Sierra Modem for GPS you must nudge the modem to get it to sending GPS stream:








						GPS on Beaglebone from 4G modem
					

I am a pfSense fan and have Sierra MC7700 and Atheros Mifi embedded builds in a couple of headless vehicle Intel PC's. So I am familiar with embedded gear and I am learning with FreeBSD on the Beaglebone Black. So due to a single USB port I used a USB hub with MC7700 on a USB to MiniPCIe adapter...




					forums.freebsd.org
				



echo \$GPS_START >/dev/cuaU0.2


----------



## Mari (Jul 26, 2019)

Phishfry said:


> He is a quirk to try using your VID and PID:
> /boot/loader.conf
> `hw.usb.quirk.0="0x091e 0x0003 0 0xffff UQ_MSC_NO_INQUIRY"`



Hi,

Before get into kernel compilation, I tried as you suggested about quirk the device by adding the command `hw.usb.quirk.0="0x091e 0x0003 0 0xffff UQ_MSC_NO_INQUIRY"` in /boot/loader.conf. However the problem still persist. 

Again thank you  for timely response.


----------



## chrbr (Jul 26, 2019)

Dear Mari,
I own a Garmin etrex10. I have been irritated by its behaviour, too. If you attach it it takes some time until it shows up as USB device. It can be even more than a minute. With the etrex10 it is connected as a USB device when the normal black on grey text changes and the background display gets activated. Once that happens you can use it as expected. It just needs some patience.
Kind regards,
Christoph


----------



## ralphbsz (Jul 26, 2019)

I think the problem here is more fundamental than usbdevs, linking cuau0, and such. What we see from the above error messages: The FreeBSD USB stack is capable of reading the vendor and product (it reports it correctly in the error message), and then things go "pear-shaped" (euphemism for really bad, I just re-learned it from the "Good Omens" movie, which is very funny). We don't even get to the point where it matters whether the device is mass storage, modem, or GPS ... all communication seems to stop there, causing the disconnect.

I think that if this can be fixed at all in FreeBSD, it will have to be fixed with a quirk (see usb_quirk() for details). There is about a dozen generic (not audio- or mouse-specific) quirks, and about a dozen mass-storage specific quirks. Unless one has some debugging capability (which I don't have), I think the only way to test this is to try out all quirks. In theory, one should try all combinations; with over 20 quirks, that's a million, so it's completely impractical to do an exhaustive enumaration test. It is also possible that the Garmin USB implementation is so broken that the FreeBSD USB stack won't work with it without coding changes.

The comment by chrbr made me think of one other thing: On our Garmin GPS receiver at home, the device needs to be put into a communication mode to even speak USB. If you just plug the USB cable in, nothing happens. But then, our Garmin is very old (probably 15 years or so).

Mandatory anecdote: One of the fathers of USB is a gentleman named L. Nigel Featherston. He used to live in the San Francisco Bay Area, where he was heavily involved with music recording and rock music in the 70s. He used his skills as a system designer and software engineer to pay for his rock music hobby. In the 70s, he bought a remote property in a mountainous area nearby, in the hope of building a house there and doing nothing but rock music. Unfortunately, that plan didn't work out, and he moved to Washington, where he became the architect for Microsoft's USB implementation; I think he has long retired from MS. His failure is our luck: We now own 3/4 of his land, and our house is on it. And while we do play heavy metal at home (my son owns two tubas and one trombone, and I have a grand piano plus a large 4-octave vibraphone), we don't do rock.

Oh, and if you try to google in detail for L. Nigel Featherston, you will find some surprises. I won't give his privacy away, but he is not exactly the person he seems to be.


----------

