Find the answer to your Linux question:
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 22
hi to all, i started sample driver in suse linux10.1 and the following is the gcc command to compile the simple helloworld program gcc -D__KERNEL__ -DMODULE -DMODVERSIONS -O2 -Wall -I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2007
    Posts
    41

    Post problem in compiling a sample driver


    hi to all, i started sample driver in suse linux10.1 and the following is the gcc command to compile the simple helloworld program

    gcc -D__KERNEL__ -DMODULE -DMODVERSIONS -O2 -Wall -I /usr/src/linux/include -o client3.o -c client3.c

    but ended with the following errors please can anyone help me for this problem .thank you

    following is the source code

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

    int init_module(void)
    {
    printk("<1>Hello World!\n");
    return 0;
    }

    void cleanup_module(void)
    {
    printk(KERN_ALERT "Goodbye World...\n");
    }

    following are errors


    client3.c:227:1: warning: "MODULE" redefined
    <command line>:1:1: warning: this is the location of the previous definition
    In file included from /usr/src/linux/include/asm/processor.h:18,
    from /usr/src/linux/include/asm/thread_info.h:17,
    from /usr/src/linux/include/linux/thread_info.h:21,
    from /usr/src/linux/include/linux/preempt.h:10,
    from /usr/src/linux/include/linux/spinlock.h:50,
    from /usr/src/linux/include/linux/capability.h:45,
    from /usr/src/linux/include/linux/sched.h:7,
    from /usr/src/linux/include/linux/module.h:10,
    from client3.c:229:
    /usr/src/linux/include/asm/system.h: In function ‘__set_64bit_var’:
    /usr/src/linux/include/asm/system.h:210: warning: dereferencing type-punned pointer will break strict-aliasing rules
    /usr/src/linux/include/asm/system.h:210: warning: dereferencing type-punned pointer will break strict-aliasing rules
    In file included from /usr/src/linux/include/linux/rwsem.h:27,
    from /usr/src/linux/include/asm/semaphore.h:42,
    from /usr/src/linux/include/linux/sched.h:20,
    from /usr/src/linux/include/linux/module.h:10,
    from client3.c:229:
    /usr/src/linux/include/asm/rwsem.h: In function ‘__down_read’:
    /usr/src/linux/include/asm/rwsem.h:106: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
    /usr/src/linux/include/asm/rwsem.h: In function ‘__down_write’:
    /usr/src/linux/include/asm/rwsem.h:158: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
    /usr/src/linux/include/asm/rwsem.h: In function ‘__up_read’:
    /usr/src/linux/include/asm/rwsem.h:195: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
    /usr/src/linux/include/asm/rwsem.h:189: warning: unused variable ‘tmp’
    /usr/src/linux/include/asm/rwsem.h: In function ‘__up_write’:
    /usr/src/linux/include/asm/rwsem.h:221: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
    /usr/src/linux/include/asm/rwsem.h: In function ‘__downgrade_write’:
    /usr/src/linux/include/asm/rwsem.h:246: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
    In file included from /usr/src/linux/include/linux/sched.h:20,
    from /usr/src/linux/include/linux/module.h:10,
    from client3.c:229:
    /usr/src/linux/include/asm/semaphore.h: In function ‘down’:
    /usr/src/linux/include/asm/semaphore.h:105: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
    /usr/src/linux/include/asm/semaphore.h: In function ‘down_interruptible’:
    /usr/src/linux/include/asm/semaphore.h:130: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
    /usr/src/linux/include/asm/semaphore.h: In function ‘down_trylock’:
    /usr/src/linux/include/asm/semaphore.h:155: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
    /usr/src/linux/include/asm/semaphore.h: In function ‘up’:
    /usr/src/linux/include/asm/semaphore.h:179: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
    In file included from /usr/src/linux/include/asm/smp.h:18,
    from /usr/src/linux/include/linux/smp.h:19,
    from /usr/src/linux/include/linux/sched.h:26,
    from /usr/src/linux/include/linux/module.h:10,
    from client3.c:229:
    /usr/src/linux/include/asm/mpspec.h:6:25: error: mach_mpspec.h: No such file or directory
    In file included from /usr/src/linux/include/asm/smp.h:18,
    from /usr/src/linux/include/linux/smp.h:19,
    from /usr/src/linux/include/linux/sched.h:26,
    from /usr/src/linux/include/linux/module.h:10,
    from client3.c:229:
    /usr/src/linux/include/asm/mpspec.h: At top level:
    /usr/src/linux/include/asm/mpspec.h:8: error: ‘MAX_MP_BUSSES’ undeclared here (not in a function)
    /usr/src/linux/include/asm/mpspec.h:23: error: ‘MAX_IRQ_SOURCES’ undeclared here (not in a function)
    In file included from /usr/src/linux/include/linux/smp.h:19,
    from /usr/src/linux/include/linux/sched.h:26,
    from /usr/src/linux/include/linux/module.h:10,
    from client3.c:229:
    /usr/src/linux/include/asm/smp.h:77:26: error: mach_apicdef.h: No such file or directory
    In file included from /usr/src/linux/include/linux/smp.h:19,
    from /usr/src/linux/include/linux/sched.h:26,
    from /usr/src/linux/include/linux/module.h:10,
    from client3.c:229:
    /usr/src/linux/include/asm/smp.h: In function ‘hard_smp_processor_id’:
    /usr/src/linux/include/asm/smp.h:81: warning: implicit declaration of function ‘GET_APIC_ID’

  2. #2
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    The code seems to be correct, try this makefile:

    Code:
    obj−m += client3.o
    all:
    	make −C /lib/modules/$(shell uname −r)/build M=$(PWD) modules
    clean:
    	make −C /lib/modules/$(shell uname −r)/build M=$(PWD) clean
    Save the file as Makefile. Pay attention of the tabs before the make commands, these must be real tabs!

    Regards

  3. #3
    Just Joined!
    Join Date
    Mar 2007
    Posts
    41
    sir, thanks for your reply. i changed the makefile as follows,

    obj−m += client3.o
    all:
    make -C /lib/modules/2.6.16.21.0.25-smp/build M=/home/umesh/usbclnt modules
    clean:
    make −C /lib/modules/2.6.16.21-0.25-smp/build M=/home/umesh/usbclnt clean


    the output is

    make -C /lib/modules/2.6.16.21.0.25-smp/build M=/home/umesh/usbclnt modules
    make: *** /lib/modules/2.6.16.21.0.25-smp/build: No such file or directory. Stop.
    make: *** [all] Error 2
    again where i am going wrong i work on x86 processor. thank you waiting for your kind reply

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    Did you also try it as I mentioned?

    Regards

  6. #5
    Just Joined!
    Join Date
    Mar 2007
    Posts
    41
    sir, i tried as you told too, but i got the result as,

    make -C /lib/modules/2.6.16.21.0.25-smp/build M=/home/umesh/usbclnt modules
    make: *** /lib/modules/2.6.16.21.0.25-smp/build: No such file or directory. Sto p.
    make: *** [all] Error 2

  7. #6
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    You must have kernel-headers/source installed that match your kernel.
    Perhaps you have incomplete kernel headers or source installed.
    Search at the net for information how you can install the proper headers/source of your distro.
    Also take a read of this:

    http://tldp.org/LDP/lkmpg/2.6/html/index.html

    especially this chapter:

    http://tldp.org/LDP/lkmpg/2.6/html/x44.html#AEN44

    Regards

  8. #7
    Just Joined!
    Join Date
    Mar 2007
    Posts
    41

    insmod error

    hi sir, when i am trying to insert the kernal object(.ko) or object file (.o) from usr/src/<linux version>/drivers/usb/serial/<drivername>.ko or /usr/<linux version>/drivers/usb/serial/<drivername>.o that results into the following error could u help me , waiting for your valuable suggestions


    linux-3mcp:/usr/src/linux-2.6.16.21-0.25/drivers/usb/serial # insmod ezusb.o
    insmod: error inserting 'ezusb.o': -1 Invalid module format
    linux-3mcp:/usr/src/linux-2.6.16.21-0.25/drivers/usb/serial # insmod ./ezusb.o
    insmod: error inserting './ezusb.o': -1 Invalid module format
    linux-3mcp:/usr/src/linux-2.6.16.21-0.25/drivers/usb/serial # ./ezusb.o
    bash: ./ezusb.o: Permission denied
    linux-3mcp:/usr/src/linux-2.6.16.21-0.25/drivers/usb/serial # chmod 777 ezusb.o
    linux-3mcp:/usr/src/linux-2.6.16.21-0.25/drivers/usb/serial # ./ezusb.o
    bash: ./ezusb.o: cannot execute binary file
    linux-3mcp:/usr/src/linux-2.6.16.21-0.25/drivers/usb/serial # insmod ./ezusb.o
    insmod: error inserting './ezusb.o': -1 Invalid module format
    linux-3mcp:/usr/src/linux-2.6.16.21-0.25/drivers/usb/serial # insmod usbserial.ko
    insmod: error inserting 'usbserial.ko': -1 Invalid module format

  9. #8
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    Hi,

    Check the kernel log by running dmesg and check (the first line) with which version of gcc your kernel was compiled.
    Your driver must also compiled with the same version. Compare the version with your C compiler. You can check the version with:
    Code:
    gcc --version
    Regards

  10. #9
    Just Joined!
    Join Date
    Mar 2007
    Posts
    41
    sir , i tried what u said and the following messages are

    linux-3mcp:/usr/src/linux-2.6.16.21-0.25 # gcc --version
    gcc (GCC) 4.1.0 (SUSE Linux)
    Copyright (C) 2006 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    linux-3mcp:/home/umesh # gcc --version
    gcc (GCC) 4.1.0 (SUSE Linux)
    Copyright (C) 2006 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    linux-3mcp:/home/umesh # dmesg
    Linux version 2.6.16.21-0.25-smp (geeko@buildhost) (gcc version 4.1.0 (SUSE Linux)) #1 SMP Tue Sep 19 07:26:15 UTC 2006


    i work on Pentium D (dual core) does this supports suse linux 10.1 .And as earlier you gave a makefile i producing different types of output (errors too) and even i gave importance to tab spaces as you said and only once i compiled but the object file(output file) was missing and later i produced the following error once

    make −C /lib/modules/2.6.16.21-0.25-smp/build M=/home/umesh/usbclntmodules
    make[1]: Entering directory `/home/umesh/usbclnt'
    make[1]: *** No rule to make target `−C'. Stop.
    make[1]: Leaving directory `/home/umesh/usbclnt'
    make: *** [all] Error 2
    linux-3mcp:/home/umesh/usbclnt #

    Actually i am working for usb , i need to write a driver for CY7C64613(EZ USB) interfaced to BF537 while compiling the driver i got stuck so i am doing all this process .thanks for your immediate reply

  11. #10
    Just Joined! vijay_kernel's Avatar
    Join Date
    Apr 2007
    Posts
    77
    Please let me know if the problem is not solved.

Page 1 of 3 1 2 3 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •