Best practice to compile for 2 or more devices

What is the best practice to follow to compile OpenWRT for different devices?

  • Lets say i have 3 devices, do i have to clone OpenWRT 3 times in 3 different folders and compile OpenWRT this way?

device1/openwrt
device2/openwrt
device3/openwrt

  • Or, can i simply clone OpenWRT 1 time and when i want to compile for a specific device, specify the "config" file for device1 for example...etc. This approach looks to be more problematic if the devices are very different (patches) but uses much less ssd space.

devices/openwrt
make menuconfig (specify config-device1, for example)

I have cloned OpenWRT from git, and what i did was to create local branches for different devices names. When i want to work on device1 for example, i simply checkout device1 branch. I am not sure if this would be the best practice for this.

Thanks.

1 Like

Some use this, personally I use different buildroot trees.

1 Like

I use git worktree and a common download directory. One worktree for the source, a nested one for the env. If you only build one architecture (“ath79”, for example) env is probably enough.

1 Like

@anomeome i have used buildroot long time in the past but only once; therefore, i am not really familiar with having a working buildroot trees environment. I could do a research but it would take a little too much time for now. My understanding is, to download and install buildroot (debian), setup trees, and clone openwrt on each tree, the download directory can be shared and could be set in .bashrc. From there, i could compile openwrt for any device i need. Wouldn't this approach take a lot of SSD space though? and isn't this the same as doing git clone openwrt on different folders without the need of buildroot?

@jeff I will try git worktree. I will look up how to share the download directory. One worktree for the main openwrt source, nested env, a common download directory, another nested env for each new devices arch. I would probably have several devices in the future.
/home/username/openwrt/
/home/username/openwrt/scripts/env new device-name

  • in this new device-name env, ./files folder and .config file are stored.

I can now switch between different environments with a simple clone of openwrt, saving SSD space. Lets say, i have to patch wireless files to allow a specific device arch to connect to the internet, will this patching procedure affect other devices that do not need a patch ?
I guess, like you were saying, I would probably only need one env if the arch is the same across devices with the same arch. But, the problem is that I will have different devices arch, how can i proceed in this case?

Thank you both

git worktree lets you share one clone of the upstream OpenWrt repo(s) and all branches you create across multiple checkout directories. That way you only need to fetch once. For me it’s more about being able to share branches across all of them than disk space.

Different devices can be handled with branches or by the arch-specific features of the build system itself. I typically have at least one active development branch and a “production” branch for each device I’m working with in both the main repo as well as its “env” (config and files). I name the config env/dot.config so I can see it easily. Using worktrees means I can easily rebase, merge, diff, cherry-pick, or things like git log master ^my-branch (on master and not on my-branch) easily.

1 Like