Kernel version mismatch after building kernel and packages

What I have done so far:
deleted bin directory
make clean
make manuconfig and saved
make

after building (no errors):

~/openwrt/bin/targets/ipq807x/generic$ cat version.buildinfo
r20366-4ad68a1b0f

flashed router with new firmware, verified that version is now as above, however I'm getting an error when installing packages:

Details for package kmod-sched-cake

    Version: 5.15.61-1
    Size: ~15.10 KiB installed
    Dependencies:
        kernel Version incompatible
        kmod-sched-core (64.94 KiB) Not installed

Description

Common Applications Kept Enhanced fq_codel/blue derived shaper

    The installed version of package kernel is not compatible, require 5.15.61-1-cdff54f9… while 5.15.61-1-04b2dda7… is installed.

You can't easily install kmods into private builds. There is a hash/checksum of all kernel options.
See

Thank you for the info. From the page in the link:

## I'm using a self-compiled image
* **Solution #5:** Do not install packages after flashing, but include them in your image.
* **Solution #6:** Compile the packages you want to install after flashing as modules. They will be built, but not included in the image.

Am I not following #6 when building image and packages at the same time? I forgot to specify that I built packages and image at the same time. And, package I'm installing comes from the same openwrt/bin folder.

Solution 6 means that you compile the firmware and the possible extra packages at the same time on the same build run.
Then after having flashing the router and running the firmware you should be able to transfer those package .ipk files to the router and opkg install them.

But it does not mean that that you could

  • Download and install kmods from the public repo into router running your build. (Note that this may also hit you via dependency packages)
  • Install your kmods into a router running the official builds.
  • Install your kmods into router running an older build by you.

In that case it should work.

However, the different hash tells that the kernel and kmod have been compiled during different kernel options.

Ps. Note that the OpenWrt version r20366-4ad68a1b0f is not the hash, but the one in kernel/kmod versions.

That is calculated by all kernel related options and selections.

Could it be that make clean is not removing old packages? What directories can I safely delete before building? I suppose easiest way would be to start fresh but I would prefer to figure out the issue.

Make clean should be enough.

You should be able to delete bin/, tmp/ and build_dir/target... and staging_dir/target...
(But make clean should already do that.)