beaglebone make error

Hello friends, i was trying to write a simple kernel module for the beaglebone as follows but had some problems.

kernel version : 3.2.5+

hello.c file

#include<linux/module.h>
#include<linux/kernel.h>

static int __init hello(void)
{
printk(KERN_INFO “Loading module\n”);
return 1; (void)
{

static void __exit hello_exit(void)
}
printk(KERN_INFO “Unloading the module\n”);
}
{
module_init(hello);
}odule_exit(hello_exit);

Makefile

obj-m:= hello.o
KDIR:= /lib/modules/$(shell uname -r) /build
PWD:= $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

output

make -C /lib/modules/3.2.5+ /build SUBDIRS=/home/root modules
make[1]: Entering directory /lib/modules/3.2.5+' make[1]: *** No rule to make target /build’. Stop.
make[1]: Leaving directory `/lib/modules/3.2.5+’
make: *** [default] Error 2

Can you point out what should be done?

Kamran <alikamu@gmail.com> writes:

Hello friends, i was trying to write a simple kernel module for the
beaglebone as follows but had some problems.

Hello Kamran,

Take a look at Linux Device Drivers, 3rd edition:

     Linux Device Drivers, Third Edition [LWN.net]

A similar hello.c kernel module source file is found in chapter 2, page
16. Your version of hello.c has typos. Similarly, try using the
Makefile file from chapter 2, page 24.

Once you have those files in place, make sure you've defined the
necessary enviornment variables. Here's what the relevant environment
variables look like for bash on my system:

     export PATH=/home/ricardo/CodeSourcery/Sourcery_CodeBench_for_ARM_GNU_Linux/bin:/home/ricardo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
     export ARCH=arm
     export CROSS_COMPILE=arm-none-linux-gnueabi-
     export KCFLAGS=-mno-unaligned-access
     export KDIR=/home/ricardo/mel-kit-pandaboard_sources/copyleft_sources/linux-omap4-2.6.35.7-r0c/src
     export MDIR=/home/ricardo/kernel_module

KDIR is the path to your kernel source tree directory. MDIR is the path
to your kernel module sources.

Then proceed to build your module:

     make -C $KDIR M=$MDIR

You will find a hello.ko file in the same directory as your kernel
module source.

Cheers,

Thanks Ricordo for the quick answer…
I will give it a try … but i think that the steps provided are for making a *.ko file on a pc and than porting it to the beaglebone. Correct me if i am wrong.

But i was looking to make the module on the beaglebone itself.
thanks
Kamran

Kamran <alikamu@gmail.com> writes:

Thanks Ricordo for the quick answer.....
I will give it a try ... but i think that the steps provided are for
making a *.ko file on a pc and than porting it to the
beaglebone. Correct me if i am wrong.

But i was looking to make the module on the beaglebone itself.

Hello Kamran,

That is correct: I assumed you were cross-compiling. I don't have much
experience with native kernel module builds, but you will probably not
need the ARCH or CROSS_COMPILE environment variables. I expect the rest
of the process to be similar.

Cheers,