A Guide to Build OpenWrt on WSL2

This article finished in a hurry.

Just wanna tell you guys that I'm still alive :)

Build System Setup

You can check https://openwrt.org/docs/guide-developer/toolchain/install-buildsystem

Obtain Latest Packages

I need some extra packages from https://github.com/kenzok8/openwrt-packages

So I run this command:

1
sed -i '1i src-git kenzo https://github.com/kenzok8/openwrt-packages' feeds.conf.default

The following stuff is from https://github.com/openwrt/openwrt

Run ./scripts/feeds update -a
(Obtain all the latest package definitions defined in feeds.conf / feeds.conf.default)

Run ./scripts/feeds install -a
(Install symlinks for all obtained packages into package/feeds/)

1
2
./scripts/feeds update -a
./scripts/feeds install -a

Edit Default Configuration

Make changes to .config in any way you like.

Remember to sync the config by running make menuconfig or make defconfig before moving further!

Download Necessary Files

Simply run this command.

1
make download -j$(nproc) V=s

Run Full Build

The original source is https://openwrt.org/docs/guide-developer/toolchain/wsl

In short, run the following command instead of executing make directly.

1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin make -j$(nproc) V=s

References

  • https://github.com/openwrt/openwrt
  • https://openwrt.org/docs/guide-developer/toolchain/install-buildsystem
  • https://openwrt.org/docs/guide-developer/toolchain/wsl