title: RT5370 SH4 Cross Compile Driver Errors
body: <p>I try to build 2.5.0.3 driver from file <a href="http://www.ralinktech.com/en/04_support/license.php?sn=5016" rel="nofollow">2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO.bz2</a> to RT5370 chipset.</p>
  
  <p>Install STLinux 2.4 under Ubuntu 10.04.4 x32, make under kernel linux-sh4-2.5.32.59_stm24_0211. But I wrote /opt/STM/STLinux-2.2/devkit/sources/kernel/linux-sh4-2.5.32.59_stm24_0211 in path instead of STLinux-2.4, because Makefile have some defects:</p>
  
  <pre><code>install:
  ifeq ($(TARGET), LINUX)
  ifneq (,$(findstring 2.4,$(LINUX_SRC)))
  $(MAKE) -C $(RT28xx_DIR)/os/linux -f Makefile.4 install
  else
  $(MAKE) -C $(RT28xx_DIR)/os/linux -f Makefile.6 install
  endif
  endif
  </code></pre>
  
  <p>The mention in a path 2.4 build a kernel as 2.4 that in my case a mistake.</p>
  
  <p>Wrote in Makefile:</p>
  
  <pre><code>PLATFORM = ST
  ...
  LINUX_SRC = /opt/STM/STLinux-2.2/devkit/sources/kernel/linux-sh4-2.5.32.59_stm24_0211
  CROSS_COMPILE = /opt/STM/STLinux-2.2/devkit/sh4/bin/sh4-linux-
  </code></pre>
  
  <p>In ./os/linux/config.mk wrote:</p>
  
  <pre><code>HAS_WPA_SUPPLICANT=y
  HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y
  CC := sh4-linux-gcc
  LD := sh4-linux-ld
  </code></pre>
  
  <p>Build at run make command. But have the error:</p>
  
  <pre><code>script/Makefile.build:49: *** CFLAGS was changed in "/home/vitaliy/drv_src/os/linux/Makefile". Fix it to use EXTRA_CFLAGS.
  </code></pre>
  
  <p>Founded strings at ./os/linux/config.mk:</p>
  
  <pre><code>ifeq ($(PLATFORM),ST)
  CFLAGS := -D__KERNEL__ -I$(LINUX_SRC)/include -I$(RT28xx_DIR)/include -Wall -O2 -Wundef -Wstrict-prototypes -Wno-trigraphs -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-aliasing -fno-common -fomit-frame-pointer -ffreestanding -m4-nofpu -o $(WFLAGS) 
  export CFLAGS
  endif
  </code></pre>
  
  <p>And change CFLAGS to EXTRA_CFLAGS in them.</p>
  
  <p>Again error:</p>
  
  <pre><code>sh4-linux-gcc: error: -pg and -fomit-frame-pointer are incompatible.
  </code></pre>
  
  <p>Ok. Remove flag -fomit-frame-pointer.</p>
  
  <p>Again error:</p>
  
  <pre><code>error: cpu/cache.h: No such file or directory.
  </code></pre>
  
  <p>In string:</p>
  
  <pre><code>WFLAGS := -DAGGREGATION_SUPPORT -DPIGGYBACK_SUPPORT -DWMM_SUPPORT -DLINUX -Wall -Wstrict-prototypes -Wno-trigraphs
  </code></pre>
  
  <p>Remove flag -DLINUX.</p>
  
  <p>Again error with unknown types (for example: ./os/linux/../../common/crypt_md5.c:638:1: error: unknown type name 'VOID' and so on with types 'UCHAR', 'ULONG' etc).</p>
  
  <p>Second way to build with help of</p>
  
  <p>KBUILD_NOPEDANTIC=1 make without changes in sources files of drivers.</p>
  
  <p>Error in this case too:</p>
  
  <pre><code>./os/linux/../../common/crypt_md5.c:28:23: fatal error: rt_config.h: No such file or directory.
  </code></pre>
  
  <p>What is wrong in my building? Or can I fix sources code and build driver for SH4-platform.</p>
  
  <p>Thank you!</p>