Problem creating simple driver

Hi all,

I am trying to create a simple driver (a couple of printk on init/exit for now) but I am having trouble understanding whats going on.

I see that insmod / lsmod utilities are not the busybox ones as there’s a symbolic link to kmodloader (ubox package) and I observe the following behaviour:

  • If I mark my driver as autoload, and recompile the complete binary, the driver will load on boot, and dmesg will show the messages
  • if i remove my driver from /etc/modules.d, it wont be loaded and the following occurs when attempting to do insmod via different means:
    • insmod simple_driver :
      • failed to insert /lib/modules/6.6.108/simple_driver.ko
    • busybox insmod /lib/modules/6.6.108/simple_driver.ko:
      • insmod: can't insert '/lib/modules/6.6.108/simple_driver.ko': Operation not permitted
    • /sbin/kmodloader simple_driver: messages shown in dmesg but not loaded (not shown in lsmod)
      • [ 545.776760] kmodloader: loading kernel modules from simple_driver*
        [ 545.776836] kmodloader: done loading kernel modules from simple_driver*

What i wanted to achieve: perform insmod / rmmod operations on demand so i can debug drivers. This all started when i saw no message on dmesg from this driver nor insmod commands. any hint or idea on what may be wrong would be greatly appreciated as having to recompile the complete binary to test a driver seems a bit of an overkill. Thanks!!!

C file code

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>

static int __init simple_driver_init(void)
{
    printk(KERN_INFO "SimpleDriver: init\n");
    return 0;
}

static void __exit simple_driver_exit(void)
{
    printk(KERN_INFO "SimpleDriver: exit\n");
}

module_init(simple_driver_init);
module_exit(simple_driver_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("my testing");

Here are the makefiles. Outter Makefile

include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/package.mk

PKG_NAME:=simple_driver
PKG_RELEASE:=1

include $(INCLUDE_DIR)/package.mk

define KernelPackage/simple_driver
	CATEGORY:=Kernel modules
	SUBMENU:=Other modules
	TITLE:=Simple Kernel Module Example
	FILES:=$(PKG_BUILD_DIR)/simple_driver.ko
	AUTOLOAD:=$(call AutoLoad,50,simple_driver)
endef

define KernelPackage/simple_driver/description
	A simple kernel module for OpenWrt testing.
endef

define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
	$(CP) ./src/* $(PKG_BUILD_DIR)/
endef

define Build/Compile
$(KERNEL_MAKE) $(PKG_JOBS) \
                $(PKG_MAKE_FLAGS)  \
                M="$(PKG_BUILD_DIR)" \
                modules
				

endef

$(eval $(call KernelPackage,simple_driver))

inner Makefile:

obj-m := simple_driver.o