What's new

[Dev] Documentation for building the firmware under WSL2

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

RMerlin

Asuswrt-Merlin dev
Staff member
Since Windows 10 version 2004 (and WSL2) are now officially available outside of the Insider Preview program, I figured I should finally clean up my notes, and document how to setup WSL2 to compile Asuswrt-Merlin.

I initially tried this on my new laptop to see how the performance was. First results were horrible, build times on the laptop took three times longer than on the desktop's VM. After a few exchanges on Twitter with other WSL2 users (and Microsoft's own Program Manager responsible for WSL), we finally tracked down the issue to the search path (building the firmware requires to execute the compiler many thousands of times). Searching through the Windows portion of the path introduced a major performance penalty.

After configuring WSL to not include the Windows search path within the Linux search path, I was able to get an RT-AC68U firmware to build in 25 minutes under WSL2 on my new laptop (an AMD Ryzen 5 4500U 6-cores). Doing the same build on the laptop running VirtualBox took 30 minutes. So at least with this AMD CPU, WSL2 is quite faster than VBox.

For reference, my desktop's i7 7700K running VMWare Player does it in about 20-21 minutes. Can't install WSL2 on it to compare as I need VMWare for work purposes, and WSL2 requires Hyper-V, which is currently incompatible with other hypervisors. Both VMWare and VBox devs are working on this. VBox already kinda supports running under Hyper-V, but it's much, much slower at the moment.


So for anyone who wants a build environment without the bulkiness of a VM, WSL2 is a very viable option. If you try it out, I'd be curious to see the performance difference for your system between WSL2 and a VM.

The guide was added to the Wiki:

https://github.com/RMerl/asuswrt-merlin.ng/wiki/Compiling-under-WSL2
 
For those wondering what this is: Windows Subsystem for Linux (or, WSL) is a Linux environment that runs within Windows 10.

WSL2, introduced with the freshly released Windows 10 version 2004 is a major improvement, as instead of emulating system calls, it sits on top of a real Linux kernel, that runs inside a lightweight Hyper-V VM. This allows it to gain very high compatibility, in addition to greatly improving performance over the original WSL.

Despite being actually a VM, it's a light-weight, specialized VM, which will start and stop transparently as needed, and very quickly.

In the future, WSL will even be gaining GPU acceleration and video support, which means we will even be able to eventually run Linux GUI applications from within Windows.
 
For those wondering what this is: Windows Subsystem for Linux (or, WSL) is a Linux environment that runs within Windows 10.

WSL2, introduced with the freshly released Windows 10 version 2004 is a major improvement, as instead of emulating system calls, it sits on top of a real Linux kernel, that runs inside a lightweight Hyper-V VM. This allows it to gain very high compatibility, in addition to greatly improving performance over the original WSL.

Despite being actually a VM, it's a light-weight, specialized VM, which will start and stop transparently as needed, and very quickly.

In the future, WSL will even be gaining GPU acceleration and video support, which means we will even be able to eventually run Linux GUI applications from within Windows.
Now I'm tempted to try and get VNC Server running in WSL2 :D
 
Now I'm tempted to try and get VNC Server running in WSL2 :D

Can't do that, no graphical support yet. But they already announced that graphical support was under development.
 
Awesome! Worked flawlessly and fast (13 minutes) . Finally can rid of VMWARE
 
Last edited:
CPU: Ryzen 9 3950X overclocked (4.4 Ghz)
Ram: Corsair Vengeance LPX 2x16GB DDR4 3600MHz (also overclocked)
I like overclocking =\

What was the build time under VMWare?
 
Since Windows 10 version 2004 (and WSL2) are now officially available outside of the Insider Preview program, I figured I should finally clean up my notes, and document how to setup WSL2 to compile Asuswrt-Merlin.

I initially tried this on my new laptop to see how the performance was. First results were horrible, build times on the laptop took three times longer than on the desktop's VM. After a few exchanges on Twitter with other WSL2 users (and Microsoft's own Program Manager responsible for WSL), we finally tracked down the issue to the search path (building the firmware requires to execute the compiler many thousands of times). Searching through the Windows portion of the path introduced a major performance penalty.

After configuring WSL to not include the Windows search path within the Linux search path, I was able to get an RT-AC68U firmware to build in 25 minutes under WSL2 on my new laptop (an AMD Ryzen 5 4500U 6-cores). Doing the same build on the laptop running VirtualBox took 30 minutes. So at least with this AMD CPU, WSL2 is quite faster than VBox.

For reference, my desktop's i7 7700K running VMWare Player does it in about 20-21 minutes. Can't install WSL2 on it to compare as I need VMWare for work purposes, and WSL2 requires Hyper-V, which is currently incompatible with other hypervisors. Both VMWare and VBox devs are working on this. VBox already kinda supports running under Hyper-V, but it's much, much slower at the moment.


So for anyone who wants a build environment without the bulkiness of a VM, WSL2 is a very viable option. If you try it out, I'd be curious to see the performance difference for your system between WSL2 and a VM.

The guide was added to the Wiki:

https://github.com/RMerl/asuswrt-merlin.ng/wiki/Compiling-under-WSL2
I tried the compile process of WSL2, it is rather lacking in the performance department. VM hands down better at performance. (just from my experience.)
 
I tried the compile process of WSL2, it is rather lacking in the performance department. VM hands down better at performance. (just from my experience.)
Then you probably didn't properly follow the instructions. It should match or exceed a VM's performance as noted by multiple users who have tested it and reported similar or better performance. Failing to address the search path issue is the most likely culprit.

Sent from my SM-T720 using Tapatalk
 
What was the build time under VMWare?
Slower. Even when I set 16 cpus in settings (tried also 32) it never stressed all my 32 threads to 100% like WSL 2 did and I gave it 8GB ram. VM took about 20 minutes. Next time I build, I will measure compile time again and report
 
Tests completed. WSL2 performance is totally identical to VMWare Player on my i7 7700K (plagued with Meltdown/Spectre patches). Tests were made building the RT-AC68U.

VMWare (without WSL2 installed, so running privileged mode):
real 21m53.120s
user 31m36.008s
sys 5m5.824s


VMWare (with WSL2 installed, so running in userland mode):
real 25m31.141s
user 38m23.152s
sys 3m20.616s


WSL2:
real 21m53.252s
user 29m35.852s
sys 1m54.276s

So if you need to run both WSL2 and VMWare 15.5 at the same time, VMWare will suffer a slight performance hit. But if the goal is to replace VMWare, then it's a toss up for this specific CPU.
 
I used vmware just for compiling your firmware... so now I don't need an additional third party software with it's drivers and services installed, don't need the tiny looking ubuntu gui on my 4K display which I had to come closer to it to see what I am typing in the Console, WSL 2 seem to utilize all my 32 threads to maximum if it needs whereas VMWARE was using much less threads even when set to 16 or 32...
I can access Ubuntu files and the compiled firmware file from Windows Explorer even when WSL is shutdown...
When new commits are pushed, I will measure the performance again. I think WSL 2 is faster on CPU's which have 8 cores or more
 
Last edited:
If you don't need VMWare for anything else, then yes, WSL2 definitely makes sense, especially if performance is equal or even better.

For my specific usage case however, since I need VMWare for other uses, and running it under Windows' Virtual Machine Platform carries a slight performance hit, I will be sticking to VMWare for now. But anyone not using any other VM might want to look at WSL2.
 
don't need the tiny looking ubuntu gui on my 4K display which I had to come closer to it to see what I am typing in the Console

Enable SSH on your VM, and connect to it using your preferred SSH client (XShell, Putty, etc...). Much more confortable to use.
 
Could someone point me in the right direction for compiling the RT-ax88u? I know, if I have to ask then I probably shouldn’t be doing it but I’m a tinkerer and would like to learn. I’ve been using amcfwm to do it the easy way.
 
If you don't need VMWare for anything else, then yes, WSL2 definitely makes sense, especially if performance is equal or even better.
Thanks Merlin. I had tried VMWare but ended up going dual boot on my laptop. I have other things I use Linux for and the dual boot made the most sense in my case.
With that said, I installed WSL2 today, then Ubuntu 20.04. Using Adams's amcfwm, the build for my AX88U failed.
I uninstalled 20.04 and am now trying 18.04 (which will likely work fine).
So far, so good.
 
Nothing wrong with the "easy" way of amcfwm. If you want to give it a go outside of amcfwm....
The wiki is the best place to start:
https://github.com/RMerl/asuswrt-merlin.ng/wiki/Compiling-under-WSL2
Thanks, I gave that a read and plan to at least set up the build environment this weekend but was curious about the comment about the bottom

“Your setup is now ready for compiling, from inside the amng-build folder. Please refer to the Wiki for more information as how to compile specific router models.”

I didn’t see anything on the wiki about compiling ax models. But I could be looking in the wrong place too.
 
Similar threads
Thread starter Title Forum Replies Date
finlay000 Selecting Adaptive QoS generates Init chrdev /dev/idp with major 190 Asuswrt-Merlin 2

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!

Staff online

Top