Click here to learn
about this Sponsor:
Home  |  News  |  Articles  |  Forum

Cross Compilation Errors PPC (Driver Module)

Cross Compilation Errors PPC (Driver Module)

Postby renergy » Tue Oct 16, 2007 7:49 am

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

");

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

",(unsigned int)virtual_base);

printk("Physical Address %08x

",(unsigned int)virt_to_phys(virtual_base));

if( virtual_base==0 )

{

printk("ioremap failed

");

return -EBUSY ;

}

else

{

//printk("Data to write out: %08x

",io_reg);

writel(reg1,virtual_base);

wmb();

printk("Value of reg1 = %08x

",reg1);



writel(reg2,virtual_base 1);

wmb();

printk("Value of reg2 = %08x

",reg2);



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



//barrier();

reg3 = readl(virtual_base 2);

rmb() ;

printk("Result of reg1 * reg2 = %08x

",reg3) ;

return 0; // indicate a success

}

}

void io_driver_exit(void)

{

printk("Release Memory Region...

") ;

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
 
Posts: 3
Joined: Tue Oct 16, 2007 7:44 am

RE:Cross Compilation Errors PPC (Driver Module)

Postby renergy » Tue Oct 16, 2007 2:24 pm

Maybe its a problem of the crosscompiler version? But a compiled the Kernel for the PPC with this toolchain...
renergy
 
Posts: 3
Joined: Tue Oct 16, 2007 7:44 am

RE:Cross Compilation Errors PPC (Driver Module)

Postby renergy » Tue Oct 16, 2007 8:32 pm

Problem solved! Only the slash was missing in front of the kerneldir :) (thanks to my fellow student)
renergy
 
Posts: 3
Joined: Tue Oct 16, 2007 7:44 am


Return to Embedded Linux questions & answers

Who is online

Users browsing this forum: No registered users and 1 guest

cron