I am working on building a kernel module, architecture is Arm (armv7-m), tool chain is arm-uclinuxeabi-gcc and family.
I have a C file, sample.c that builds as a kernel module, loads, executes, all is fine.
I have an assembly file, mmcau.S, that builds independently.
However, when I try to include the assembly file in the kernel module build process, I can not get the make file to cooperate. I have read that there are implicit rules for .S -> .o, but I am left wondering if that is true.
To build sample.c by itself:
Code:
CFLAGS := -Os -mcpu=cortex-m4 -mthumb
LDFLAGS := -mcpu=cortex-m4 -mthumb
CC = $(CROSS_COMPILE_APPS)gcc
obj-m += sample.o
KERNELDIR := $(INSTALL_ROOT)/linux
modules :
make -C $(KERNELDIR) M=`pwd` modules CFLAGS="" LDFLAGS=""
clean_modules:
make -C $(KERNELDIR) M=`pwd` clean
rm -f modules.order
To build mmcau.S by itself:
Code:
AS := $(CROSS_COMPILE_APPS)gcc
#AS := $(CROSS_COMPILE_APPS)as
ASFLAGS := -x assembler-with-cpp -mcpu=cortex-m4 -mthumb
#Rule for assembling .s -> o files
$(SOBJ) : %.o : %.S
@echo Assembling
$(AS) $(ASFLAGS) -c $< -o $@
mmcau : mmcau.S
@echo Assembling mmcau.S
$(AS) $(ASFLAGS) -c $<
# with the -o $@ creates an application
# w/o the -o $@ creates a .o
However, when I add mmcau.o to obj-m for the kernel module,
Code:
obj-m += sample.o
obj-m += mmcau.o
I get an error like:
Code:
make[2]: *** No rule to make target `..../app/mmcau.c', needed by `.../app/mmcau.o'. Stop.
I haven't been able to get past this error. Some variations of makefile cause an output module to be created, but loading it in the kernel causes a kernel taint error regarding the licensing, and the entire system crashes when the module is accessed.
Thanks, paulcsf