General TC > General TC Talk
Simple device driver trouble
jjacobs:
I need to write a device driver for a piece of hardware my company manufactures. This board has 8 serial ports that sit on an ISA bus. There are 4 ISA slots on the mother board.
I downloaded the 2.6.29.1 kernel source code and placed it on my hard drive. I ran make headers_install in the source directory.
I also made a Makefile in the directory where my test code resides it has one line and it looks like this:
obj-m := first.o
I've been having trouble compiling the simplest device driver example from the linux device driver how to's I've found.
The code is in a file called first.c and looks like this:
#define __KERNEL__
#define MODULE
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT, "Hello, world\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT, "Goodbye, cruel world\n");
}
module_init(hello_init);
module_exit(hello_exit);
I compile with the line:
make -C pathtosource M=`pwd` modules
I get ther error:
ERROR: Kernel configuration is invalid.
include/linux/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.
WARNING: Symbol version dump /mnt/hda3/MyKernel/linux-2.6.29.1/Module.symvers
is missing; modules will have no dependencies and modversions.
CC [M] /mnt/hda3/DriverTest/first.o
/mnt/hda3/DriverTest/first.c:1: error: code model 'kernel' not supported in the 32 bit mode
/mnt/hda3/DriverTest/first.c:1: sorry, unimplemented: 64-bit mode not compiled in
make[1]: *** [/mnt/hda3/DriverTest/first.o] Error 1
make: *** [_module_/mnt/hda3/DriverTest] Error 2
make: Leaving directory `/mnt/hda3/MyKernel/linux-2.6.29.1'
Are there any device driver experts about that can give some advice? Do I need to compile a custom kernel?
This is the location of the howto I'm using:
http://www.freesoftwaremagazine.com/articles/drivers_linux?page=0%2C1
I notice that the author says,
"First, you need to have a complete, compiled kernel source-code-tree."
Is there a list of kernel options for tinycore anyplace? On my machine uname -a shows:
Linux box 2.6.29.1-tinycore #1337 SMP Fri Apr 10 19:12:39 EEST 2009 i686 GNU/Linux
popolon:
The kernel options for tinycore are here:
http://distro.ibiblio.org/pub/linux/distributions/tinycorelinux/2.x/release/src/config-2.6.29.1-tinycore
I think you must copy the config file to .config in the source tree and then "make oldconfig". Not 100% sure, i'm no expert but it worked for me building a module.
You should also probably use the patched kernel source from the same place as the config (linux-2.6.29.1-patched.tar.bz2)
jjacobs:
Thanks popolon,
I'm compiling the kernel after applying the patch. I will give an update after the compilation completes.
jjacobs:
It now compiles and I get first.ko amongst other outputs. When I insmod first.ko I don't see the print on the terminal, and I don't see the message in /var/log/syslog. If I do lsmod though I see first, and first is removed after rmmod. I verified its removal via a second lsmod.
I think I'm on the right track though somewhat disappointed that I didn't see the messages.
^thehatsrule^:
Make sure syslog is running, or check dmesg?
Navigation
[0] Message Index
[#] Next page
Go to full version