EBC Exercise 02 Setting Up Windows Subsystem for Linux

From eLinux.org
Jump to: navigation, search

thumb‎ Embedded Linux Class by Mark A. Yoder

The Beagle can run standalone with a monitor and keyboard and mouse, but we use it in an iot mode where it's accessed through the network. When used this way an Linux host is used that is either a native install on a laptop (or desktop) or a virtual machine running under Windows.

The purpose of this wiki is to introduce a third option, running in the Windows Subsystem of Linux (wsl).

The Windows Subsystem of Linux

wsl lets developers run a GNU/Linux environment directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup. Details about wsl can be found here: https://docs.microsoft.com/en-us/windows/wsl/about, or just googling for it. Here I'll highlight how to install and use is for the class.

Installing WSL

Simply got to https://docs.microsoft.com/en-us/windows/wsl/install and follow the directions. In order to use certain features when working with the BeagleBone, you will need wsl 2. To check which version you have run the command below.

 host$ wsl.exe –l –v
  NAME      STATE           VERSION
* Ubuntu    Running         2

The NAME is your distribution name and VERSION is the version of wsl you are running (1 or 2). If you have version 2 then you are good to go, otherwise, to switch to wsl 2 run:

 host$ wsl.exe --set-version <distribution name> 2
 host$ wsl.exe --set-default-version 2

Run 'host$ wsl -l -v' again and you should see that wsl is now version 2.

Sharing the network

We used ip masquerading to have the host computer share the network with the Beagle. Here you need to set up Windows to do the sharing.

Once the Beagle is connected to your host computer running Windows 10, there should be an "ethernet connection" created over usb.

To share your internet from Windows:

  • Right click the wifi or ethernet icon in your taskbar, and select the Open Network & Internet Settings option.
  • Once the window is opened, scroll to the bottom and press Change adapter options under Advanced network settings.
  • To share your internet, right click on the adapter that your host is using to access the internet, and select Properties.
  • Go to the sharing tab at the top, and check the Allow other network users to connect through this computer's Internet connection option. If you have multiple internet adapters, you might need to select the Bone using the drop down menu. It should be the adapter with the description Remote NDIS Compatible Device in the Network Connection window.
  • Press OK at the bottom, then
  • right click the adapter for the Bone (the one labled Remote NDIS Compatible Device), and press Properties.
  • Double click on the Internet Protocol Version 4 option on the main tab, and
  • set both the IP address and DNS server addresses to be set automatically.
  • Press OK to go back to the Properties window and
  • press OK again.

After that, ssh into the bone, and run the command

bone$ sudo route add default gw

(This command needs to be run every time you boot the Bone.) The Bone should now have access to the internet. If you disconnect the Bone from your host, you may have to stop sharing your internet and reshare it, then set the IP and DNS Addresses to be automatic again for it to work.

thumb‎ Embedded Linux Class by Mark A. Yoder