How to create kernel module for mini2440

rahul s
Hi,
     Can someone tell me the step of creating kernel module for mini2440
from c file?
     As I know that we have to use make command but to use that we have to
create Makefile.
    So pls explain me how to write Makefile?

Juergen Beisert
Read the documentation in the kernel source tree under
"Documentation/kbuild", especially "Documentation/kbuild/modules.txt"

Gautam
Hi Rahul,

I have attached a sample Makefile for building a module for the mini2440.
It drives the 4 LEDs via an application. I have also attached the kernel
module source code (mini2440led.c) as well as a sample application to test
this module.

To run the sample code you will need to do the following:

1. Obtain and extract the mini2440 linux kernel sources (available on the
product DVD).

2. Install a cross-compilation toolchain (such as Codesourcery Lite++) for
ARM. (Also available on the product DVD).

3. Configure, build and install the new kernel on your development machine.
(Yes, your development machine! I know you are not going to boot it on your
dev machine, but this step will ensure that the kernel source headers are
visible to the cross-compiler.)

4. Create a new directory called 'mini2440led' in your user home directory
and extract the attached files.

5. Change to this directory and run make in it.

6. Now build the application (in the same directory) as follows:
   gcc -o mini2440ledapp mini2440ledapp.c

7. Insert the module using insmod.

8. Run the application and do as directed by the source code.

9. Sit back and relax!

Hope that helps!

Gautam Ghate

Gautam
Attachment: mini2440led.zip (1.84 KB)
@Rahul,

Sorry about the missing attachment. Here it is!

Gautam Ghate

rahul s
Hi,
   Thanks for reply.
     I got your c code file for kernel and c code for application, both the
files are take in host linux system(PC).Then I use make command and I got
.ko file. Then I use insmod command and mknod command to make mini2440led
file.
     Also I compile application .c file using arm-linux-gcc compiler I got
.o file.
    now I want to transfer this mini2440led file and object file to board.
    object file is copied in pendrive but mini2440led wannt get transfered.
     Then I copy .ko file from host system and send it to mini2440 kit.
   There I try with the command insmod and mknod but it doesnt work.
   Please sug me how can I transfer these files in board.
Thanks,
Rahul

mark
Hi, Gautam :
I have tried the attachment,but I don't have directory
/lib/modules/2.6.32.2-FriendlyARM/build .
Only a link named "build" in /lib/modules/2.6.32.2-FriendlyARM/ ,it's not a
directory,
And the result of make is : No such file or directory.

Can you help? Thanks!

Mark

cowboy
I'll quickly show you how easy it is to compile a kernel for the mini2440.
If you haven't already installed git, you should do so now. In Ubuntu, you
simply install the package git-core. 

the full content see follows url:
http://www.hycshop.com/article/How_to_create_kernel_module_for_mini2440.htm

Sushant
TOOLCHAIN :=    CC
KDIR :=KERNEL PATH
PWD := $(shell pwd)
PATH := $(TOOLCHAIN):${PATH}


obj-m += spi_ker.o

default:
        $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

clean:
        @rm -Rf *.o *.ko *.mod.c modules.order Module.symvers