Just to be clear, Windows for any software development SUCKS!!!!!, the following guide present a good alternative since allow us to use many of the feature presented in Linux, with certain limitation but at the end of the day much better than using Windows. The guide assumes you are using windows 11 and you have all the freedom to run program in admin mode

Open a Windows PowerShell terminal as an administrator, then type the following commands to enable WSL on your machine, entering each line separately.

> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Restart your computer, then open PowerShell as an administrator to update the Windows Subsystem for Linux (WSL). If it's not already installed, this process will install it for you.

> wsl --update

Installing Arch Linux

Download the files ArchWSL-AppX_24.4.28.0_x64.appx and ArchWSL-AppX_24.4.28.0_x64.cer from the official ArchWSL repo Releases · yuk7/ArchWSL (always look for the latest release), install the cer file first, remember to install at local machine level

then select the certification store, then finish and OK.

After the last steps you can install the appx just like any other windows installer and then launch, a wild terminal will appear, just hit enter to close it

At this point Arch is installed in our system, we just need to configure a few things. Open a Windows Terminal and type Arch and then passwd to set up the root password

> Arch
[root@PC-NAME]# passwd

Then set up the your default user with its corresponding password, where {username} is the user nae you want to provide

[root@PC-NAME]# echo "%wheel ALL=(ALL) ALL" > /etc/sudoers.d/wheel
[root@PC-NAME]# useradd -m -G wheel -s /bin/bash {username}
[root@PC-NAME]# passwd {username}
[root@PC-NAME]# exit

Set the your user as default to init with arch

> Arch config --default-user {username}

Set up pacman package manager and update

> Arch
[user@PC-NAME]$ sudo pacman-key --init
[user@PC-NAME]$ sudo pacman-key --populate
[user@PC-NAME]$ sudo pacman -Sy archlinux-keyring
[user@PC-NAME]$ sudo pacman -Su

Install base tool for software development (like gcc, make, bison, etc..), this is also necessary to install some packages with pacman or manually

[user@PC-NAME]$ sudo pacman -S base-devel 

Install USB utilities because we are embedded and we need to connect our boards.

[user@PC-NAME]$ sudo pacman -S usbutils

And naturally, proficiency in Python is essential, as without it one cannot be regarded as a proficient developer and also git.

[user@PC-NAME]$ sudo pacman -S python git

paru is another must to install, is an extra package manager when the official repos in pacman does not have available some of the software

$ git clone https://aur.archlinux.org/paru.git
$ cd paru
$ makepkg -si
$ cd ..
$ rm -r paru

Installing USB support

by default WSL does not support USB devices, making impossible to flash or debug our beloved microcontroller, but there is an alternative installing an extra package, go to Connect USB devices look for the link to USB-WIN project and download de latest version to proceed to install.

I have connected my Nucleo-G0 board with a preprogramed JLink debugger, if we type the following in PowerShell (admin privileges is required) we should see a USB Serial Device (COM5), BULK interface (i don’t have installed any driver yet) and yes, I also have a Lauterbach $$$$

> usbipd list
Connected:
BUSID  VID:PID    DEVICE                                                        STATE
5-2    1366:0105  USB Serial Device (COM5), BULK interface                      Not shared
5-3    8087:0029  Intel(R) Wireless Bluetooth(R)                                Not shared
6-3    0897:0005  Lauterbach PODBUS USB Controller (USB3,PRO)                   Not shared

If we follow the steps in the Microsoft page we should “share“ the 5-2 device usign the command usbipd bind, after that, list again to see is already share

> usbipd bind --busid 5-2
> usbipd list
Connected:
BUSID  VID:PID    DEVICE                                                        STATE
5-2    1366:0105  USB Serial Device (COM5), BULK interface                      Shared
5-3    8087:0029  Intel(R) Wireless Bluetooth(R)                                Not shared
6-3    0897:0005  Lauterbach PODBUS USB Controller (USB3,PRO)                   Not shared

Next we need to attach to our WSL instance with Arch Linux, but before this open another terminal and run your Arch instance

> usbipd attach --wsl --busid 5-2
usbipd: info: Using WSL distribution 'Arch' to attach; the device will be available in all WSL 2 distributions.
usbipd: info: Using IP address 172.19.0.1 to reach the host.
> usbipd list
Connected:
BUSID  VID:PID    DEVICE                                                        STATE
5-2    1366:0105  USB Serial Device (COM5), BULK interface                      Attached
5-3    8087:0029  Intel(R) Wireless Bluetooth(R)                                Not shared
6-3    0897:0005  Lauterbach PODBUS USB Controller (USB3,PRO)                   Not shared

On your Arch terminal type the linux command lsusb to display the usb devices, you can see Linux does not need any driver and already detects our JLink out of the box

[diego@DESKTOP-0VPDF6R ~]$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 1366:0105 SEGGER J-Link
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

WSL package for VSCode

I assume you're using VSCode, search for the WSL extension and install it. If that's not the case, there's no need to worry—simply continue using the terminal independently alongside your preferred editor.

Once the extension is installed, click the icon in the bottom left corner and then select 'Connect to a remote option' from the popup menu. When you open a terminal, you will notice that we are now in our lovely Arch environment.

From this point, you can generally follow the instructions we use in our various trainings when we mention to install tools in linux. Just keep in mind that we are not using Linux, and several features that reference the kernel will not be available. However, it is very similar to Microsoft, and it is a much better alternative than using Windows.

One last thing, where in the heck are located all the files we create and edit in our Linux subsytem (WSL), it is easy just open a Windows explorer and type \\wsl$ then hit enter. You just need to navigate to Arch/home/username

Here is a nice video from Abstract Programmer How to access WSL files from windows and Windows files from WSL with a good explanation. But do not mess around with files in Linux and Windows, if you want to share something use Git or something like that. Here is another video to install Arch just in case Using Linux on Windows with WSL 2 🐧 – Debian and Arch Linux

Additionally, you can execute Windows programs from your WSL terminal, specifically CLI programs, by adding their extension, which can be a bit annoying. For example, I have this fancy compiler from Hightec that only runs on Windows, at least the version I possess.

$ tricore-gcc.exe -v
HTC_GCC_OPTIONS=-v
Using built-in specs.
COLLECT_GCC=tricore-gcc.exe
COLLECT_LTO_WRAPPER=c:/hightec/toolchains/tricore/v4.9.3.0-infineon-1.0/bin/../libexec/gcc/tricore/4.9.4/lto-wrapper.exe
Target: tricore
Configured with: ../../sources/gcc/configure --host=x86_64-w64-mingw32 --build=x86_64-linux-gnu --with-pkgversion=HDP-v4.9.3.0-infineon-1.0-fb21a99 --with-bugurl=support@hightec-rt.com --target=tricore --prefix=/data/distribution/HDP-v4.9.3.0-infineon-1.0/tricore-win64/htc/tricore/win64/HDP-v4.9.3.0-infineon-1.0 --program-prefix=tricore- --with-local-prefix=/data/distribution/HDP-v4.9.3.0-infineon-1.0/tricore-win64/htc/tricore/win64/HDP-v4.9.3.0-infineon-1.0 --disable-shared --with-gnu-as --with-gnu-ld --disable-threads --enable-languages=c,c++ --disable-libssp --enable-nls --with-headers=yes --with-newlib=yes --enable-newlib-elix-level=3 --enable-newlib-io-long-long --disable-newlib-supplied-syscalls
Thread model: single
gcc version 4.9.4 build on 2019-06-07 (HighTec Release HDP-v4.9.3.0-infineon-1.0-fb21a99)