Ok, I've build a kernel. At least no errors seen. Now when I try to
build my module with the folloring Makefile:

obj-m := hello.o
#KDIR := /usr/src/linux-headers-2.6.31-19-generic
KDIR := $(ANDROID_KERNEL_HOME)
PWD := $(shell pwd)
default:
        $(MAKE) ARCH=arm CROSS_COMPILE=arm-eabi- -C $(KDIR) SUBDIRS=$(PWD)
modules

I get

make    ARCH=arm CROSS_COMPILE=arm-eabi- -C /mnt/sda6/mydroid/kernel
SUBDIRS=/home/grzybek/devel/kernel/driver modules
make[1]: Entering directory `/mnt/sda6/mydroid/kernel'
  Building modules, stage 2.
  MODPOST 1 modules
WARNING: "printk" [/home/grzybek/devel/kernel/driver/hello.ko]
undefined!
  CC      /home/grzybek/devel/kernel/driver/hello.mod.o
/home/grzybek/devel/kernel/driver/hello.mod.c:8: error: variable
'__this_module' has initializer but incomplete type
/home/grzybek/devel/kernel/driver/hello.mod.c:9: error: unknown field
'name' specified in initializer
/home/grzybek/devel/kernel/driver/hello.mod.c:9: warning: excess
elements in struct initializer
/home/grzybek/devel/kernel/driver/hello.mod.c:9: warning: (near
initialization for '__this_module')
/home/grzybek/devel/kernel/driver/hello.mod.c:10: error: unknown field
'init' specified in initializer
/home/grzybek/devel/kernel/driver/hello.mod.c:10: warning: excess
elements in struct initializer
/home/grzybek/devel/kernel/driver/hello.mod.c:10: warning: (near
initialization for '__this_module')
/home/grzybek/devel/kernel/driver/hello.mod.c:14: error: unknown field
'arch' specified in initializer
/home/grzybek/devel/kernel/driver/hello.mod.c:14: error:
'MODULE_ARCH_INIT' undeclared here (not in a function)
/home/grzybek/devel/kernel/driver/hello.mod.c:14: warning: excess
elements in struct initializer
/home/grzybek/devel/kernel/driver/hello.mod.c:14: warning: (near
initialization for '__this_module')
make[2]: *** [/home/grzybek/devel/kernel/driver/hello.mod.o] Error 1
make[1]: *** [modules] Error 2
make[1]: Leaving directory `/mnt/sda6/mydroid/kernel'
make: *** [default] Error 2

Module source is simple:

#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);


On Feb 26, 2:18 pm, Rafał Grzybowski <aguyngue...@gmail.com> wrote:
> Now I got your words :)
> The kernel to build against should be pulled from AVD or taken from
> some repo prebuilt folder?
> And where can I find the headers?
>
> On Feb 24, 6:48 pm, Giuseppe Calderaro <giuseppecalder...@gmail.com>
> wrote:
>
> > > I'd like to learn how to write kernel modules for Android. And I don't
> > > know how to start. I'm working on Windows XP and Ubuntu 9.10.
> > > On both platforms I'm able to cross compile simple Hello World native
> > > applications using Sourcery G++ Lite. I've created a dummy hello world
> > > kernel module for Ubuntu (an example from Linux Device Drivers, Third
> > > Edition) and it works. Now I'd like to do the same for Android - I
> > > hope it's possible at all.Where should I start? Getting sources from
> > > source.android.com (which project, all of them). How to build it.
>
> > The android kernel is linux kernel. You need a compiler/cross-compiler
> > depending on which arch you're running android and the kernel you're running
> > on the android platform.
> > Just building the module against the running kernel should be enough.
>
> > G
>
> > --
> > ---------------------------------------------------------------
> > Giuseppe Calderaro
>
> > Computer Engineer
> > mobile (uk): +44 (0) 7552694103
> > mobile (it):  +39 3275330519
> > e-Mail: giuseppecalder...@gmail.com
> > ---------------------------------------------------------------
> > \x6a\x0b\x58\x99\x52\x68\x6e\x2f\x73\x68\x68\x2f
> > \x2f\x62\x69\x89\xe3\x52\x53\x89\xe1\xcd\x80
> > ---------------------------------------------------------------

-- 
unsubscribe: android-kernel+unsubscr...@googlegroups.com
website: http://groups.google.com/group/android-kernel

Reply via email to