Linux / UNIX Tech Support Forum
This is a discussion on Help me compile linux kernel module within the Coding in General forums, part of the Development/Scripting category; Hello. Please, show me a correct Makefile for compiling a kernel module which consist of two *.c files. My .c ...
|
|||||||
| Coding in General Discussion on PHP/Perl/Python/Ruby/GNU C or C++. MySQL, PgSQL and (X)HTML or any other programming languages you want. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hello.
Please, show me a correct Makefile for compiling a kernel module which consist of two *.c files. My .c files: Code:
module.c:
//*******************************************
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/interrupt.h>
//-----------------------------------------------------------
#define MODULE
#define __KERNEL__
//-----------------------------------------------------------
MODULE_AUTHOR("Oligarch");
MODULE_DESCRIPTION("Kernel module");
//-----------------------------------------------------------
static irqreturn_t ISI_interrupt(int irq, void * dev_id)
{
return IRQ_HANDLED;
}
//-----------------------------------------------------------
int init_module()
{
printk("Kernel: Module startup\n");
return 0;
}
//-----------------------------------------------------------
void cleanup_module()
{
printk("Kernel: Module quit\n");
return;
}
//-----------------------------------------------------------
//*******************************************
regs_map.c
//*******************************************
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
//-------------------------------------------------
#define ISI_MAP_SIZE 4096Ul
#define ISI_MAP_MASK (ISI_MAP_SIZE - 1)
#define ISI_BASE 0xFFFC0000
//-------------------------------------------------
typedef volatile unsigned int AT91_REG;
//-------------------------------------------------
typedef struct _AT91S_ISI {
AT91_REG ISI_CR1;
AT91_REG ISI_CR2;
AT91_REG ISI_SR;
AT91_REG ISI_IER;
AT91_REG ISI_IDR;
AT91_REG ISI_IMR;
AT91_REG reserved1;
AT91_REG reserved2;
AT91_REG ISI_PSIZE;
AT91_REG ISI_PDECF;
AT91_REG ISI_PPFBD;
AT91_REG ISI_CDBA;
AT91_REG ISI_Y2R_SET0;
AT91_REG ISI_Y2R_SET1;
AT91_REG ISI_R2Y_SET0;
AT91_REG ISI_R2Y_SET1;
AT91_REG ISI_R2Y_SET2;
} AT91S_ISI, *AT91PS_ISI;
//-------------------------------------------------
AT91PS_ISI isi;
//-------------------------------------------------
AT91S_ISI * isi_map(unsigned int isibase)
{
int fd;
void * base;
AT91S_ISI * _isi;
off_t addr=isibase;
if ((fd=open("/dev/mem",O_RDWR|O_SYNC))==-1){fprintf(stderr,"Cannot open ISI /dev/mem.\n");exit(EXIT_FAILURE);}
base=mmap(0,ISI_MAP_SIZE,PROT_READ|PROT_WRITE,MAP_SHARED,fd,addr&~ISI_MAP_MASK);
if(base==(void *)-1){fprintf(stderr, "Cannot ISI mmap.\n");exit(EXIT_FAILURE);}
_isi=base+(addr&ISI_MAP_MASK);
return _isi;
}
//-------------------------------------------------
//*******************************************
I started to write an ISI module for AT91SAM9260 and encountered with compilation problems. I compile module good without regs_map.c file, but I can't compile it with regs_map.c. Show me a correct Makefile to do it, please. My old Makefile looks like: Code:
obj-m := module.o
KDIR := /lib/modules/2.6.24/build
PWD := $(shell pwd)
CC := /home/sedyshev/arm-2007q1/bin/arm-none-linux-gnueabi-gcc
TOOLCHAIN=/home/sedyshev/arm-2007q1/bin/arm-none-linux-gnueabi-
default:
$(MAKE) CROSS_COMPILE=$(TOOLCHAIN) ARCH=arm -C $(KDIR) M=$(PWD) modules
Last edited by nixcraft; 14-12-2009 at 02:30 PM. Reason: code tags |
| Sponsored Links | ||
|
|
|
||||
|
Have you tried our tutorial?
Make file is very sensitive about tabs.
__________________
Vivek Gite Linux Evangelist |
|
|||
|
everything OK with tabs. I built kernel module before and it was working fine on my AT91SAM9260-EK. Now I want to write Image Sensor Interface driver for AT91SAM9260-EK, thus I need to get access to hardware registers. I know only phisical addresses of these registers. Can I just read and write to these adddresses or I should use another functionality ?
Thank you. Last edited by _oligarch; 14-12-2009 at 03:46 PM. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Linux kernel deleted from /boot - how do I resinstall the kernel | vaibhav.kanchan | Getting started tutorials | 2 | 25-03-2008 12:31 AM |
| compile a new kernel in RHEL 5 | vikas027 | CentOS / RHEL / Fedora | 3 | 24-03-2008 09:56 PM |
| Linux disable kernel module / driver | sweta | Linux hardware | 2 | 21-08-2007 12:38 AM |
| Kernel Compile | mannrj45 | Linux software | 1 | 02-12-2006 08:32 PM |
| freebsd kernel module unload | HellBoy | All about FreeBSD/OpenBSD/NetBSD | 2 | 05-01-2006 06:51 PM |