Multiple firmware images

Is it possible to build several openwrt firmware images for the same device but with different configuration?

i build firmware image for an organization so i put related configuration files in build_root/files/

now i have to remove the files of Org1 and put config files for Org2 and then run make -jxx world to build an image for the second one.

is there a way to put configuration files in build_root/files/org1/, org2/, org3/ .....
and when run build command i get generated images in build_root/bin/targets/......./org1/, org2/, org3/

1 Like

See if Build Environments works for you.

1 Like

As filesystems on OpenWrt images are pretty much always compressed, there is not much alternative to compiling. You need to include the correct files and then compress the lot.

If you has a limited number of devices and they can see each other's settings, (so that all settings can be stored on all devices), the approach from lleachii might work, where you use run-at-first-boot script to set some settings e.g. according to the lan MAC of the device.

Other approach might be to create scripts for copying the next files to files/ and running the compilation again.

That might be speeded up by using the imagebuilder instead of the whole toolchain. I crafted a script for imagebuilder where my files/ are separate from the actual imagebuilder, so that you can just pass the files/ as an argument to the image-cooking command:

That script

  • copies build keys (not important),
  • brands the exact build date/time/version to a file,
  • does the compilation with "../files" as path to "files/": FILES="../files"
  • finally renames/copies the created images and build script itself

cp key-build* openwrt-imagebuilder-qualcommax-ipq807x.Linux-x86_64

cd openwrt-imagebuilder-qualcommax-ipq807x.Linux-x86_64

GETVER=$(grep "^REVISION" include/  | cut -f 2 -d "=" | cut -c "-14")
VersTime=$(date +%Y%m%dT%H%M)
echo "$GETVER built on $VersTime" > ../files/etc/Compile_info.txt

make image \
 PROFILE="dynalink_dl-wrx36" \
 PACKAGES="ccrypt diffutils gdbserver htop irqbalance mtr-nojson nano-full \
  openssh-sftp-server patch tcpdump-mini tree wget-ssl \
  block-mount kmod-usb-storage kmod-fs-cifs kmod-fs-exfat libblkid \
  kmod-fs-ext4 kmod-fs-msdos kmod-fs-ntfs3 kmod-nls-cp437 kmod-nls-iso8859-1 \
  kmod-nls-utf8 hostapd-utils wpad-openssl ca-certificates \
  luci-ssl-openssl \
  luci-app-adblock luci-app-banip luci-app-bcp38 luci-app-commands \
  luci-app-nlbwmon luci-app-opkg luci-app-sqm luci-app-uhttpd \
  luci-app-statistics collectd-mod-conntrack collectd-mod-cpufreq \
  collectd-mod-ping collectd-mod-thermal collectd-mod-uptime \
  kmod-tun luci-proto-wireguard unetd unet-cli \
  iptables-nft ip6tables-nft ipset \
  qosify kmod-sched-bpf \
  -wpad-basic-mbedtls -libustream-mbedtls -libmbedtls" \

[ "$?" -ne 0 ] && echo "Build failed." && exit 1

cp bin/targets/qualcommax/ipq807x/openwrt-qualcommax-ipq807x-dynalink_dl-wrx36.manifest \
cp bin/targets/qualcommax/ipq807x/openwrt-qualcommax-ipq807x-dynalink_dl-wrx36-squashfs-sysupgrade.bin \
grep squash bin/targets/qualcommax/ipq807x/sha256sums \
 > ../dl-wrx36-$GETVER-$VersTime-sha256sums.txt

cd ..

cp \

tar -czf dl-wrx36-$GETVER-$VersTime-files.tar.gz files *sh key*

You can easily modify that approach by having the actual files/ location as an argument to the build function.


thank you. @hnyman

sorry for the late response.

if the compile have to be done over and over for each org.
then i could use sh script to copy files from baths and do builds one after the other


# Configuration
TARGET_DEVICE="HYC-G920"  # Default target device KM08-708H OR HYC-G920 OR DW02-412

# Organization list

# Function to build firmware for an organization
build_organization() {
    local org="$1"
    local snapshot_dir="$CONFIG_DIR/$org/snapshot/$TARGET_DEVICE"

    echo "Copying files from $snapshot_dir to $OPENWRT_FILES_DIR..."
    cp -r "$snapshot_dir"/* "$OPENWRT_FILES_DIR/"

    echo "Building firmware for $org..."
    # Build firmware
    cd "$OPENWRT_BUILD_DIR" || exit
    make -j23 |& tee build_output.log

    # Check if build succeeded
    if grep -q "checksum" build_output.log; then
        echo "Build succeeded"
        echo "Build failed"
        exit 1

    # Move generated *.bin files to organization's bin folder
    mv "$OPENWRT_TARGET_DIR"/*.bin "$CONFIG_DIR/$org/snapshot/bin/"

    # Clean OpenWRT files directory
    echo "Cleaning up OpenWRT files directory..."
    rm -rf "$OPENWRT_FILES_DIR"/*

    echo "Build for $org completed successfully"

# Main script
for org in "${ORG_LIST[@]}"; do
    build_organization "$org"

echo "All organizations built successfully"

Default target device KM08-708H OR HYC-G920 OR DW02-412
for each org. i have either one of these folders that contain config files for a target device.

thank you once again.

i think it will need a script too to switch between env(s)
but thank you for the idea i didn't knew about it before.
i would use it in the feature thank you.

the thing is that there are custom files that are not part of UCI system.
so i have to use /files
Thank you

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.