cross compiling the "skeleton" driver for ARM on an 86 FreeBSD workstation still builds for x86



help needed


I must be doing something wrong but I have read the architecture reference manual a dozen times and googled this question just as much. I also purchased the "FreeBSD device drivers: for the intrepid" book but it doesnt target cross development issues ...

I just wanted to verify that the skeleton driver (pseudo kernel module) can be built for ARM. I had no issues cross compiling a copy of the kernel I placed in a particular directory (/home/devel/nfsroot/usr/src) with the following environment variables set accordingly

BASEDIR=/home/devel/nfsroot

KERNBUILDDIR=/home/devel/nfsroot/obj/home/devel/nfsroot/usr/src/arm.armv7/sys/GENERIC

SYSDIR=/home/devel/nfsroot/usr/src/sys

MAKEOBJDIRPREFIX=/home/devel/nfsroot/obj

cd $BASEDIR/usr/src

**make TARGET=arm TARGET_arch=armv7 KERNCONF=GENERIC buildkernel**

takes about an hour on my system but when it completes I can verify it created an object file that can be run on my arm development board
file /home/devel/nfsroot/obj/home/devel/nfsroot/usr/src/arm.armv7/sys/GENERIC/kernel

returns

**kernel: ELF 32-bit LSB executable, ARM, EABI5 version 1 (FreeBSD), dynamically linked, interpreter /red/herring, BuildID[sha1]=e5b7d6488e6324e8dc8686fb925a5722d84a3238, for FreeBSD 14.4 (1404500), not stripped**

The kernel source is FreeBSD 14.3 and under my home directory I had the skeleton.c pseudo module along with a Makefile whose contents are

Makefile
**************
SRCS=skeleton.c
KMOD=skeleton

.include <bsd.kmod.mk>

Running make with this makefile will create a file skeleton.ko that can be loaded into the kernel by typing:
# kldload -v ./skeleton.ko

******************************

Again all this is provided by FreeBSD

Now when I run

make TARGET=arm TARGET_ARCH=armv7

It completes in about a few seconds but I can clearly see - even before running the output against "file" its not building for an arm target.

machine -> /home/devel/nfsroot/usr/src/sys/amd64/include
x86 -> /home/devel/nfsroot/usr/src/sys/x86/include
i386 -> /home/devel/nfsroot/usr/src/sys/i386/include

Warning: Object directory not changed from original /home/devel/nfsroot/bsd_example_driver

cc -O2 -pipe -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc -DHAVE_KERNEL_OPTION_HEADERS -include /home/devel/nfsroot/obj/home/devel/nfsroot/usr/src/arm.armv7/sys/GENERIC/opt_global.h -I. -I/home/devel/nfsroot/usr/src/sys -I/home/devel/nfsroot/usr/src/sys/contrib/ck/include -fno-common -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/home/devel/nfsroot/usr/src/sys=/usr/src/sys -ffile-prefix-map=/home/devel/nfsroot/obj/home/devel/nfsroot/usr/src/arm.armv7/sys/GENERIC=/usr/obj/usr/src/amd64.amd64/sys/GENERIC -ffile-prefix-map=/home/devel/nfsroot/bsd_example_driver=/usr/obj/usr/src/amd64.amd64/sys/GENERIC/modules/usr/src/sys/modules/bsd_example_driver -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include -fdebug-prefix-map=./i386=/usr/src/sys/i386/include -I/home/devel/nfsroot/obj/home/devel/nfsroot/usr/src/arm.armv7/sys/GENERIC -MD -MF.depend.skeleton.o -MTskeleton.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error=tautological-compare -Wno-error=empty-body -Wno-error=parentheses-equality -Wno-error=unused-function -Wno-error=pointer-sign -Wno-error=shift-negative-value -Wno-address-of-packed-member -Wno-format-zero-length -mno-aes -mno-avx -std=gnu99 -c skeleton.c -o skeleton.o

ld -m elf_x86_64_fbsd -warn-common --build-id=sha1 -T /home/devel/nfsroot/usr/src/sys/conf/ldscript.kmod.amd64 -r -o skeleton.ko skeleton.o

:> export_syms

awk -f /home/devel/nfsroot/usr/src/sys/conf/kmod_syms.awk skeleton.ko export_syms | xargs -J% objcopy % skeleton.ko

objcopy --strip-debug skeleton.ko

What am I doing wrong?

skeleton pseudo kernel module and Makefile are provided unchanged. And as I stated I can build (cross compile) an armv7 kernel without an issue

Thanks in advance
 
First off are you actually using ARMv7 ?? What platform?

There is an updated version of the online files that rbranco has so make sure your try that out for Kong's FreeBSD Drivers book.
He has nice examples for each chapter. Refreshed from 2013 for FreeBSD 14

Hope he does mind me posting a link:

Check the last post.
make toolchain TARGET=BLAH TARGET_ARCH=BLAHBLAH
make buildenv TARGET=BLAH TARGET_ARCH=BLAHBLAH

 
Back
Top