LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-16-2007, 06:09 AM   #1
renergy
LQ Newbie
 
Registered: Oct 2007
Posts: 2

Rep: Reputation: 0
Problems with cross compilation of a loadable driver module for powerPC


I have ported Linux to Xilinx XUPV2P Board using different sites on the internet. I'm using a cross compiler on my machine with SUSE 10.2 (gcc3.4.4-gclib-2.3.3). It is possible to cross-compile standard C-files and they work on the Xilinx Board.
I added a custom IP to the EDK design (simple multiplier). It can be written to reg1 and reg2 and then the result of the multiply can be read in reg3. With mmap in a simple C program it is no problem to use the multiplier, but when I try to build a loadable driver module I got problems with the cross compilation. It seems to be the fact that the problems comes from the Cross Compiler (the added headers). I have not done many things with Linux before. Therefore I have no idea what the problem is and how I can solve it.
I used the code source from Jamie Lin (available on the internet). Thats the driver source code:

#include <linux/init.h> // to use module_init and module_exit
#include <linux/module.h>// macros for modules
#include <linux/kernel.h>
#include <linux/ioport.h>
#include <linux/errno.h>
#include <asm/io.h>

MODULE_AUTHOR("Rene Schoenherr") ;
MODULE_DESCRIPTION("Driver Module for a Custom IP on a FPGA") ;
MODULE_SUPPORTED_DEVICE("simple_multiplier on the XUPV2P Board") ;

EXPORT_NO_SYMBOLS ;

static unsigned int reg1 = 3; // test data
static unsigned int reg2 = 4; // test data
static unsigned int reg3 = 0; // test data
static unsigned int *virtual_base = 0; // remapped address
static unsigned long mem_addr = 0x74a00000;// IP base address
static unsigned long mem_size = 0x10000; // 64KB

MODULE_PARM(mem_addr,"i") ;
MODULE_PARM_DESC(mem_addr,"base address of I/O memory for the custom IP core");
MODULE_PARM(mem_size,"i") ;
MODULE_PARM_DESC(mem_size,"size of I/O memory segment for the custom IP core");

int io_driver_init(void)
{
int i;
if(check_mem_region(mem_addr,mem_size))
{
printk("simp_mult: memory already in use\n");
return -EBUSY;
}
// request memory for the device
request_mem_region(mem_addr,mem_size,"simp_mult");
// remap
virtual_base = ioremap_nocache(mem_addr,mem_size);
printk("ioremap: Virtual Address %08x\n",(unsigned int)virtual_base);
printk("Physical Address %08x\n",(unsigned int)virt_to_phys(virtual_base));
if( virtual_base==0 )
{
printk("ioremap failed\n");
return -EBUSY ;
}
else
{
//printk("Data to write out: %08x\n",io_reg);
writel(reg1,virtual_base);
wmb();
printk("Value of reg1 = %08x\n",reg1);

writel(reg2,virtual_base + 1);
wmb();
printk("Value of reg2 = %08x\n",reg2);

for( i=0 ; i<10000 ; i++);

//barrier();
reg3 = readl(virtual_base + 2);
rmb() ;
printk("Result of reg1 * reg2 = %08x\n",reg3) ;

return 0; // indicate a success
}
}

void io_driver_exit(void)
{
printk("Release Memory Region...\n") ;
iounmap(virtual_base) ;
release_mem_region(mem_addr,mem_size) ;
}

module_init(io_driver_init);
module_exit(io_driver_exit);



Thats the Makefile:

KERNELDIR=home/rene/linuxonxupv2p/kernel/linuxppc_2_4_devel
#include $(KERNELDIR)/.config

CC = powerpc-405-linux-gnu-gcc
LD = powerpc-405-linux-gnu-ld
CFLAGS = -D__KERNEL__ -DMODULE -I$(KERNELDIR)/include \
-I$(KERNELDIR)/arch/ppc \
-O -Wall

ifdef CONFIG_SMP
CFLAGS += -D__SMP__ -DSMP
endif

mult_test_drv_module.o: mult_test_drv_module.c

skull.o: skull_init.o skull_clean.o
$(LD) -r $^ -o $@



And this are the error and warning messages (It seems to be the fact that the cross compiler took header files from another directory than the given KERNELDIR):

rene@linux-79k2:~/drivertest/loadable_module_without_userapp> make
powerpc-405-linux-gnu-gcc -D__KERNEL__ -DMODULE -Ihome/rene/linuxonxupv2p/kernel/linuxppc_2_4_devel/include -Ihome/rene/linuxonxupv2p/kernel/linuxppc_2_4_devel/arch/ppc -O -Wall -c -o mult_test_drv_module.o mult_test_drv_module.c
In file included from /opt/powerpc-405-linux/lib/gcc/powerpc-405-linux-gnu/3.4.4
/../../../../powerpc-405-linux-gnu/sys-include/linux/sched.h:16,
from /opt/powerpc-405-linux/lib/gcc/powerpc-405-linux-gnu/3.4.4
/../../../../powerpc-405-linux-gnu/sys-include/linux/module.h:9,
from mult_test_drv_module.c:11:
/opt/powerpc-405-linux/lib/gcc/powerpc-405-linux-gnu/3.4.4/../../../../powerpc-4
05-linux-gnu/sys-include/linux/signal.h:2:2: warning: #warning "You should inclu
de <signal.h>. This time I will do it for you."
In file included from /opt/powerpc-405-linux/lib/gcc/powerpc-405-linux-gnu/3.4.4
/../../../../powerpc-405-linux-gnu/sys-include/linux/sched.h:79,
from /opt/powerpc-405-linux/lib/gcc/powerpc-405-linux-gnu/3.4.4
/../../../../powerpc-405-linux-gnu/sys-include/linux/module.h:9,
from mult_test_drv_module.c:11:
/opt/powerpc-405-linux/lib/gcc/powerpc-405-linux-gnu/3.4.4/../../../../powerpc-4
05-linux-gnu/sys-include/linux/resource.h:2:2: warning: #warning "You should inc
lude <sys/resource.h>. This time I will do it for you."
In file included from mult_test_drv_module.c:11:
/opt/powerpc-405-linux/lib/gcc/powerpc-405-linux-gnu/3.4.4/../../../../powerpc-4
05-linux-gnu/sys-include/linux/module.h:41: error: field `attr' has incomplete type
/opt/powerpc-405-linux/lib/gcc/powerpc-405-linux-gnu/3.4.4/../../../../powerpc-405-linux-gnu/sys-include/linux/module.h:49: error: field `kobj' has incomplete type
mult_test_drv_module.c:22: warning: type defaults to `int' in declaration of `EXPORT_NO_SYMBOLS'
mult_test_drv_module.c:22: warning: data definition has no type or storage class
mult_test_drv_module.c: In function `io_driver_init':
mult_test_drv_module.c:41: warning: implicit declaration of function `printk'
mult_test_drv_module.c:47: warning: implicit declaration of function `ioremap_nocache'
mult_test_drv_module.c:47: warning: assignment makes pointer from integer without a cast
mult_test_drv_module.c:49: warning: implicit declaration of function `virt_to_phys'
mult_test_drv_module.c:58: warning: implicit declaration of function `writel'
mult_test_drv_module.c:59: warning: implicit declaration of function `wmb'
mult_test_drv_module.c:69: warning: implicit declaration of function `readl'
mult_test_drv_module.c:70: warning: implicit declaration of function `rmb'
mult_test_drv_module.c: In function `io_driver_exit':
mult_test_drv_module.c:80: warning: implicit declaration of function `iounmap'
make: *** [mult_test_drv_module.o] Error 1



I would be very grateful if someone could help me.
Best regards
René

Last edited by renergy; 10-16-2007 at 06:14 AM.
 
Old 10-16-2007, 01:29 PM   #2
renergy
LQ Newbie
 
Registered: Oct 2007
Posts: 2

Original Poster
Rep: Reputation: 0
compiler version

Problem solved! Only the slash was missing in front of the kerneldir (thanks to my fellow student)

Last edited by renergy; 10-16-2007 at 07:34 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Guide needed in device driver / module compilation. SPo2 Linux - Newbie 1 09-30-2007 12:18 PM
Help, loadable kernel module . ERBRMN Linux - General 3 10-13-2006 07:34 AM
Problem with gcc powerpc cross compile !! rohya_joshi Linux - Software 2 02-07-2006 12:44 AM
Building cross-compiler gcc for powerpc-linux ccool Linux - General 3 09-17-2004 06:33 AM
kernel 2.6.1 module compilation problems Zamolxis Linux - Software 3 01-16-2004 10:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration