Results 1 to 5 of 5

Thread: Driver Hello World example in Ubuntu

  1. #1
    Join Date
    Jun 2013
    Beans
    3

    Question Driver Hello World example in Ubuntu

    Hi, i have in the same folder the following archives:

    hello.c

    Code:
    #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);
    Makefile

    Code:
    obj-m += hello.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
    When i run the command
    Code:
    make
    in the folder where there is this archives, i get:

    Code:
    make -C /lib/modules/3.5.0-34-generic/build M=/home/johann/Desktop/8º Período/Infra-Estrutura de Software/driver-linux modulesmake[1]: Entering directory `/usr/src/linux-headers-3.5.0-34-generic'
    make[1]: *** No rule to make target `Período/Infra-Estrutura'.  Stop.
    make[1]: Leaving directory `/usr/src/linux-headers-3.5.0-34-generic'
    make: *** [all] Error 2
    What am i missing? Thanks in advance

  2. #2
    Join Date
    Feb 2008
    Location
    Land of fire and drought
    Beans
    Hidden!
    Distro
    Xubuntu

    Re: Driver Hello World example in Ubuntu

    Thread moved to Programming Talk.

  3. #3
    Join Date
    Jun 2010
    Beans
    92

    Re: Driver Hello World example in Ubuntu

    Quote Originally Posted by johanngomes View Post
    Hi, i have in the same folder the following archives:

    hello.c

    Code:
    #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);
    Makefile

    Code:
    obj-m += hello.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
    When i run the command
    Code:
    make
    in the folder where there is this archives, i get:

    Code:
    make -C /lib/modules/3.5.0-34-generic/build M=/home/johann/Desktop/8º Período/Infra-Estrutura de Software/driver-linux modules
    make[1]: Entering directory `/usr/src/linux-headers-3.5.0-34-generic'
    make[1]: *** No rule to make target `Período/Infra-Estrutura'.  Stop.
    make[1]: Leaving directory `/usr/src/linux-headers-3.5.0-34-generic'
    make: *** [all] Error 2
    What am i missing? Thanks in advance

    The folder's path contains spaces. Create a folder with no spaces in the path:
    /home/johann/drivers/hello

  4. #4
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,288
    Distro
    Kubuntu

    Re: Driver Hello World example in Ubuntu

    Quote Originally Posted by johanngomes View Post
    What am i missing? Thanks in advance
    It's not what your missing, but what you have. You have white-space in your directory names, and that is confusing the 'make' command. Simply surrounding the $(PWD) with double-quotes will not solve the problem. Thus unless someone else chimes in with a brilliant suggestion, my suggestion right now is for you to rename your directories to eliminate the white-space.

    For example:
    Code:
    /home/johann/Desktop/8ºPeríodo/Infra-EstruturaDeSoftware/driver-linux

  5. #5
    Join Date
    Mar 2010
    Location
    Dhaka, Bangladesh
    Beans
    210
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Driver Hello World example in Ubuntu

    Quote Originally Posted by johanngomes View Post
    Hi, i have in the same folder the following archives:

    hello.c

    Code:
    #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);
    Makefile

    Code:
    obj-m += hello.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
    When i run the command
    Code:
    make
    in the folder where there is this archives, i get:

    Code:
    make -C /lib/modules/3.5.0-34-generic/build M=/home/johann/Desktop/8º Período/Infra-Estrutura de Software/driver-linux modulesmake[1]: Entering directory `/usr/src/linux-headers-3.5.0-34-generic'
    make[1]: *** No rule to make target `Período/Infra-Estrutura'.  Stop.
    make[1]: Leaving directory `/usr/src/linux-headers-3.5.0-34-generic'
    make: *** [all] Error 2
    What am i missing? Thanks in advance
    I have written a similar thing few years back, and faced same sort of problems, I fixed it by not using any space in the directory names and instead of $(PWD) I had to use $(shell pwd), I still have no idea why $(PWD) did not work...

    Here is the example http://zobayer.blogspot.com/2011/07/simple-character-device.html

Bookmarks

Posting Permissions

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