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

I retrieved the OpenWRT source code from git by downloading the .zip file for 22.03.0
After that I copied 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
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:
This patch replaces the value of the vermagic.

Also look this:
Very important for FW compatibility:

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.
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?