LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problems with cross compilation of a loadable driver module for powerPC (https://www.linuxquestions.org/questions/linux-newbie-8/problems-with-cross-compilation-of-a-loadable-driver-module-for-powerpc-592197/)

renergy 10-16-2007 07:09 AM

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é

renergy 10-16-2007 02:29 PM

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


All times are GMT -5. The time now is 08:57 PM.