cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jonesyx
Observer
Observer
10,202 Views
Registered: ‎07-23-2009

Unable to compile drivers

Jump to solution

Ive been working through the "Embedded open-source linux development" materials and labs from Xilinx and am able to compile my own kernel and programs for an embedded target (ml507) however im coming into problems compiling drivers for the board.

 

I keep getting errors such as the following:

 

[mjones@desectlws004 hellodriver]$ make
make ARCH=ppc CROSS_COMPILE=powerpc-linux-uclibc- -C /home/mjones/emb_linux/kernel/work M=/home/mjones/emb_linux/kernel/work/drivers/hellodriver modules
make[1]: Entering directory `/home/mjones/emb_linux/kernel/linux_xilinx/2.6.25'
  CC [M]  /home/mjones/emb_linux/kernel/work/drivers/hellodriver/hello.o
  Building modules, stage 2.
  MODPOST 1 modules
WARNING: "printk" [/home/mjones/emb_linux/kernel/work/drivers/hellodriver/hello.ko] undefined!
  CC      /home/mjones/emb_linux/kernel/work/drivers/hellodriver/hello.mod.o
/home/mjones/emb_linux/kernel/work/drivers/hellodriver/hello.mod.c:8: error: variable ‘__this_module’ has initializer but incomplete type
/home/mjones/emb_linux/kernel/work/drivers/hellodriver/hello.mod.c:9: error: unknown field ‘name’ specified in initializer
/home/mjones/emb_linux/kernel/work/drivers/hellodriver/hello.mod.c:9: warning: excess elements in struct initializer
/home/mjones/emb_linux/kernel/work/drivers/hellodriver/hello.mod.c:9: warning: (near initialization for ‘__this_module’)
/home/mjones/emb_linux/kernel/work/drivers/hellodriver/hello.mod.c:10: error: unknown field ‘init’ specified in initializer
/home/mjones/emb_linux/kernel/work/drivers/hellodriver/hello.mod.c:10: warning: excess elements in struct initializer
/home/mjones/emb_linux/kernel/work/drivers/hellodriver/hello.mod.c:10: warning: (near initialization for ‘__this_module’)
/home/mjones/emb_linux/kernel/work/drivers/hellodriver/hello.mod.c:14: error: unknown field ‘arch’ specified in initializer
/home/mjones/emb_linux/kernel/work/drivers/hellodriver/hello.mod.c:14: error: ‘MODULE_ARCH_INIT’ undeclared here (not in a function)
/home/mjones/emb_linux/kernel/work/drivers/hellodriver/hello.mod.c:14: warning: excess elements in struct initializer
/home/mjones/emb_linux/kernel/work/drivers/hellodriver/hello.mod.c:14: warning: (near initialization for ‘__this_module’)
make[2]: *** [/home/mjones/emb_linux/kernel/work/drivers/hellodriver/hello.mod.o] Error 1
make[1]: *** [modules] Error 2
make[1]: Leaving directory `/home/mjones/emb_linux/kernel/linux_xilinx/2.6.25'
make: *** [all] Error 2

 

My Makefile is the following:

 

obj-m += hello.o


KDIR=/home/mjones/emb_linux/kernel/work
EXTRA_CFLAGS := -I$(KDIR)/include
all:
    make ARCH=ppc CROSS_COMPILE=powerpc-linux-uclibc- -C $(KDIR) M=$(PWD) modules
clean:
    make ARCH=ppc CROSS_COMPILE=powerpc-linux-uclibc- -C $(KDIR) M=$(PWD) clean

 

hello.c is the following:

 

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>

MODULE_LICENSE("GPL");


static int hello_init(void) {
  printk("<1> Hello world!\n");
  return 0;
}

static void hello_exit(void) {
  printk("<1> Bye, cruel world\n");
}

module_init(hello_init);
module_exit(hello_exit);

 

And the paths are as follows:

 

Folder of mydriver (hello.c) = /home/mjones/emb_linux/kernel/work/drivers/hellodriver

Folder of kernel work = /home/mjones/emb_linux/kernel/work or ($WORK/kernel/work)

 

 

Ive tried combinations of the paths and nothing seems to work. The powerpc-linux-uclibc-gcc works and I have compiled simple c programs with it.

 

Any help would be greatly appreciated.

 

Many Thanks

Michael.

 

0 Kudos
Reply
1 Solution

Accepted Solutions
linnj
Xilinx Employee
Xilinx Employee
12,731 Views
Registered: ‎09-10-2008

You need to get a clean tree and start from scratch.  I'm sorry to say, but I don't know the instructions that you are following there.  I have seen a course materials from Xilinx but it's been a long time, maybe it's out of date (sorry).

 

The wiki is the place that I can be sure of.  When you switch architectures like that, you may need to do make ARCH=.... mrproper as there are links in the kernel tree that must be setup corrrectly.

 

You need to get a good baseline (clean kernel tree from git) and follow the wiki to get the baseline. It should build and run on the Xilinx boards right out of the box.

 

-- John

View solution in original post

6 Replies
linnj
Xilinx Employee
Xilinx Employee
10,200 Views
Registered: ‎09-10-2008

Hi Michael,

 

ARCH=ppc is your problem.  ARCH ppc is no longer supported, you should be using ARCH=powerpc.  I'm not sure what documentation you're using, but the wiki, at http://xilinx.wikidot.com, should reflect that.

 

Give it a try and that should help. 

 

Thanks,

John

0 Kudos
Reply
jonesyx
Observer
Observer
10,254 Views
Registered: ‎07-23-2009

Well that make a difference, im not sure if good or bad: Compilation throws up even more errors now :

 

- See attached txt file, too big to post now.

 

Im using the "Embedded Open-Source Linux Development" workbook (embd22000-10-wkbp-rev1) from xilinx.

 

I set an envirnonment variable at the start ARCH=ppc however all the tools ive used such as the compiler are powerpc. Now ive changed the ARCH variable to powerpc my kernal won't compile anymore.Im being asked for step by step y/n questions on what to include, and errors such as the following:

 

include/linux/elf.h:30: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Elf64_Off’
include/linux/elf.h:31: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Elf64_Sword’
include/linux/elf.h:32: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Elf64_Word’
include/linux/elf.h:33: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Elf64_Xword’
include/linux/elf.h:34: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Elf64_Sxword’
include/linux/elf.h:128: error: expected specifier-qualifier-list before ‘Elf32_Sword’
include/linux/elf.h:136: error: expected specifier-qualifier-list before ‘Elf64_Sxword’
include/linux/elf.h:151: error: expected specifier-qualifier-list before ‘Elf32_Addr’
include/linux/elf.h:156: error: expected specifier-qualifier-list before ‘Elf64_Addr’
include/linux/elf.h:161: error: expected specifier-qualifier-list before ‘Elf32_Addr’
include/linux/elf.h:167: error: expected specifier-qualifier-list before ‘Elf64_Addr’

 

 

Is there a newer version of the workbook available?

0 Kudos
Reply
linnj
Xilinx Employee
Xilinx Employee
12,732 Views
Registered: ‎09-10-2008

You need to get a clean tree and start from scratch.  I'm sorry to say, but I don't know the instructions that you are following there.  I have seen a course materials from Xilinx but it's been a long time, maybe it's out of date (sorry).

 

The wiki is the place that I can be sure of.  When you switch architectures like that, you may need to do make ARCH=.... mrproper as there are links in the kernel tree that must be setup corrrectly.

 

You need to get a good baseline (clean kernel tree from git) and follow the wiki to get the baseline. It should build and run on the Xilinx boards right out of the box.

 

-- John

View solution in original post

jonesyx
Observer
Observer
10,135 Views
Registered: ‎07-23-2009

Thanks John,

 

Im going to have a look at that kernel, your help on this and my other thread is greatly appreciated.

 

Michael

0 Kudos
Reply
ccdoss
Participant
Participant
8,333 Views
Registered: ‎10-24-2008

I know this topic has been described as closed, but I followed the instructions on xilinx.wikidot.com, as well as followed the format in this thread, and am unable to compile my helloworld driver. Here's my setup:

in main directory:

  1. hwmodule.c:

#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "Hello, world\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world\n");
}
module_init(hello_init);
module_exit(hello_exit);

 

2. Makefile:

 

obj-m := hwmodule.o
KDIR=~/xlinux
EXTRA_CFLAGS := -I$(KDIR)/include
all:
   make ARCH=powerpc CROSS_COMPILE=powerpc-linux-uclibc- -C $(KDIR) M=$(PWD) modules
clean:
   make ARCH=powerpc CROSS_COMPILE=powerpc-linux-uclibc- -C $(KDIR) M=$(PWD) clean

 

The xlinux directory contains the git download of the Xilinx kernel. I have successfully built the kernel.

When I type make in the home directory, I get "Nothing to be done for 'all'"

What am I doing wrong?

0 Kudos
Reply
ccdoss
Participant
Participant
8,331 Views
Registered: ‎10-24-2008

For some reason, when I typed

make ARCH=powerpc CROSS_COMPILE=ppc_4xx- -C xlinux M=/home/christopher modules

it compiled it. So, I guess it's a problem with the makefile?

0 Kudos
Reply