OpenWrt Forum Archive

Topic: Compiled the rt73 driver, but EXTRA_CFLAGS required

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

Hi,

I created a new package for the (legacy) rt73 driver from rt2x00.serialmonkeys.org using the rt2570 Makefile as a basis. After some tweeking got it to compile (for brcm47xx-2.6) and it actually works too!

The thing was that I had to manually add "EXTRA_CFLAGS" with a lot of options in order to make it compile. The rt2570 did not have it but somehow it was not required there.

Any tips for avoiding this?

So here's the "packages/rt73/Makefile":

PKG_NAME:=rt73
PKG_VERSION:=cvs-2007051515
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/rt2x00
PKG_MD5SUM:=b254540060fe704bfa7199fb8f606ddb

include $(INCLUDE_DIR)/package.mk

define KernelPackage/rt73
  SUBMENU:=Wireless Drivers
  TITLE:=Driver for ralink usb wireless chipsets
  DEPENDS:=@LINUX_2_6 @USB_SUPPORT +wireless-tools
  DESCRIPTION:=\
        This package contains a driver for ralink rt73 usb chipsets.
  URL:=http://rt2x00.serialmonkey.com/
  VERSION:=$(LINUX_VERSION)+$(PKG_VERSION)-$(BOARD)-$(PKG_RELEASE)
  FILES:= \
                $(PKG_BUILD_DIR)/Module/rt73.$(LINUX_KMOD_SUFFIX)
  AUTOLOAD:=$(call AutoLoad,50,rt73)
endef

define Build/Compile
        $(MAKE) -C "$(PKG_BUILD_DIR)/Module" \
                CC="$(TARGET_CC)" \
                EXTRA_CFLAGS="-D__KERNEL__ -I/home/user/buildroot/trunk/build_mipsel/linux-2.6-brcm47x x/linux-2.6.19.2/include -Wall -Wstrict-prototypes -Wno-trigraphs -Os -fno-strict-aliasing -fno-common  -fno-builtin-sprintf -fomit-frame-pointer   -funit-at-a-time -I /home/user/buildroot/trunk/build_mips el/linux-2.6-brcm47xx/linux-2.6.16.2/include/asm/gcc -G 0 -mno-abicalls -fno-pic -pipe  -finline-limit =100000 -mabi=32 -march=mips32 -Wa,-32 -Wa,-march=mips32 -Wa,-mips32 -Wa,--trap -DMODULE -mlong-calls -fno-common -I. -nostdinc -iwithprefix include" \
                LD="$(TARGET_CROSS)ld" \
                ARCH="$(LINUX_KARCH)" \
                PWD="$(PKG_BUILD_DIR)/Module" \
                KERNDIR="$(LINUX_DIR)" \
                PATCHLEVEL="$(patsubst 2.%,%,$(KERNEL))"
endef

$(eval $(call KernelPackage,rt73))

The makefile below works for me. You have to manually fix the PKG_BUILD_DIR and PKG_MD5SUM.

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

PKG_NAME:=rt73
PKG_VERSION:=cvs-daily
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://rt2x00.serialmonkey.com/
PKG_MD5SUM:=a5f08e33cd4115129cbe811f697e0af1

PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-cvs-2007052116

include $(INCLUDE_DIR)/package.mk

define KernelPackage/rt73
  SUBMENU:=Wireless Drivers
  TITLE:=Driver for ralink usb wireless chipsets
  DEPENDS:=@LINUX_2_6 @USB_SUPPORT +wireless-tools
  DESCRIPTION:= \
    This package contains a driver for ralink rt73 usb chipsets.
  URL:=http://rt2x00.serialmonkey.com/
  VERSION:=$(LINUX_VERSION)+$(PKG_VERSION)-$(BOARD)-$(PKG_RELEASE)
  FILES:= \
    $(PKG_BUILD_DIR)/Module/rt73.$(LINUX_KMOD_SUFFIX)
  AUTOLOAD:=$(call AutoLoad,50,rt73)
endef

define Build/Compile
    $(MAKE) -C $(LINUX_DIR) \
        ARCH="$(LINUX_KARCH)" \
        CROSS_COMPILE="$(TARGET_CROSS)" \
        PATCHLEVEL="$(LINUX_PATCHLEVEL)" \
        KERNDIR="$(LINUX_DIR)" \
        SUBDIRS="$(PKG_BUILD_DIR)/Module" \
        modules
endef

$(eval $(call KernelPackage,rt73))
ubuntu@OpenWrt-DevEnv:~/brcm47xx-2.6$ du -ah build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/
4,0K    build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/etc/modules.d/50-rt73
8,0K    build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/etc/modules.d
12K     build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/etc
320K    build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/lib/modules/2.6.19.2/rt73.ko
324K    build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/lib/modules/2.6.19.2
328K    build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/lib/modules
332K    build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/lib
4,0K    build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/CONTROL/control
4,0K    build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/CONTROL/postinst
12K     build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/CONTROL
360K    build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73
364K    build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/
ubuntu@OpenWrt-DevEnv:~/brcm47xx-2.6$
ubuntu@OpenWrt-DevEnv:~/brcm47xx-2.6$ ll -h bin/packages/kmod-rt73_2.6.19.2+cvs-daily-brcm47xx-1_mipsel.ipk 
-rw-r--r-- 1 ubuntu ubuntu 135K 2007-05-22 00:40 bin/packages/kmod-rt73_2.6.19.2+cvs-daily-brcm47xx-1_mipsel.ipk
ubuntu@OpenWrt-DevEnv:~/brcm47xx-2.6$

buildlog:

ubuntu@OpenWrt-DevEnv:~/brcm47xx-2.6$ make package/rt73-{clean,compile} V=99
make -C package rt73-clean
make[1]: Entering directory `/home/ubuntu/brcm47xx-2.6/package'
make -C rt73 clean
make[2]: Entering directory `/home/ubuntu/brcm47xx-2.6/package/rt73'
rm -f /home/ubuntu/brcm47xx-2.6/bin/packages/kmod-rt73_*
make[2]: Leaving directory `/home/ubuntu/brcm47xx-2.6/package/rt73'
make[1]: Leaving directory `/home/ubuntu/brcm47xx-2.6/package'
make -C package rt73-compile
make[1]: Entering directory `/home/ubuntu/brcm47xx-2.6/package'
make -C wireless-tools compile
make[2]: Entering directory `/home/ubuntu/brcm47xx-2.6/package/wireless-tools'
make[2]: `compile' is up to date.
make[2]: Leaving directory `/home/ubuntu/brcm47xx-2.6/package/wireless-tools'
make -C rt73 compile
find: /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116: No such file or directory
make[2]: Entering directory `/home/ubuntu/brcm47xx-2.6/package/rt73'
gzip -dc /home/ubuntu/brcm47xx-2.6/dl/rt73-cvs-daily.tar.gz | /bin/tar -C /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/.. -xf -
ls: ./patches: No such file or directory
touch /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/.prepared_d7b2276b15bbde3ce7b306e882c5656e
(cd /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/./; if [ -x ./configure ]; then AR=mipsel-linux-uclibc-ar AS="ccache mipsel-linux-uclibc-gcc -c -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time" LD=mipsel-linux-uclibc-ld NM=mipsel-linux-uclibc-nm CC="ccache mipsel-linux-uclibc-gcc" GCC="ccache mipsel-linux-uclibc-gcc" CXX=mipsel-linux-uclibc-g++ RANLIB=mipsel-linux-uclibc-ranlib STRIP=mipsel-linux-uclibc-strip OBJCOPY=mipsel-linux-uclibc-objcopy OBJDUMP=mipsel-linux-uclibc-objdump CFLAGS="-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -I/home/ubuntu/brcm47xx-2.6/staging_dir_mipsel/usr/include -I/home/ubuntu/brcm47xx-2.6/staging_dir_mipsel/include" CXXFLAGS="-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -I/home/ubuntu/brcm47xx-2.6/staging_dir_mipsel/usr/include -I/home/ubuntu/brcm47xx-2.6/staging_dir_mipsel/include" CPPFLAGS="-I/home/ubuntu/brcm47xx-2.6/staging_dir_mipsel/usr/include -I/home/ubuntu/brcm47xx-2.6/staging_dir_mipsel/include -I/home/ubuntu/brcm47xx-2.6/staging_dir_mipsel/usr/include -I/home/ubuntu/brcm47xx-2.6/staging_dir_mipsel/include" LDFLAGS="-L/home/ubuntu/brcm47xx-2.6/staging_dir_mipsel/usr/lib -L/home/ubuntu/brcm47xx-2.6/staging_dir_mipsel/lib" PKG_CONFIG_PATH="/home/ubuntu/brcm47xx-2.6/staging_dir_mipsel/usr/lib/pkgconfig" PKG_CONFIG_LIBDIR="/home/ubuntu/brcm47xx-2.6/staging_dir_mipsel/usr/lib/pkgconfig"  ./configure --target=mipsel-linux --host=mipsel-linux --build=i486-linux-gnu --program-prefix="" --program-suffix="" --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var --mandir=/usr/man --infodir=/usr/info --disable-nls ; fi; )
touch /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/.configured
make -C /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/linux-2.6.19.2 ARCH="mips" CROSS_COMPILE="mipsel-linux-uclibc-" PATCHLEVEL="" KERNDIR="/home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/linux-2.6.19.2" SUBDIRS="/home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module" modules
make[3]: Entering directory `/home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/linux-2.6.19.2'
  CC [M]  /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/rtmp_main.o
  CC [M]  /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/mlme.o
  CC [M]  /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/connect.o
  CC [M]  /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/rtusb_bulk.o
  CC [M]  /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/rtusb_io.o
  CC [M]  /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/sync.o
  CC [M]  /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/assoc.o
  CC [M]  /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/auth.o
  CC [M]  /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/auth_rsp.o
  CC [M]  /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/rtusb_data.o
  CC [M]  /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/rtmp_init.o
  CC [M]  /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/sanity.o
  CC [M]  /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/rtmp_wep.o
  CC [M]  /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/rtmp_info.o
  CC [M]  /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/rtmp_tkip.o
  CC [M]  /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/wpa.o
  CC [M]  /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/md5.o
  LD [M]  /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/rt73.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/rt73.mod.o
  LD [M]  /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/rt73.ko
make[3]: Leaving directory `/home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/linux-2.6.19.2'
make[3]: Entering directory `/home/ubuntu/brcm47xx-2.6/package/rt73'
make[3]: Leaving directory `/home/ubuntu/brcm47xx-2.6/package/rt73'
touch /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/.built
mkdir -p /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/CONTROL
echo "Package: kmod-rt73" > /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/CONTROL/control
echo "Version: 2.6.19.2+cvs-daily-brcm47xx-1" >> /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/CONTROL/control
( DEPENDS='kernel (=2.6.19.2-brcm47xx-1)'; for depend in +wireless-tools; do DEPENDS=${DEPENDS:+$DEPENDS, }${depend##+}; done; echo "Depends: $DEPENDS"; echo "Source: package/rt73"; echo "Section: kernel"; echo "Priority: optional"; echo "Maintainer: OpenWrt Developers Team <openwrt-devel@openwrt.org>"; echo "Architecture: mipsel"; echo -n "Description: "; getvar V_Package_kmod_rt73_description | sed -e 's,^[[:space:]]*, ,g'; ) >> /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/CONTROL/control
chmod 644 /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/CONTROL/control
(cd /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/CONTROL; var2file "V_Package_kmod_rt73_conffiles" conffiles; var2file "V_Package_kmod_rt73_preinst" preinst; var2file "V_Package_kmod_rt73_postinst" postinst; var2file "V_Package_kmod_rt73_prerm" prerm; var2file "V_Package_kmod_rt73_postrm" postrm; )
mkdir -p /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/lib/modules/2.6.19.2
cp -fpR -L /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/Module/rt73.ko /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/lib/modules/2.6.19.2/
export modules=; add_module() { mkdir -p /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/etc/modules.d; ( for mod in $2; do getvar mod; done ) > /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/etc/modules.d/$1-rt73; modules="${modules:+$modules }$1-rt73"; }; add_module 50 "rt73"; if [ -n "$modules" ]; then mkdir -p /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/etc/modules.d; echo "#!/bin/sh" > /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/CONTROL/postinst; echo "[ -z \"\$IPKG_INSTROOT\" ] || exit 0" >> /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/CONTROL/postinst; echo ". /etc/functions.sh" >> /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/CONTROL/postinst; echo "load_modules $modules" >> /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/CONTROL/postinst; chmod 0755 /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/CONTROL/postinst; fi
mkdir -p /home/ubuntu/brcm47xx-2.6/bin/packages
find /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73 -name CVS   | xargs -r rm -rf
find /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73 -name .svn  | xargs -r rm -rf
find /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73 -name '.#*' | xargs -r rm -f
NM="mipsel-linux-uclibc-nm" STRIP="/home/ubuntu/brcm47xx-2.6/staging_dir_mipsel/bin/sstrip" STRIP_KMOD="mipsel-linux-uclibc-strip --strip-unneeded --remove-section=.comment" /home/ubuntu/brcm47xx-2.6/scripts/rstrip.sh /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73
rstrip.sh: /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73/lib/modules/2.6.19.2/rt73.ko:relocatable
ipkg-build -c -o 0 -g 0 /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73 /home/ubuntu/brcm47xx-2.6/bin/packages
Packaged contents of /home/ubuntu/brcm47xx-2.6/build_mipsel/linux-2.6-brcm47xx/rt73-cvs-2007052116/ipkg/kmod-rt73 into /home/ubuntu/brcm47xx-2.6/bin/packages/kmod-rt73_2.6.19.2+cvs-daily-brcm47xx-1_mipsel.ipk
make[2]: Leaving directory `/home/ubuntu/brcm47xx-2.6/package/rt73'
make[1]: Leaving directory `/home/ubuntu/brcm47xx-2.6/package'
ubuntu@OpenWrt-DevEnv:~/brcm47xx-2.6$

(Last edited by forum2006 on 22 May 2007, 00:20)

Thanks, your makefile works for me too.

Hi is it possible that you can make an ipkg of this driver and put it online.

I have looked into doing this myself but its to hard for me. :-)

The discussion might have continued from here.