# problem with including if_var.h and cpu.h header in program, raspberry pi 2 B



## araz (May 17, 2016)

on a raspberry pi 2 B that has FreeBSD 11.0-current on it, I need to have some kind of a network interface created (meaning that if for example `ifconfig` is typed, my network interface and its options must be shown alongside lo0 & ue0 ).

and to do just that, I need ifnet and other structures that are defined in if_var.h header. so I include this header in my program, but when I make the ( .c ) file, I get the following error:

```
In file included from cc2530.c:24:
In file included from /sys/net/if_var.h:74:
In file included from /sys/sys/buf_ring.h:33:
./machine/cpu.h:48:10: error : implicit declaration of function 'cp15_pmccntr_get' is invalid ...
```

one more thing to mention is that I even tested FreeBSD's  usb_ethernet.c: I copy the ( .c ) file and its make file from their original directory to some other directory, and when I make it to see if this FreeBSD original driver can be compiled  again exactly the same error appears and the point is that, this problem does not exist in amd64 architecture.

what do you think? any ideas, solutions?


----------



## Phishfry (May 17, 2016)

How about cross compiling or build with poudriere or synth.


----------



## araz (May 17, 2016)

i noticed something interesting, in one hand i have FreeBSD 11 on my raspberry and in the other i have it in my virtualbox.
(I had previously built the world and the kernel for my RPI2 by cross compiling on virtualbox )
now, I `cd` to /boot/kernel and then `kldload ./uether.ko` in both RPI2 and vbox.
in vbox the module gets loaded and i can see it after in `kldstat`, but in raspberry it says:

```
interface uether.1 already present in the KLD 'kernel'!
kldload: can't load ./uether.ko: module already loaded or in kernel
```

what does it mean? is it something about a cross compile?


----------



## araz (May 17, 2016)

Phishfry said:


> How about cross compiling or build with poudriere or synth.


the kind of cross compile that i'm familiar with, as I said, is for building the kernel completely. and when you say cross compile do you mean the kind that I have done, or do you mean another?
is there a way to just cross compile my program?


----------



## Phishfry (May 18, 2016)

I am not the most knowledgeable about the topic.
https://wiki.freebsd.org/FreeBSD/arm/crossbuild


----------



## Phishfry (May 18, 2016)

Do you realize that hardware is enumerated differently on Arm platforms. They use a system called fdt(4)
The DTS file for a particular platform has all the hardware listed. So whereas x86/64 has a live hardware detection system and Arm uses a fixed system. The reason I mention it is you may need to add your psudo device to the DTS for your Arm board..

https://wiki.freebsd.org/FlattenedDeviceTree
https://www.freebsd.org/cgi/man.cgi?query=FDT


----------



## araz (May 19, 2016)

*W*hat you say is correct. *A*nd in fact that is exactly what I have done so that Raspberry can detect my cc2530 and I can send and receive data. *B*ut what I am going to do now is to tell kernel that my chip is a network interface. *H*ow? *B*y providing kernel with (ifnet) and (ifmedia) structures, the ifnet structure is defined in if_var.h and as the error message shows, including this header (in any program in ARM) leads to an implicit declaration of cp15_pmccntr_get().
*A*nd I don't know why?


----------

