OpenWrt Forum Archive

Topic: HOWTO: Compile Openwrt in Windows 10's embedded Ubuntu Linux subsystem

The content of this topic has been archived on 1 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I usually compile Openwrt & LEDE in Ubuntu 16.04 x64 running in Virtualbox inside my Windows PC. But I wanted to test if the new Windows 10 feature of a built-in embedded Linux subsystem is powerful enough to compile Openwrt.

The feature is part of the 1607 Anniversary Update for Windows 10 Pro+, but not Home. Basically the feature shows up as an Ubuntu bash shell. It even allows you to install new packages via "sudo apt-get install" like you would do in a normal Ubuntu computer.

To my surprise things actually worked pretty well. Openwrt (or actually LEDE) trunk firmware got compiled ok and my ar71xx/WNDR3700 router is happily running that firmware now. So, it is possible to compile Openwrt in Windows without needing to use Virtualbox etc. to get the needed Linux.

Key observations in case somebody else wants to try the same:

  • Native Windows NTFS disks are available in /mnt/c, /mnt/d etc. However, they have limitations for the allowed filenames: apparently ":" is a forbidden character, so cloning Openwrt sources to a native NTFS partition will fail due to e.g. wwan and usbmode packages that have files with : in the name. Similarly the file permissions defaults to chmod 777, which will not work for Openwrt buildroot.

    The subsystem creates a new Linux rootfs in the Windows user's Appdata\local dir ( C:\Users\<username>\AppData\Local\lxss ). There ":" is allowed for filenames as the filename handling seems to contain some conversion logic. Same goes also for file/dir permissions that work Linux-wise and allow other than 777.

    In practice that means that the Openwrt buildroot needs to be created on the system drive into the user profile of the Windows user. That might be unwanted in some situations, e.g. depending on the backup strategies.

  • The needed prerequisite packages list almost matched the normal Ubuntu x64 requirements. The only surprise was that "unzip" needed to be installed separately. I have never installed that on normal Ubuntu, but it seems to be missing from the default packages in the Windows Linux subsystem. But "sudo apt-get install unzip" fixed that.

Otherwise the compilation was straightforward and even my own buildscripts worked perfectly.

Personally I will continue to use Virtualbox to host Ubuntu, as that allows me to have the files elsewhere than the system drive. But in any case, the "Linux in Windows" feature works ok for Openwrt compilation.

I did not test it, but likely also the Openwrt imagegenerator would work ok.

Key steps to compile Openwrt inside Windows 10's embedded Linux:

  • Install & enable Linux subsystem for Windows 10. First change Windows 10 to "Developer mode" in System Settings to allow advanced development features. Then enable the "Windows subsystem for Linux (beta)" in the Windows programs&features selection. From a normal CMD command prompt issue the command "bash" to get the Linux subsystem installed and launched. The installation process also asks you to set a Linux username for the shell. Note that for Openwrt that needs to be something else than "root".

  • In the bash shell, install the pre-requisites:
      sudo apt-get install unzip
      sudo apt-get install build-essential subversion libncurses5-dev zlib1g-dev
      sudo apt-get install gawk gcc-multilib flex git-core gettext libssl-dev

  • Create a directory for the Openwrt buildroot to the / of the Linux subsystem rootfs, and chown & chmod the dir suitably. ("perus" is my non-root username):

      sudo mkdir /ow
      sudo chown perus /ow
      sudo chmod 755 /ow

  • Clone sources, change to directory, update feeds. The buildroot will be in /ow/openwrt :

      cd /ow
      git clone https://github.com/openwrt/openwrt.git
      cd openwrt
      ./scripts/feeds update -a
      ./scripts/feeds install -a

  • Normal config & make:

      make menuconfig
      make

(Last edited by hnyman on 16 Oct 2016, 16:09)

Hi,

I can confirm that building OpenWRT works as you described (however only with make -j1).

However, Image Generator (Image Builder) does not work, see below.

I followed

h-t-t-p-s://wiki.openwrt.org/doc/howto/obtain.firmware.generate

My system:
- Win10 Pro 10.2.14393
- Linux HOSTNAME 3.4.0+ #1 PREEMPT Thu Aug 1 17:06:05 CST 2013 x86_64 x86_64 x86_64 GNU/Linux

Commands in Bash:

cd ~
mkdir openwrt && cd openwrt
wget h-t-t-p-s://downloads.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64.tar.bz2
tar -xvjf OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64.tar.bz2
cd OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64
make -j1 image PROFILE=TLWR710

Output:

make[1]: Entering directory `/home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64'
echo 'Building images for ar71xx - TP-LINK TL-WR710N'
Building images for ar71xx - TP-LINK TL-WR710N
echo 'Packages: base-files busybox dnsmasq dropbear firewall fstools ip6tables iptables kernel kmod-ath9k kmod-gpio-button-hotplug kmod-nf-nathelper kmod-usb-core kmod-usb2 libc libgcc mtd netifd odhcp6c odhcpd opkg ppp ppp-mod-pppoe swconfig uboot-envtools uci wpad-mini'
Packages: base-files busybox dnsmasq dropbear firewall fstools ip6tables iptables kernel kmod-ath9k kmod-gpio-button-hotplug kmod-nf-nathelper kmod-usb-core kmod-usb2 libc libgcc mtd netifd odhcp6c odhcpd opkg ppp ppp-mod-pppoe swconfig uboot-envtools uci wpad-mini
echo

rm -rf /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/build_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx
mkdir -p /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/build_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/bin/ar71xx /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/tmp /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/dl
if [ ! -f "/home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/packages/Packages" ] || [ ! -f "/home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/packages/Packages.gz" ] || [ "`find /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/packages -cnewer /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/packages/Packages.gz`" ]; then \
                echo "Package list missing or not up-to-date, generating it.";\
                make package_index; \
        else \
                mkdir -p /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/build_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx/tmp; \
                IPKG_NO_SCRIPT=1 IPKG_TMP="/home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/tmp/ipkgtmp" IPKG_INSTROOT="/home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/build_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx" IPKG_CONF_DIR="/home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/tmp" IPKG_OFFLINE_ROOT="/home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/build_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx" /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/staging_dir/host/bin/opkg -f /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/repositories.conf --force-depends --force-overwrite --force-postinstall --cache /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/dl --offline-root /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/build_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx --add-dest root:/ --add-arch all:100 --add-arch ar71xx:200 update || true; \
        fi
Downloading h-t-t-p-://downloads.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/packages/base/Packages.gz.
Updated list of available packages in /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/build_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx//usr/lib/opkg/lists/chaos_calmer_base.
Downloading h-t-t-p-://downloads.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/packages/luci/Packages.gz.
Updated list of available packages in /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/build_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx//usr/lib/opkg/lists/chaos_calmer_luci.
Downloading h-t-t-p-://downloads.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/packages/packages/Packages.gz.
Updated list of available packages in /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/build_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx//usr/lib/opkg/lists/chaos_calmer_packages.
Downloading h-t-t-p-://downloads.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/packages/routing/Packages.gz.
Updated list of available packages in /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/build_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx//usr/lib/opkg/lists/chaos_calmer_routing.
Downloading h-t-t-p-://downloads.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/packages/telephony/Packages.gz.
Updated list of available packages in /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/build_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx//usr/lib/opkg/lists/chaos_calmer_telephony.
Downloading h-t-t-p-://downloads.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/packages/management/Packages.gz.
Updated list of available packages in /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/build_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx//usr/lib/opkg/lists/chaos_calmer_management.
Downloading file:packages/Packages.
Updated list of available packages in /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/build_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx//usr/lib/opkg/lists/imagebuilder.
make package_install
make[2]: Entering directory `/home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64'

Installing packages...
IPKG_NO_SCRIPT=1 IPKG_TMP="/home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/tmp/ipkgtmp" IPKG_INSTROOT="/home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/build_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx" IPKG_CONF_DIR="/home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/tmp" IPKG_OFFLINE_ROOT="/home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/build_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx" /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/staging_dir/host/bin/opkg -f /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/repositories.conf --force-depends --force-overwrite --force-postinstall --cache /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/dl --offline-root /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/build_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx --add-dest root:/ --add-arch all:100 --add-arch ar71xx:200 install /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/packages/base/libc_0.9.33.2-1_ar71xx.ipk
Installing libc (0.9.33.2-1) to root...
Installing libgcc (4.8-linaro-1) to root...
Copying /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/dl/libgcc_4.8-linaro-1_ar71xx.ipk.
make[2]: *** [package_install] Segmentation fault (core dumped)
make[2]: Leaving directory `/home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64'
make[1]: *** [_call_image] Error 2
make[1]: Leaving directory `/home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64'
make: *** [image] Fehler 2

Does anyone know how to fix this? I couldn't find an appropriate fix in the forums etc.

PS: Needed to change the h-t-t-p to be able to post due to error "Too more links in message".

Thank you and best regards,
Leonardo

humaita wrote:

Hi,
er, Image Generator (Image Builder) does not work, see below.

My system:
- Win10 Pro 10.2.14393
- Linux HOSTNAME 3.4.0+ #1 PREEMPT Thu Aug 1 17:06:05 CST 2013 x86_64 x86_64 x86_64 GNU/Linux

Commands in Bash:

Installing libc (0.9.33.2-1) to root...
Installing libgcc (4.8-linaro-1) to root...
Copying /home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64/dl/libgcc_4.8-linaro-1_ar71xx.ipk.
make[2]: *** [package_install] Segmentation fault (core dumped)
make[2]: Leaving directory `/home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64'
make[1]: *** [_call_image] Error 2
make[1]: Leaving directory `/home/USERNAME/openwrt/OpenWrt-ImageBuilder-15.05.1-ar71xx-generic.Linux-x86_64'
make: *** [image] Fehler 2

Does anyone know how to fix this? I couldn't find an appropriate fix in the forums etc.

PS: Needed to change the h-t-t-p to be able to post due to error "Too more links in message".

Thank you and best regards,
Leonardo

Hi Leonardo, did you ever solve this? I'm seeing the same behaviour now.

The discussion might have continued from here.