How to reliably cross-compile Ralink drivers (CFLAGS, ccflags-y etc)

Hello,
I’ve browsed the group looking for cross-compiling Ralink WIFI drivers for the BeagleBoard xM or other Beagle platforms, but couldn’t find a good guide on this.

I need to cross-compile the Ralink 5370 staging drivers (DPO_RT5572_LinuxSTA_2.6.1.3_20121022) from a Ubuntu host on a BBxM with custom Kernel (this: https://ccrma.stanford.edu/~eberdahl/Satellite/). I’ve been given the kernel sources (it’s 3.2.30-x4) and I already succeeded in compiling a Realtek USB dongle kernel module (based on rtl8192cu). My toolchain is based on code sourcery arm-none-linux-gnueabi

However, differently from the Realtek one, the Ralink package has a ugly makefile and thus:
1- if I leave the CFLAGS to the default it will go for normal x86 compile and the arm gcc toolchain won’t recognize x86 related flags (of course)
2- If I attempt to change the CFLAGS, I get the following error:

make[1]: Entering directory `/mnt/DATA/UNIVPM/TECHNICAL/beagleboard/SatelliteCCRMA/SatelliteCCRMA-Berdahl-Kernel-3.2.30-x14_img1.0.1’
scripts/Makefile.build:49: *** CFLAGS was changed in “/mnt/DATA/UNIVPM/TECHNICAL/beagleboard/ZZRALINK2012/DPO_RT5572_LinuxSTA_2.6.1.3_20121022/os/linux/Makefile”. Fix it to use ccflags-y. Stop.

I’ve gone through reading about ccflags-y on the kernel docs, but couldn’t figure out how to apply this here, and on the other side, I can just guess what gcc flags are good to compile this driver on the beagle (e.g. march=armv7-a) but I’m not expert enough to guess them all right. It will take months to guess them ok.

Some insight on this or past experience would be helpful.
Thanks, L

Hello, just wanted to bump this topic.
I think this is of general use: how to compile modules for your beagle against a specific kernel version without messing with the CFLAGS?

Hey all,

I don’t know if this helps, but I have been documenting the build of modules for the MT7601U and these are the steps I’ve taken. They are unclear, unrefined, unorganized, and quite possibly unintelligible, but since this question seems to be asked a lot and hasn’t been answered (I had to figure this out all my self :wink: I thought I would post my steps: