I have a .c file which I want to packetize. I currently have it compiled it directly to the kernel and it works, but I want to create a package with it so I can satisfy OpenWRT standards.
This is the file structure:
├── b43-sprom-driver
│ ├── Makefile
│ └── src
│ ├── b43-sprom-fallback.c
│ └── Makefile
The .c file is just a small driver to create a dummy SPROM for those Broadcom's Wifi chipsets which does not have an SPROM or it can't be read for whatever reason. This .c file has the following dependencies:
#include <linux/bcma/bcma.h>
#include <linux/module.h>
#include <linux/etherdevice.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/mtd/mtd.h>
#include <linux/of_net.h>
#include <linux/of_platform.h>
#include <linux/ssb/ssb.h>
Full file: openwrt/b43-sprom.c at master · openwrt/openwrt (github.com)
The Makefile:
#
# Copyright (C) 2020 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=b43spromdriver
PKG_RELEASE:=1
PKG_LICENSE:=GPL-2.0
PKG_VERSION:=5.15.74-1
PKG_MAINTAINER:=Daniel Huici <danielhuici@hotmail.com>
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/backports-$(PKG_VERSION)
PKG_BUILD_PARALLEL:=1
MAKE_OPTS:= \
EXTRA_CFLAGS="-I$(PKG_BUILD_DIR)/include $(IREMAP_CFLAGS) $(C_DEFINES)" \
KLIB_BUILD="$(LINUX_DIR)" \
MODPROBE=true \
KLIB=$(TARGET_MODULES_DIR) \
KERNEL_SUBLEVEL=$(lastword $(subst ., ,$(KERNEL_PATCHVER))) \
KBUILD_LDFLAGS_MODULE_PREREQ=
include $(INCLUDE_DIR)/package.mk
define KernelPackage/b43-sprom-driver
SECTION:=kernel
SUBMENU:=B43 SPROM Driver 2
TITLE:=B43 SPROM Driver
DEPENDS:=@PCI_SUPPORT +kmod-mac80211 +kmod-lib-cordic \
+kmod-ssb +kmod-bcma
FILES:=$(PKG_BUILD_DIR)/b43-sprom-driver.ko
KCONFIG:= \
CONFIG_BCMA=y \
CONFIG_BCMA_BLOCKIO=y \
CONFIG_BCMA_DRIVER_PCI=y \
CONFIG_BCMA_HOST_PCI=y \
CONFIG_BCMA_HOST_PCI_POSSIBLE=y \
CONFIG_SSB=y\
CONFIG_SSB_B43_PCI_BRIDGE=y \
CONFIG_SSB_BLOCKIO=y \
CONFIG_SSB_DRIVER_PCICORE=y\
CONFIG_SSB_DRIVER_PCICORE_POSSIBLE=y\
CONFIG_SSB_PCIHOST=y\
CONFIG_SSB_PCIHOST_POSSIBLE=y \
CONFIG_SSB_SPROM=y
AUTOLOAD:=$(call AutoLoad,b43-sprom-driver,1)
endef
define KernelPackage/b43-sprom-driver/description
Enable B43 Fallback SPROM Driver
endef
define Build/Compile
+$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" $(KERNEL_MAKE_FLAGS) $(MAKE_OPTS)\
M="$(PKG_BUILD_DIR)" \
modules
endef
$(eval $(call KernelPackage,b43-sprom-driver))
The Makefile inside src folder:
obj-m += b43-sprom-fallback.o
Then I run make menuconfig to select new package, and when I try to compile it, this is what happens:
make[3]: Entering directory '/home/osboxes/openwrt-Arcadyan-VRV9510KWAC23/build_dir/target-mips_24kc_musl/linux-lantiq_xrx200/linux-5.10.155'
CC [M] /home/osboxes/openwrt-Arcadyan-VRV9510KWAC23/build_dir/target-mips_24kc_musl/linux-lantiq_xrx200/backports-5.15.74-1/b43-sprom-fallback.o
MODPOST /home/osboxes/openwrt-Arcadyan-VRV9510KWAC23/build_dir/target-mips_24kc_musl/linux-lantiq_xrx200/backports-5.15.74-1/Module.symvers
WARNING: modpost: missing MODULE_LICENSE() in /home/osboxes/openwrt-Arcadyan-VRV9510KWAC23/build_dir/target-mips_24kc_musl/linux-lantiq_xrx200/backports-5.15.74-1/b43-sprom-fallback.o
ERROR: modpost: "bcma_arch_register_fallback_sprom" [/home/osboxes/openwrt-Arcadyan-VRV9510KWAC23/build_dir/target-mips_24kc_musl/linux-lantiq_xrx200/backports-5.15.74-1/b43-sprom-fallback.ko] undefined!
ERROR: modpost: "ssb_arch_register_fallback_sprom" [/home/osboxes/openwrt-Arcadyan-VRV9510KWAC23/build_dir/target-mips_24kc_musl/linux-lantiq_xrx200/backports-5.15.74-1/b43-sprom-fallback.ko] undefined!
make[4]: *** [scripts/Makefile.modpost:123: /home/osboxes/openwrt-Arcadyan-VRV9510KWAC23/build_dir/target-mips_24kc_musl/linux-lantiq_xrx200/backports-5.15.74-1/Module.symvers] Error 1
make[4]: *** Deleting file '/home/osboxes/openwrt-Arcadyan-VRV9510KWAC23/build_dir/target-mips_24kc_musl/linux-lantiq_xrx200/backports-5.15.74-1/Module.symvers'
make[3]: *** [Makefile:1742: modules] Error 2
make[3]: Leaving directory '/home/osboxes/openwrt-Arcadyan-VRV9510KWAC23/build_dir/target-mips_24kc_musl/linux-lantiq_xrx200/linux-5.10.155'
make[2]: *** [Makefile:67: /home/osboxes/openwrt-Arcadyan-VRV9510KWAC23/build_dir/target-mips_24kc_musl/linux-lantiq_xrx200/backports-5.15.74-1/.built] Error 2
make[2]: Leaving directory '/home/osboxes/openwrt-Arcadyan-VRV9510KWAC23/package/kernel/b43-sprom-driver'
time: package/kernel/b43-sprom-driver/compile#2.01#0.31#2.22
ERROR: package/kernel/b43-sprom-driver failed to build.
Compilation seems to be successful, but I think it's in the linker. The functions 'bcma_arch_register_fallback_sprom' and 'ssb_arch_register_fallback_sprom' are from the kmod-ssb and kmod-bcma packages where has been included as DEPENDS on the Makefile.
Is my approach good? I'm really stuck here, I don't know what to do. I appreciate any kind of help. Thank you!