hii i am trying to compile a simple device driver and insert it on lenux system that is on the DE1-SOC board that i have
i included the files when i compile the lkm module gets generated but when i move it to the de1-soc board and try the insmod command i get an error i it cant load
when i do file hello.ko i can see that its elf 32bit arm file
but when i put on the board it says invalid module format
what i missing here i be glad for help
the make file code
Target object file
obj-m := hello.o
Cross-compiler path for ARM (BeagleBone)
CROSS_COMPILE_ARM = arm-linux-gnueabihf-
Cross-compiler path for x86 (Intel)
CROSS_COMPILE_X86 =
Target architecture (default: ARM)
ARCH ?= arm
ifeq ($(ARCH),x86_64)
# Compile for x86 (Intel)
CROSS_COMPILE := $(CROSS_COMPILE_X86)
else
# Compile for ARM (default)
CROSS_COMPILE := $(CROSS_COMPILE_ARM)
endif
Kernel directory
KERNELDIR ?= $(HOME)/linux
Current directory
PWD := $(shell pwd)
Build target for building the module
module:
$(MAKE) -C $(KERNELDIR) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) M=$(PWD) modules
@echo “Building module for $(ARCH) architecture”
Clean target for cleaning the module build artifacts
clean:
$(MAKE) -C $(KERNELDIR) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) M=$(PWD) clean
rm -rf *.o ~ core .depend ..cmd *.ko *.mod.c .tmp_versions
Declare the targets as phony targets
.PHONY: module clean
the lkm modle code
/*
- $Id: hello.c,v 1.5 2004/10/26 03:32:21 corbet Exp $
*/
#include <linux/init.h>
#include <linux/module.h>
static int hello_init(void)
{
printk(KERN_ALERT “hello world \n”);
printk(KERN_ALERT “module is up \n”);
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT “bye bye \n”);
printk(KERN_ALERT “module is down \n”);
return ;
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE(“Dual BSD/GPL”);