Building image using WSL

I have been all day fighting with WSL to be able to build the image from the SDK, so here is what I have found, this may save you a bunch of time if you plan to build it under wsl.

First, I use Debian with WSL2, so I followed the instructions for Ubuntu 20.04, install the specified packages and update cmake as explained. If you use other OS with wsl then follow the appropiate instructions.

After that, there are some checks and modifications to do in order to be able to build the image.

  • 1 Check that your wsl subsystem has enough memory to build the image.

With 4Gb it was not able to complete the build, so if you have assigned 4Gb or less you can change the memory creating a .wslconfig in your profile’s folder.

You can run this to create it at the correct place:

notepad.exe %UserProfile%/.wslconfig

Then add this to the config file:

memory=8GB #Assign 8Gb of RAM
swap=8GB #Add 8Gb of swap
processors=4 #Not needed, but speeds up building, can be removed or adjusted

Save it and restart wsl with “wsl --shutdown” if it was running.

  • 2 Ensure there are no spaces in the PATH

WSL by default enables Windows interop, so it adds the PATH of your system to the linux one, this causes troubles as it does not quote the paths that contain spaces.
You can avoid this creating a wsl.conf file at /etc with these entries:

  • 3 Not sure if this is because WSL or because I use Debian, I had to add a link from mounts to mtab.

Verify if you have the entry /etc/mtab, if it’s not present then use this to create a link:

sudo ln -s /proc/self/mounts /etc/mtab
  • 4 Finally modify the file duo-buildroot-sdk/buildroot-2021.05/package/ncurses/

Under WSL the terminfo contains hex numbers instead of letters, so we need to modify the build script.
Find the “define NCURSES_TARGET_CLEANUP_TERMINFO” and replace it with:

	$(RM) -rf $(TARGET_DIR)/usr/share/terminfo $(TARGET_DIR)/usr/share/tabset
	$(foreach t,$(NCURSES_TERMINFO_FILES), \
		$(INSTALL) -D -m 0644 $(STAGING_DIR)/usr/share/terminfo/$(shell python3 -c \
			"import sys; t = sys.argv[1]; t = f'{ord(t[0]):x}{t[1:]}'; print(t)" ${t}) \

The modified script uses python3 to parse the folder and convert it from ascii to the hex code so it matches what is generated, I tried before to use printf but not sure why the build jsut hangs when it’s used and with python it works correctly.

Hope this helps!


Thanks a lot! I ordered my Milk-V Duo and while waiting for it I was trying to build the Linux image using Ubuntu 22.04 on WSL. Everything was fine except the build failed and I didn’t understand why. Actually, I was embarrassed to ask for help as it seemed basic to simply follow the instructions on GitHub. Then I found your post and my problem was related to Windows paths and following our second point I was able to build! :wink: Great post, thanks again!

1 Like