I can't compile the kernel module I wrote myself

I had just started studying and I was having some difficulties


here is Makefile

I need some help, thank you all for your pointers.

My two cents:

  • Do not post screenshots of code or messages; copy-and-paste the text.
  • Post the complete error message, not just the last lines.

Your top screenshot shows LEDE. Please try building with the latest (OpenWrt 23.05 or current snapshot), as the old versions are no longer supported)

This is an error message

touch /home/qwh/wwwwwwwwwwwwww/lede/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/hello_kernel/.configured_68b329da9893e34099c7d8ad5cb9c940
make[2]: *** No rule to make target '/home/qwh/wwwwwwwwwwwwww/lede/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/linux-5.15.145/.config', needed by '/home/qwh/wwwwwwwwwwwwww/lede/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/hello_kernel/.built'.  Stop.
make[2]: Leaving directory '/home/qwh/wwwwwwwwwwwwww/lede/package/kernel/text1'
time: package/kernel/text1/compile#0.28#0.10#0.36
    ERROR: package/kernel/text1 failed to build.
make[1]: *** [package/Makefile:116: package/kernel/text1/compile] Error 1
make[1]: Leaving directory '/home/qwh/wwwwwwwwwwwwww/lede'
make: *** [/home/qwh/wwwwwwwwwwwwww/lede/include/toplevel.mk:231:package/kernel/text1/compile] 错误 2

This is the content of the Makefile

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

PKG_NAME:=hello_kernel

include $(INCLUDE_DIR)/package.mk

PKG_AUTOLOAD:=hello_kernel
RSTRIP:=:

define KernelPackage/hello_kernel
  SECTION:=myapps
  CATEGORY:=myapps
  TITLE:=hello kernel
  FILES:=$(PKG_BUILD_DIR)/hello_kernel.ko 
  DEPENDS:=+kmod-ipt-conntrack
  KCONFIG:=
  AUTOLOAD:=$(call AutoLoad,0,$(PKG_AUTOLOAD))
endef

define KernelPackage/hello_kernel/description
  hello kernel
endef

MAKE_OPTS:= \
	$(KERNEL_MAKE_FLAGS) \
	M="$(PKG_BUILD_DIR)" \
	EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
	$(EXTRA_KCONFIG)

define Build/Compile
	$(MAKE) -C "$(LINUX_DIR)" \
		$(MAKE_OPTS) \
		modules
endef

$(eval $(call KernelPackage,hello_kernel))

I see, I'll do it the next time I ask for help

I got the source code from GitHub, maybe just the name LEDE

Where specifically? Did it come from the official OpenWrt git?

Maybe it would be best to follow this:
https://openwrt.org/docs/guide-developer/toolchain/use-buildsystem

1 Like

I have never build a unique kernel.
But you have only at best defined a kernel package at this point.

Can’t you start with something smaller and easier like a flashing led so you at least get the basics working?

I can guarantee you will have to do more settings than that for a new kernel. You can look at the commits of new kernels in the main snapshot.

6.6 is very new so you don’t have to dig so deep in the commits to find the start.

You also need to make some hardware use it. And do a lot of patches to make it openwrt unique and fit to openwrt.

What kernel are you building that we don’t already have since we are running 3 or 4 different kernels right now if I counted it right.

git clone https://github.com/coolsnowwolf/lede
I've successfully compiled the firmware and burned it into my router so far, and it's working fine

What I want to do at the moment is like you said, create a kernel module, like the led lights you said. I've successfully experimented with this kernel module on the virtual machine ubuntu, so I'll think something is wrong with my Makefile

This appears to be a fork from coolsnowwolf and is not part of the official OpenWrt releases. The good news is that the user does appear to be a member of OpenWrt forums. But the bad news is that they haven't been on here in about a year (although it is possible that they would get a notification if you ping them). The other consideration is that this fork is using LEDE (17.01) which is entirely unsupported in mainline OpenWrt. Therefore, if you need help, you need to reach out to the maintainer via their github or user account here.

Okay, I got it

No, a kernel change isn’t like making a small isolated package that make something blink.

It is like comparing changing the engine in a car to a completely new engine model and expect it to fit right away compared to mound an extra full beam light.

You can’t “only make a kernel package” and expect it to work.

But still, if you want something newer than 17.01 we have at least kernel (5.4), 5.15, 6.1 and 6.6 running and supported at this time. So there is probably easier for you to move a device you have to the latest kernel we use than to move some old 17.01 version to a kernel we already have running.

I see what you mean, thank you for your answer, it helped me a lot