OpenWrt Forum Archive

Topic: How to add new kmod package to buildroot

The content of this topic has been archived on 4 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi Guys,

I try to add new kmod packege to buildroot but the package creation does not work. sad
I read the next documents: 1, 2, 3.

I can compile the module wiht the next command:

make module KERNDIR=/usr/src/whiterussian/openwrt/build_mipsel/linux-2.4-brcm/linux-2.4.30 \
                    PATCHLEVEL=4 \
                    CC=/usr/src/whiterussian/openwrt/staging_dir_mipsel/bin/mipsel-linux-uclibc-gcc \
                    LD=/usr/src/whiterussian/openwrt/staging_dir_mipsel/bin/mipsel-linux-uclibc-ld

If I copy the rt2570.o to the router and load with insmod then the device works fine.

I created an rt2570 directory in openwrt/target/linux/package directory.
I made a Make file:

include $(TOPDIR)/rules.mk

PKG_NAME:=rt2570
PKG_VERSION:=1.1.0-b2
PKG_RELEASE:=1
PKG_MD5SUM:=f4131d670920a878b4d4a0f5d4d8b93a

PKG_SOURCE_URL:=@SF/rt2400
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_CAT:=zcat

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)

include $(TOPDIR)/package/rules.mk

$(eval $(call PKG_template,KMOD_RT2570,kmod-rt2570,$(LINUX_VERSION)$(BOARD)+$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH),kern
el ($(LINUX_VERSION)-$(BOARD)-$(KERNEL_RELEASE))))

$(PKG_BUILD_DIR)/.configured:
        touch $@

$(PKG_BUILD_DIR)/.built:
        $(MAKE) -C $(PKG_BUILD_DIR)/Module \
                PATCHLEVEL=4 \
                KERNDIR="$(KERNEL_DIR)" \
                LD="$(KERNEL_CROSS)ld" \
                CC="$(KERNEL_CROSS)gcc"
        touch $@

$(IPKG_KMOD_RT2570):
        mkdir -p $(IDIR_KMOD_RT2570)/lib/modules/$(LINUX_VERSION)
        cp -fpR $(PKG_BUILD_DIR)/Module/rt2570.o \
                $(IDIR_KMOD_RT2570)/lib/modules/$(LINUX_VERSION)/
        $(IPKG_BUILD) $(IDIR_KMOD_RT2570) $(PACKAGE_DIR)

and a Config.in:

config BR2_PACKAGE_KMOD_RT2570
        prompt "kmod-rt2570 - RaLink 2570 Wifi driver"
        tristate
        default m
        help
          Driver for RaLink 2570 802.11g USB Chipset

Afterthat I added the necessary lines to the openwrt/target/linux/package/Makefile and openwrt/target/linux/package/Config.in

part of Makefile:

package-$(BR2_PACKAGE_KMOD_MADWIFI) += madwifi
package-$(BR2_PACKAGE_KMOD_MINI_FO) += mini_fo
package-$(BR2_PACKAGE_KMOD_RT2570) += rt2570
package-y += openwrt

package-$(BR2_PACKAGE_KMOD_WLCOMPAT) += wlcompat
wlcompat-compile: openwrt-compile

all: compile install

part of Config.in

source "target/linux/package/wlcompat/Config.in"
source "target/linux/package/madwifi/Config.in"
source "target/linux/package/mini_fo/Config.in"
source "target/linux/package/fuse/Config.in"
source "target/linux/package/shfs/Config.in"
source "target/linux/package/nozomi/Config.in"
source "target/linux/package/switch/Config.in"
source "target/linux/package/openswan/Config.in"
source "target/linux/package/rt2570/Config.in"

If I use the make menuconfig command in the openwrt directory then the new package appears as
Kernel Configuration / Device Support  --->  <M> kmod-rt2570 - RaLink 2570 Wifi driver .

I select that as module and save the new config. Afterthat I try to compile the firmware again, then  in the output of make I do not find anything about the new package and it will be not created.

Why have not been compiled my new package? Are there any other files to edit?

hi,
I am using the Kernel 2.6.19.2, for WL-500B. I would like to add my USB card WUSB54G support too. And compile driver rt2570-1.1.0-b2.tar.gz using below command:
make module KERNDIR=/home/alex/work2/openwrt/kamikaze/trunk/build_mipsel/linux-2.6-brcm47xx/linux-2.6.19.2 \
                    PATCHLEVEL=6 \
                    CC=/home/alex/work2/openwrt/kamikaze/trunk/staging_dir_mipsel/bin/mipsel-linux-uclibc-gcc \
                    LD=/home/alex/work2/openwrt/kamikaze/trunk/staging_dir_mipsel/bin/mipsel-linux-uclibc-ld
And then got an errror like this,
make[1]: Entering directory `/home/alex/work2/openwrt/kamikaze/trunk/build_mipsel/linux-2.6-brcm47xx/linux-2.6.19.2'
  CC [M]  /home/alex/work2/openwrt/kamikaze/mypackages/rt2570-1.1.0-b2/Module/rtusb_main.o
cc1: error: unrecognized command line option "-maccumulate-outgoing-args"
make[2]: *** [/home/alex/work2/openwrt/kamikaze/mypackages/rt2570-1.1.0-b2/Module/rtusb_main.o] Error 1
make[1]: *** [_module_/home/alex/work2/openwrt/kamikaze/mypackages/rt2570-1.1.0-b2/Module] Error 2
make[1]: Leaving directory `/home/alex/work2/openwrt/kamikaze/trunk/build_mipsel/linux-2.6-brcm47xx/linux-2.6.19.2'
rt2570.ko failed to build!

Looks like CFLAGS is wrong.
Can anybody help me to solve this issue?

Thanks
Alex

OK, I got the way to build it.
1) Go to the folder trunk/package/rt2570
2) Modify the line   
  DEPENDS:=@LINUX_2_4 @USB_SUPPORT +wireless-tools
TO:
  DEPENDS:=@LINUX_2_6 @USB_SUPPORT +wireless-tools
3) make menuconfig, will find an option in Kernel Module --> Wireless Drivers --> <M> Kmod-rt2570
4) make package/rt2570-compile V=99

late, I will test if It can work on my router.

The discussion might have continued from here.