This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Cannot compile .ko, how can I use gcc-3.4.4 with glibc 2.3.5 built by crosstool to compile .ko module?


Hello,

I am trying to compile a module. I don't know how to make .ko file. All 
examples, i have seen are a little confusing.

I have tried to compile a very simple device driver.

The .o file I compile cannot be loaded into the kernel, because the format is 
wrong.
How can I compile a .ko file.

I read the faq http://www.faqs.org/docs/kernel/ , but it did not help either.

Thanks for reading





/* ?hello-1.c - The simplest kernel module. */
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <linux/module.h> ?/* Needed by all modules */
#include <linux/kernel.h> ?/* Needed for KERN_ALERT */
#include <linux/vermagic.h>

MODULE_INFO(vermagic, VERMAGIC_STRING);

#undef unix
struct module __this_module
__attribute__((section(".gnu.linkonce.this_module"))) = {
?.name = __stringify(KBUILD_MODNAME),
?.init = init_module,
#ifdef CONFIG_MODULE_UNLOAD
?.exit = cleanup_module,
#endif
};

int init_module(void)
{
? ?printk("<1>Hello world 1.\n");
? ? ? ? 
? ?// A non 0 return means init_module failed; module can't be loaded.
? ?return 0;
}

void cleanup_module(void)
{
? printk(KERN_ALERT "Goodbye world 1.\n");
} ?
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



///////////////////////////////////////// Makefile
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
# Makefile for the kac device driver

# Comment/uncomment the following line to enable/disable debugging
#DEBUG = y

ifeq ($(DEBUG),y)
? DEBFLAGS = -O -g -DDEBUG_FLAG 
else
? DEBFLAGS = -O2
endif


CC = /arm9/crosstool/gcc-3.4.4-glibc-2.3.5/arm-linux/bin/arm-linux-gcc
MAKE = 
CFLAGS = -v -O2 -DMODULE -D__KERNEL__ ${WARN} ${DEBFLAGS} ${INCLUDEDIR} 
${INCLUDEASMARMDIR} ${INCLUDELINUXDIR}
WARN ? ?:= -W -Wall -Wstrict-prototypes -Wmissing-prototypes 

INCLUDEDIR = -I/atmel.kernel.2.6.12/linux-2.6.14/include
INCLUDEASMARMDIR = -I/atmel.kernel.2.6.12/linux-2.6.14/include/asm-arm
INCLUDELINUXDIR = -I/atmel.kernel.2.6.12/linux-2.6.14/include



simple.o: simple.c
????????$(CC) $(CFLAGS) simple.c 

clean:
????????rm ./*.o
????????rm ./*~
????????rm ./*.ko
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.org


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]