I'm very new in Openwrt-based development. I need to write a custom kernel module that will use Netfilter. I've previously written kernel modules for ubuntu. But I don't even know how to start for OpenWrt. I just wrote a basic Hello World-type kernel module and tried to compile it. But I couldn't do that, as build-essential files ain't there. And, so I got:
make -C /lib/modules/5.10.146/build M=/root/nf modules
make: *** /lib/modules/5.10.146/build: No such file or directory. Stop.
make: *** [Makefile:4: all] Error 2
Writing a linux kernel is the same for any distro as long as you consider compiling from source. The only difference might be the "build system" or especially for OpenWrt, the fact that most of the time there is cross-compiling involved.
Create your own working OpenWrt image for your target and take it from there. For debugging your code it’s almost a necessity to have serial acccess to your device and be familiar how to recover from a soft brick.
Since you said you were developing kernel modules before, but didn’t find the wiki linked, maybe familiarize yourself with the basics I just mentioned before attending to write (or port) other modules to “OpenWrt”.
Thank you. I've set up the build system. And tried to make the kernel driver that you linked here but got this:
Makefile:17: /package.mk: No such file or directory
make: *** No rule to make target '/package.mk'. Stop.
Is every kernel module a package? Can't I write a kernel module and generate the .ko by cross-compilation and take the .ko file and load it to the real device?
FYI, my RPi device is running an image alredy.