Attach a GPS in preboot mode [RESOLVED]

lnj.sam@gmail.com stephan.crevenat.pro at gmail.com
Sat Feb 4 14:16:36 UTC 2023


Thank you Peter and sorry for the delay !

You put me in the correct direction and the problem is now resolved :)

I wrongly assumed that attaching the device to the guest in "preboot 
mode" should be only made in the "serial" way because I supposed that we 
can not attach the device as a "hostdev" before the host really detect 
the device as a USB device listed by "lsusb" which can take a moment.

But simply attach with "hostdev" with the idVendor/idProduct given in 
"preboot mode" did the trick :

     echo    "<hostdev mode='subsystem' type='usb' managed='yes'> \
                 <source> \
                     <vendor id='0x091e'/> \
                     <product id='0x0003'/> \
                 </source> \
             </hostdev>" > serial_device.xml

 From the host (here Debian 11) when I plug the GPS, I see this :

root at host:~# journalctl -kf
...
févr. 04 13:11:46 host kernel: usb 2-11: new high-speed USB device 
number 34 using xhci_hcd
févr. 04 13:11:46 host kernel: usb 2-11: New USB device found, 
idVendor=091e, idProduct=0003, bcdDevice= 0.01
févr. 04 13:11:46 host kernel: usb 2-11: New USB device strings: Mfr=0, 
Product=0, SerialNumber=0
févr. 04 13:11:46 host kernel: garmin_gps 2-11:1.0: Garmin GPS usb/tty 
converter detected
févr. 04 13:11:46 host kernel: usb 2-11: Garmin GPS usb/tty converter 
now attached to ttyUSB0
févr. 04 13:11:54 host kernel: usb 2-11: USB disconnect, device number 34
févr. 04 13:11:54 host kernel: garmin_gps ttyUSB0: Garmin GPS usb/tty 
converter now disconnected from ttyUSB0
févr. 04 13:11:54 host kernel: garmin_gps 2-11:1.0: device disconnected
...

 From a guest (here Debian 11 too) when the script attach the GPS, I see 
this :

root at guest:~# journalctl -kf
...
févr. 04 13:25:58 guest kernel: usb 2-6: new high-speed USB device 
number 8 using ehci-pci
févr. 04 13:25:58 guest kernel: usb 2-6: New USB device found, 
idVendor=091e, idProduct=0003, bcdDevice= 0.01
févr. 04 13:25:58 guest kernel: usb 2-6: New USB device strings: Mfr=0, 
Product=0, SerialNumber=0
févr. 04 13:25:58 guest kernel: garmin_gps 2-6:1.0: Garmin GPS usb/tty 
converter detected
févr. 04 13:25:58 guest kernel: usb 2-6: Garmin GPS usb/tty converter 
now attached to ttyUSB0
févr. 04 13:26:03 guest kernel: usb 2-6: USB disconnect, device number 8
févr. 04 13:26:03 guest kernel: garmin_gps ttyUSB0: Garmin GPS usb/tty 
converter now disconnected from ttyUSB0
févr. 04 13:26:03 guest kernel: garmin_gps 2-6:1.0: device disconnected
...

So the device is correctly transferred, and it is confirmed as the 
"preboot tools" detect the device in a "Windows 7"**guest

I want to add that, as far as I know we can not use the "virt-manager" 
GUI to do the same, for two reasons :
- the USB host device window do not refresh itself when the items are 
added or removed
- the delay to attach this device is pretty short (5 to 8 seconds) and 
just after, from the guest we must trigger the tools which can manage 
the device in "preboot mode" (typically a flash tool)

That is why the solution I found, is to automate this with a script 
which detects the kernel events and automatically attach the devices.


The host versions :
root at host:~# cat /etc/os-release | grep -E "^(NAME|VERSION)=" | tr '\n' 
' ' ; uname -a ; kvm --version | grep version ; libvirtd --version ; 
virt-manager --version
NAME="Debian GNU/Linux" VERSION="11 (bullseye)"
Linux host 5.10.0-8-amd64 #1 SMP Debian 5.10.46-4 (2021-08-03) x86_64 
GNU/Linux
QEMU emulator version 5.2.0 (Debian 1:5.2+dfsg-11)
libvirtd (libvirt) 7.0.0
3.2.0


As I want to post the complete method I used, I will certainly make a 
feedback in this thread later ;)

Le 25/01/2023 à 15:24, Peter Krempa a écrit :
> On Tue, Jan 24, 2023 at 00:10:46 +0100,lnj.sam at gmail.com  wrote:
>> Hello everyone and best wishes for 2023 :)
>>
>> I have an old *Garmin Drive Smart 50 GPS* and I want to be able to attach it
>> when it is in preboot mode to a VM hosted by a *Debian 11 host*.
>>
>>  From what I understand, the preboot mode allows us to flash a firmware
>> before the GPS actually starts (used among other things when the GPS is soft
>> bricked).
>>
>> When I connect the GPS to the host it gives:
> [...]
>
>> My questions :
>>
>> Q1 : Is it possible ?
> It shpi;d be/
>
>> Q2 : Am I doing it the right way ?
> I don't think so. You are using a serial device emulated which is then
> connected to the host side USB-tty device.
>
> A better way is simply to use USB-assignment/passthrough and have the
> guest OS handle also the USB side
>
>> Q3 : Is there a method to pass such a device directly (pass-through) ?
> To pass a USB device use the following XML:
>
>      <hostdev mode='subsystem' type='usb' managed='yes'>
>        <source>
>          <vendor id='0x1a86'/>
>          <product id='0x55d4'/>
>        </source>
>        <address type='usb' bus='0' port='4'/>
>      </hostdev>
>
> Obviously tweak vendor/product.
>
> Alternatively when you are using virt-manager GUI there's a menu to pass
> any device, or by default when you have a VM window active and plug in a
> USB device it's passed to the VM. (It can be disabled though).
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20230204/aea72ad5/attachment.htm>


More information about the libvirt-users mailing list