TLDR
I have a recipe, based on @arinc9's instructions that will produce a kernel package with the same magic number as the official release, and does not require patches:
git clone https://git.openwrt.org/openwrt/openwrt.git
cd openwrt
git checkout v21.02.1
rm -rf package/kernel/{mac80211,ath10k-ct,mt76,rtl8812au-ct}
git checkout d1100c76b33ff68c6db0f5fa31a26532bdbb15c4 -- package/kernel/{mac80211,ath10k-ct,mt76,rtl8812au-ct}
rm -f package/kernel/mac80211/patches/ath/551-ath9k_ubnt_uap_plus_hsr.patch
./scripts/feeds update -a -f && ./scripts/feeds install -a -f
./scripts/feeds uninstall batman-adv
wget 'https://downloads.openwrt.org/releases/21.02.1/targets/mvebu/cortexa9/config.buildinfo'
cp config.buildinfo .config
make defconfig
make -j8 download && make -j8 BUILD_LOG=1
Detailed Explanation regarding the kernel vermagic hash
batman-adv fails to compile because of header mixup involving a mac80211-installed header. It could be trivially patched, but the purpose of the build is to allow openwrt package installation, so I don't imagine it would be much of a problem.
You can customize the configuration with make menuconfig
, but beware that some packages will change the kernel config, changing the vermagic
number. The value is computed at the beginning of make target/compile
. So if you want to check if the configuration changes its value, run make target/compile
, and wait a bit for the sources to be unpacked, and the .config files to be generated. It is saved to build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/linux-mvebu_cortexa9/linux-5.4.154/.vermagic
.
Inclusion or exclusion of a package may change the hash. Notably, excluding the ath10k-ct, and other wireless driver packages will change the hash. The same happens if you don't install a feed. Luckily, omitting batman-adv did not alter the hash, so I took the shortcut and just removed it.
I'm just speculating, as my wrt3200s are used in production, and I can't just test things at will, but it may be possible to use the official image, and then just force-downgrade the mac80211 packages (kmod-cfg80211, kmod-mwifiex-sdio, kmod-mac80211) from a local build that shares the same magicver.
Edit: I'm adding kmod-mwlwifi to the list of packages that need to come from the local build. One of the functions has apparently changed name, judging by the difference when running strings /lib/modules/5.4.154/mwlwifi.ko
:
--- strings 2021-11-17 16:07:23.206678891 -0300
+++ strings.new 2021-11-17 16:07:48.576678480 -0300
... minor binary stuff skipped.
@@ -934,10 +934,10 @@
__dev_kfree_skb_any
devm_ioremap_resource
filp_close
+ieee80211_channel_to_frequency
ieee80211_unregister_hw
cancel_work_sync
ieee80211_beacon_get_tim
-ieee80211_channel_to_freq_khz
skb_copy
__aeabi_uidivmod
ieee80211_hdrlen