Skip to content

mwp in Windows 11 WSL G

Jonathan Hudson edited this page Oct 12, 2021 · 34 revisions

Intro

As a result of user interest in running mwp on Windows 11 / WSL-G, here's an experiment to see if it's possible. By a Windows neophyte, so if I can install mwp on WSL, anyone can.

There is also an excellent you-tube video tutorial from Marc Hoffmann (in English and German).

Environment

Tested with Windows 11 VM hosted on Arch Linux.

WSL Installation

  • Installed default Ubuntu
  • Note that serial ports still don't appear to work in WSL (workaround described below)

Windows / WSL Pre-requisites

None other than the serial port issue, Wayland (GUI) and sound just work. The serial port problem can be mitigated by a "serial to IP" solution; mwptools provides ser2udp for this purpose.

mwp Installation

If git is not pre-installed in WSL, then it will be necessary to install it.

sudo apt update && sudo apt upgrade
sudo apt install git

Note: /etc/sudoers (via visudo) was edited to allows the WSL user to run commands as root without asking for a password.

Then it was just a case of cloning the mwp repository and following mwp's instructions (mwptools/docs/debian-ubuntu-dependencies.txt), to install the dependencies, thusly:

cp mwptools/docs/debian-ubuntu-dependencies.txt /tmp/u.sh
chmod +x /tmp/u.sh
# edit /tmp/u.sh for any optional items ...
sudo /tmp/u.sh Y # 'Y' bypasses interactive query / responses

Then build and install mwp and optionally the blackbox tools (as mwptools/docs/debian-ubuntu-dependencies.txt). Build documentation.

For the optimal blackbox replay, install the flightlog2x tools, either from the Github release or build from source in Linux/WSL.

Running mwp

There is no longer any need to mess around the DISPLAY or udev settings. No 3rd party X-server, Windows handles all the GUI.

One off changes

  • If you wish to replay blackbox logs, it is necessary to have an IPv6 definition of localhost; WSL's /etc/hosts does not provide this:

    # updated in /etc/hosts for ipv6
    ::1   localhost ip6-localhost ip6-loopback
    
  • Due font differences, it is may be necessary to reduce the font scaling in the mwp 'Flight View' docklet.

    gsettings set org.mwptools.planner font-fv 10
    # if you still have resizing problems, try 9 ....
    

Then you are ready to run mwp.

mwp

Serial devices

In order to use a serial device, it is necessary to run a "serial to IP" bridge on the Windows side. This application will need to be white-listed in the Windows firewall.

There are a number of existing solutions that may work; mwp provides a ser2udp tool that works well.

Building mwp's ser2udp

On the Linux/WSL side:

  • cd mwptools/src/samples/s2n
  • make ser2udp.exe
  • copy ser2udp.exe to the dark Windows side

On the Windows side:

  • Use the Windows firewall settings to allow ser2udp.exe to accept UDP traffic.

  • Run ser2udp.exe ; it will autodetect your serial port. By default this listens on UDP port 17071, you can change this by supplying a second parameter, e.g., to use port 34567. In this case, either define the serial port or use auto (auto-detect).

    > ser2udp.exe auto :34567
    ## or just let ser2udp autodetect
    > ser2udp.exe
    External address: fe80::1439:d6de:efcb:97e1%7
    External address: 172.29.32.1
    

    The colon is required to define an alternative port.

  • ser2udp will survive removal of USB devices and attempt to re-connect (e.g. if the FC is rebooted).

  • You need to kill (^C) ser2udp when you're done with it

Using ser2udp in mwp

  • We need to know the IP address (or have a hostname for) the Windows WSL endpoint. Fortunately this happens to be the Linux default gateway, so we can handle it fairly transparently.

It is easily automated by using the magic __MWP_SERIAL_HOST name in the serial device.

mwp -d udp://__MWP_SERIAL_HOST:17071
# recognised by other tools as well ...
cliterm udp://__MWP_SERIAL_HOST:17071

__MWP_SERIAL_HOST is resolved as:

  • If an enviroment variable $MWP_SERIAL_HOST exists, it is used; else
  • The default gateway (which on WSL in the Windows host IP) is used; else
  • It will fail, as the literal name is unlikely to exist as a resolvable host name (not even a RFC legal host name).

Thus:

  • For WSL and ser2udp, in mwp preferences, set the serial device to udp://__MWP_SERIAL_HOST:17071
  • Or in the shell, for some other scenario, export MWP_SERIAL_HOST=foobox.org in the event that you have a valid use case

Launch ser2udp and MWP in one go

  • Create a new txt file in the same folder where ser2udp.exe is located and copy the following lines into that file:
@echo off
echo Launching MWP Mission Planner
start wslg.exe -d Ubuntu mwp
echo Waiting for WSL System to boot up
timeout 5
echo Launching Serial to UDP Tool
start "Serial2UDP" cmd /c ser2udp.exe -verbose 1
exit
  • rename the file with any name and change the extension to .cmd
  • Create a shortcut anywhere on your PC or in C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs to pin it to your Start Menu
  • Replace the shortcut symbol with the MWP icon from here

Other packages for additional functionality.

  • To replay blackbox logs, you need
    • inav blackbox tools, mandatory
    • flightlog2x / bbl2kml optional. Provides a much better blackbox replayer than the default shipped with mwp (and you can generate really pretty Google Earth files from blackbox / opentx / bulletgcss logs).
  • Terrain Analysis
    • Gnuplot. Check the installer script that it's enabled.

Summary

  • Much, much better than the prior WSL instances, pity about the lack of support for serial ports (still). Overall, the seamless WSL-g experience is impressive.

Connection via ser2udp bridge

Connected Note: Older version of ser2udp that defaulted to port 7071.

Terrain / elevation analysis

Terrain

Blackbox replay

BBL Note: The user's compass seems good enough for navigation functions (top right widget comparing GPS CoG v. compass heading).

Clone this wiki locally