How to build exactly the same binary as provided by OpenWrt?

This questions was asked many times, but I still cannot find an answer to it.

Part 1: I want to build myself exactly the same file
https://downloads.openwrt.org/releases/22.03.0/targets/ipq806x/generic/openwrt-22.03.0-ipq806x-generic-tplink_ad7200-squashfs-sysupgrade.bin

I retrieved the OpenWRT source code from git by downloading the .zip file for 22.03.0
After that I copied https://downloads.openwrt.org/releases/22.03.0/targets/ipq806x/generic/config.buildinfo to .config and ran 'make menuconfig' to select my target AD7200.

Finally 'make world' and voila everything is built, but the linux version is 5.10.143, while the OpenWRT download repository has it 5.10.138.

How can I specify the Linux version for my build?

Part 2: If I download https://downloads.openwrt.org/releases/22.03.0/targets/ipq806x/generic/openwrt-imagebuilder-22.03.0-ipq806x-generic.Linux-x86_64.tar.xz
and use it to build a default image for a given profile:

make image PROFILE=tplink_ad7200

Should I get the same checksum on the binary? Obviously I don't, but why?

Look this: https://github.com/openwrt-xiaomi/openwrt/commit/d589e017db90ab27d7a0fcef6e10c647d18cd04e
This patch replaces the value of the vermagic.

Also look this: https://github.com/openwrt-xiaomi/builder
Very important for FW compatibility: https://github.com/openwrt-xiaomi/builder/blob/596e4adf86ce7ecb96517e7e83229f51daacd6b2/_base.config#L6-L11

Hi
My guess is that you have downloaded a master trunk snapshot code, that is up to date to kernel 5.10.143.
To create a 22.03.0, just use the right image builder.
https://downloads.openwrt.org/releases/22.03.0/targets/ipq806x/generic/openwrt-imagebuilder-22.03.0-ipq806x-generic.Linux-x86_64.tar.xz
If you build using the default .config, you should have the same image that the one provided by OpenWrt, and a 5.10.138 kernel.

It's not just the kernel version that affects compatibility. Compatibility is also affected by the value of vermagic.

1 Like

Why this vermagic can not be included in make menuconfig in the official OpenWRT source code? (I guess the patches mentioned are only for Xiaomi branch)

The vermagic value is generated dynamically on every build of the project.

This patch is universal.

My point, why is it dynamic? Why a user can not have a choice between dynamic or static?