Cannot compile crda for 10.03.1

I know, I know, I'm trying to compile an old and unsupported version, alas upgrading is not an option.
I'm doing some research with older devices and as such I'm stuck with older versions as well. I'm able to create an image using the image builder and this works okay as I wasn't expecting to loose the webui in the process but at least it isn't bricked.
This made me want to be able to test the image before flashing. The target device is a WRT54GL and as such the arch is mipsel. In a later version the Malta target has been added specifically to test such images in Qemu. So I figured to attempt to backport that target, seems like the code base is modular enough to allow this.
So before doing that I want to compile OpenWrt from source just to see if it works before messing with it. I'm running Ubuntu 11.10 in a VM and cloned the OpenWrt archive (https://git.openwrt.org/openwrt/svn-archive/archive.git) that contains the 10.03.1 release (f79d3e781c0dbc2c259ecd4aa8eefb51a1bd28b6). I've copied the .config from the image builder and ran make menuconfig to check if the config actually works. After manually downloading some sources and putting them in the dl dir it starts to compile. But I cannot seem to be able to build crda for some reason.
Below is the output I get when running make package/crda/compile V=99:

make[1]: Entering directory `/home/user/archive'                                                                                                          
make[2]: Entering directory `/home/user/archive/package/wireless-tools'
make[2]: Leaving directory `/home/user/archive/package/wireless-tools'
make[1]: Circular package/iw/compile <- package/mac80211/compile dependency dropped.
make[2]: Entering directory `/home/user/archive/package/libnl-tiny'
make[2]: Leaving directory `/home/user/archive/package/libnl-tiny'
make[2]: Entering directory `/home/user/archive/package/iw'                                                                                               
make[2]: Leaving directory `/home/user/archive/package/iw'       
make[1]: Circular package/mac80211/compile <- package/crda/compile dependency dropped.
make[2]: Entering directory `/home/user/archive/package/mac80211'
WARNING: skipping kmod-ath5k -- package not selected
WARNING: skipping kmod-lib80211 -- package not selected    
WARNING: skipping kmod-libertas-usb -- package not selected             
WARNING: skipping kmod-libertas-sd -- package not selected       
WARNING: skipping kmod-cfg80211 -- package not selected
WARNING: skipping kmod-mac80211 -- package not selected    
WARNING: skipping kmod-p54-common -- package not selected                                                                                                 
WARNING: skipping kmod-p54-pci -- package not selected           
WARNING: skipping kmod-p54-usb -- package not selected
WARNING: skipping kmod-p54-spi -- package not selected               
WARNING: skipping kmod-rt2x00-lib -- package not selected        
WARNING: skipping kmod-rt2x00-pci -- package not selected
WARNING: skipping kmod-rt2x00-usb -- package not selected  
WARNING: skipping kmod-rt2x00-soc -- package not selected                                                                                                 
WARNING: skipping kmod-rt2800-lib -- package not selected        
WARNING: skipping kmod-rt2400-pci -- package not selected
WARNING: skipping kmod-rt2500-pci -- package not selected
WARNING: skipping kmod-rt2500-usb -- package not selected   
WARNING: skipping kmod-rt61-pci -- package not selected
WARNING: skipping kmod-rt73-usb -- package not selected                                                                                                   
WARNING: skipping kmod-rt2800-pci -- package not selected
WARNING: skipping kmod-rt2800-usb -- package not selected                                                                                                 
WARNING: skipping kmod-rtl8180 -- package not selected   
WARNING: skipping kmod-rtl8187 -- package not selected                                                                                                    
WARNING: skipping kmod-zd1211rw -- package not selected  
WARNING: skipping kmod-mac80211-hwsim -- package not selected                                                                                             
WARNING: skipping kmod-ath9k-common -- package not selected
WARNING: skipping kmod-ath9k -- package not selected                                                                                                      
WARNING: skipping kmod-ath9k-htc -- package not selected 
WARNING: skipping kmod-ath -- package not selected                                                                                                        
WARNING: skipping kmod-carl9170 -- package not selected  
WARNING: skipping kmod-b43 -- package not selected
WARNING: skipping kmod-b43legacy -- package not selected
WARNING: skipping kmod-net-libipw -- package not selected
WARNING: skipping kmod-net-ipw2100 -- package not selected
WARNING: skipping kmod-net-ipw2200 -- package not selected
WARNING: skipping kmod-iwlagn -- package not selected            
WARNING: skipping kmod-iwl-legacy -- package not selected            
WARNING: skipping kmod-iwl4965 -- package not selected
WARNING: skipping kmod-iwl3945 -- package not selected             
WARNING: skipping kmod-mwl8k -- package not selected                   
WARNING: skipping kmod-net-hermes -- package not selected       
WARNING: skipping kmod-net-hermes-pci -- package not selected
WARNING: skipping kmod-net-hermes-plx -- package not selected         
WARNING: skipping kmod-net-hermes-pcmcia -- package not selected
make[2]: Leaving directory `/home/user/archive/package/mac80211'                                                                                          
make[2]: Entering directory `/home/user/archive/package/crda'                   
CFLAGS="-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -fhonour-copts -msoft-float  -I/home/user/archive/staging_dir/target-mipsel_uClibc-0.9.30.1/usr/i
nclude/libnl-tiny -D_GNU_SOURCE -I/home/user/archive/staging_dir/target-mipsel_uClibc-0.9.30.1/usr/include -I/home/user/archive/staging_dir/target-mipsel_
uClibc-0.9.30.1/include -I/home/user/archive/staging_dir/toolchain-mipsel_gcc-3.4.6_uClibc-0.9.30.1/usr/include -I/home/user/archive/staging_dir/toolchain
-mipsel_gcc-3.4.6_uClibc-0.9.30.1/include " CXXFLAGS="-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -fhonour-copts -msoft-float  -I/home/user/archive/s
taging_dir/target-mipsel_uClibc-0.9.30.1/usr/include/libnl-tiny -D_GNU_SOURCE -I/home/user/archive/staging_dir/target-mipsel_uClibc-0.9.30.1/usr/include -
I/home/user/archive/staging_dir/target-mipsel_uClibc-0.9.30.1/include -I/home/user/archive/staging_dir/toolchain-mipsel_gcc-3.4.6_uClibc-0.9.30.1/usr/incl
ude -I/home/user/archive/staging_dir/toolchain-mipsel_gcc-3.4.6_uClibc-0.9.30.1/include " LDFLAGS="-L/home/user/archive/staging_dir/target-mipsel_uClibc-0
.9.30.1/usr/lib -L/home/user/archive/staging_dir/target-mipsel_uClibc-0.9.30.1/lib -L/home/user/archive/staging_dir/toolchain-mipsel_gcc-3.4.6_uClibc-0.9.
30.1/usr/lib -L/home/user/archive/staging_dir/toolchain-mipsel_gcc-3.4.6_uClibc-0.9.30.1/lib " make -C /home/user/archive/build_dir/linux-brcm-2.4/crda-1.
1.1/. AR=mipsel-openwrt-linux-uclibc-ar AS="mipsel-openwrt-linux-uclibc-gcc -c -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -fhonour-copts -msoft-floa
t" LD=mipsel-openwrt-linux-uclibc-ld NM=mipsel-openwrt-linux-uclibc-nm CC="mipsel-openwrt-linux-uclibc-gcc" GCC="mipsel-openwrt-linux-uclibc-gcc" CXX="mip
sel-openwrt-linux-uclibc-g++" RANLIB=mipsel-openwrt-linux-uclibc-ranlib STRIP=mipsel-openwrt-linux-uclibc-strip OBJCOPY=mipsel-openwrt-linux-uclibc-objcop
y OBJDUMP=mipsel-openwrt-linux-uclibc-objdump SIZE=mipsel-openwrt-linux-uclibc-size CROSS="mipsel-openwrt-linux-uclibc-" ARCH="mipsel" NL1FOUND="" NL2FOUN
D=Y NLLIBNAME="libnl-tiny" NLLIBS="-lnl-tiny -lm" REG_BIN="/home/user/archive/dl/2011.04.28-regulatory.bin" crda ;
make[3]: Entering directory `/home/user/archive/build_dir/linux-brcm-2.4/crda-1.1.1'
  CC   reglib.o
In file included from reglib.h:7,
                 from reglib.c:6:
regdb.h:31: error: syntax error before "__be32"
regdb.h:31: warning: no semicolon at end of struct or union
regdb.h:33: warning: type defaults to `int' in declaration of `version'
regdb.h:33: warning: data definition has no type or storage class
regdb.h:41: error: syntax error before "reg_country_ptr"
regdb.h:41: warning: type defaults to `int' in declaration of `reg_country_ptr'
regdb.h:41: warning: data definition has no type or storage class
regdb.h:42: error: syntax error before "reg_country_num"
regdb.h:42: warning: type defaults to `int' in declaration of `reg_country_num'
regdb.h:42: warning: data definition has no type or storage class
regdb.h:44: error: syntax error before "signature_length"
regdb.h:44: warning: type defaults to `int' in declaration of `signature_length'
regdb.h:44: warning: data definition has no type or storage class
regdb.h:48: error: syntax error before "__be32"
regdb.h:48: warning: no semicolon at end of struct or union
regdb.h:59: error: syntax error before "__be32"
regdb.h:59: warning: no semicolon at end of struct or union
regdb.h:61: warning: type defaults to `int' in declaration of `max_eirp'
regdb.h:61: warning: data definition has no type or storage class
regdb.h:83: error: syntax error before "__be32"
regdb.h:83: warning: no semicolon at end of struct or union
regdb.h:84: warning: type defaults to `int' in declaration of `power_rule_ptr'
regdb.h:84: warning: data definition has no type or storage class
regdb.h:86: error: syntax error before "flags"
regdb.h:86: warning: type defaults to `int' in declaration of `flags'
regdb.h:86: warning: data definition has no type or storage class
regdb.h:90: error: syntax error before "__be32"
regdb.h:90: warning: no semicolon at end of struct or union
regdb.h:94: warning: type defaults to `int' in declaration of `reg_rule_ptrs'
regdb.h:94: warning: data definition has no type or storage class
regdb.h:95: error: syntax error before '}' token
regdb.h:102: error: syntax error before "__be32"
regdb.h:102: warning: no semicolon at end of struct or union
regdb.h: In function `check_db_binary_structs':
regdb.h:119: error: invalid application of `sizeof' to incomplete type `regdb_file_header' 
regdb.h:119: error: size of array `type name' is negative
regdb.h:120: error: invalid application of `sizeof' to incomplete type `regdb_file_freq_range' 
regdb.h:120: error: size of array `type name' is negative
regdb.h:121: error: invalid application of `sizeof' to incomplete type `regdb_file_power_rule' 
regdb.h:121: error: size of array `type name' is negative
regdb.h:122: error: invalid application of `sizeof' to incomplete type `regdb_file_reg_rule' 
regdb.h:122: error: size of array `type name' is negative
regdb.h:123: error: invalid application of `sizeof' to incomplete type `regdb_file_reg_rules_collection' 
regdb.h:123: error: size of array `type name' is negative
regdb.h:124: error: invalid application of `sizeof' to incomplete type `regdb_file_reg_country' 
regdb.h:124: error: size of array `type name' is negative
In file included from reglib.c:6:
reglib.h: At top level:
reglib.h:87: error: syntax error before "__be32"
reglib.c:29: error: syntax error before "__be32"
reglib.c: In function `crda_get_file_ptr':
reglib.c:31: error: `ptr' undeclared (first use in this function)
reglib.c:31: error: (Each undeclared identifier is reported only once
reglib.c:31: error: for each function it appears in.)
reglib.c:33: error: `dblen' undeclared (first use in this function)
reglib.c:33: error: `structlen' undeclared (first use in this function)
reglib.c:38: error: `db' undeclared (first use in this function)
reglib.c: At top level:
regdb.h:94: warning: array 'reg_rule_ptrs' assumed to have one element
make[3]: *** [reglib.o] Error 1
make[3]: Leaving directory `/home/user/archive/build_dir/linux-brcm-2.4/crda-1.1.1'
make[2]: *** [/home/user/archive/build_dir/linux-brcm-2.4/crda-1.1.1/.built] Error 2
make[2]: Leaving directory `/home/user/archive/package/crda'
make[1]: *** [package/crda/compile] Error 2
make[1]: Leaving directory `/home/user/archive'
make: *** [package/crda/compile] Error 2

In my experience these errors are bogus and the fault is somewhere else. I have limited C knowledge but can tell that the sources seem fine and there is no visual 'syntax error'. If you want to look at the source: http://ftp.iij.ad.jp/pub/linux/kernel/software/network/crda/crda-1.1.1.tar.bz2 (or pick another mirror).

As some of the errors are related to __be32 and it wasn't syntax highlighted I took a look at that. The type (it's a type, right?) needs to be defined and should be included from linux/types.h. Checking the include dirs reported by the make command I can find one types.h but it doesn't seem to have a typedef for __be32. I did find another types.h with the __be32 typedef but including that doesn't seem to change anything. I've stripped the file (build_dir/linux-brcm-2.4/crda-1.1.1/include/linux/types.h) down to this:

#include <linux/posix_types.h>
#include <asm/types.h>

typedef __u32 __bitwise __be32;

Again no luck and I'm out of ideas, can you help me?

Hi,
welcome to the OpenWRT forum!
First an unfortunate disclaimer, I know nothing of this openwrt version or crda package.
I had a quick look at the repos I could find:


It seems that this section of the code was heavily rewritten for crda version 1.1.3. See commit 501f6913bb889f684d33ef8206aefed08fe03e01 (7th here): https://git.ti.com/cgit/wilink8-wlan/crda/log/crda.c

So... maybe it would be worth a shot trying to use version 1.1.3 (by changing the Makefile)...

Regardless of the disclaimer I'm glad somebody is willing to help and I owe you a big thank you. 1.1.3 compiled so fast I didn't believe it at first, but it compiles fine. I'm now a couple steps closer to my goal. Now fingers crossed that this won't break something else. Thank you, you've made my day!

1 Like

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.