IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Linux Discussion :

Problème compilation - Drivers


Sujet :

Linux

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Août 2002
    Messages
    168
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2002
    Messages : 168
    Points : 123
    Points
    123
    Par défaut Problème compilation - Drivers
    Bonsoir,
    J'essai de suivre le tuto suivant : http://broux.developpez.com/articles/c/driver-c-linux/

    Donc 1ere chose, je tente de compiler le code d'exemple et c'est là que mon premier obstacle apparait...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    #define MODULE
    #include <linux/module.h>
    #include <linux/init.h>
     
    static int __init mon_module_init(void)
    {
    	printk(KERN_DEBUG "Hello World !\n");
    	return 0;
    }
     
    static void __exit mon_module_cleanup(void)
    {
        printk(KERN_DEBUG "Goodbye World!\n");
    }
     
    module_init(mon_module_init);
    module_exit(mon_module_cleanup);
    Ma commande pour compiler le tout :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    gcc -c -I/usr/src/linux-headers-2.6.17-10-386/include/ module.c
    Et le résultat... Je dois avouer que je suis un peu perdu... Les erreurs viennent de fichiers systèmes on dirait :/

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    In file included from /usr/src/linux-headers-2.6.17-10-386/include/linux/bitops.h:9,
                     from /usr/src/linux-headers-2.6.17-10-386/include/linux/thread_info.h:20,
                     from /usr/src/linux-headers-2.6.17-10-386/include/linux/preempt.h:9,
                     from /usr/src/linux-headers-2.6.17-10-386/include/linux/spinlock.h:49,
                     from /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:10,
                     from module.c:2:
    /usr/src/linux-headers-2.6.17-10-386/include/asm/bitops.h:244: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’
    In file included from /usr/src/linux-headers-2.6.17-10-386/include/linux/spinlock.h:56,
                     from /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:10,
                     from module.c:2:
    /usr/src/linux-headers-2.6.17-10-386/include/asm/system.h:307: error: expected declaration specifiers or ‘...’ before ‘u8’
    /usr/src/linux-headers-2.6.17-10-386/include/asm/system.h:307: error: expected declaration specifiers or ‘...’ before ‘u8’
    /usr/src/linux-headers-2.6.17-10-386/include/asm/system.h:308: error: expected declaration specifiers or ‘...’ before ‘u16’
    /usr/src/linux-headers-2.6.17-10-386/include/asm/system.h:308: error: expected declaration specifiers or ‘...’ before ‘u16’
    /usr/src/linux-headers-2.6.17-10-386/include/asm/system.h:309: error: expected declaration specifiers or ‘...’ before ‘u32’
    /usr/src/linux-headers-2.6.17-10-386/include/asm/system.h:309: error: expected declaration specifiers or ‘...’ before ‘u32’
    /usr/src/linux-headers-2.6.17-10-386/include/asm/system.h: In function ‘cmpxchg_386’:
    /usr/src/linux-headers-2.6.17-10-386/include/asm/system.h:316: error: too many arguments to function ‘cmpxchg_386_u8’
    /usr/src/linux-headers-2.6.17-10-386/include/asm/system.h:318: error: too many arguments to function ‘cmpxchg_386_u16’
    /usr/src/linux-headers-2.6.17-10-386/include/asm/system.h:320: error: too many arguments to function ‘cmpxchg_386_u32’
    In file included from /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:86,
                     from /usr/src/linux-headers-2.6.17-10-386/include/asm/processor.h:22,
                     from /usr/src/linux-headers-2.6.17-10-386/include/asm/atomic.h:5,
                     from /usr/src/linux-headers-2.6.17-10-386/include/linux/spinlock.h:230,
                     from /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:10,
                     from module.c:2:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_zero’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:128: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:128: error: (Each undeclared identifier is reported only once
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:128: error: for each function it appears in.)
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:132: warning: incompatible implicit declaration of built-in function ‘memset’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_fill’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:141: warning: incompatible implicit declaration of built-in function ‘memset’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:143: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_copy’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:149: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:153: warning: incompatible implicit declaration of built-in function ‘memcpy’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_and’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:160: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_or’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:169: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_xor’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:178: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_andnot’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:187: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_complement’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:196: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_equal’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:205: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_intersects’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:214: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_subset’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:223: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_empty’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:231: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_full’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:239: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_shift_right’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:253: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_shift_left’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:262: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
    In file included from /usr/src/linux-headers-2.6.17-10-386/include/asm/processor.h:22,
                     from /usr/src/linux-headers-2.6.17-10-386/include/asm/atomic.h:5,
                     from /usr/src/linux-headers-2.6.17-10-386/include/linux/spinlock.h:230,
                     from /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:10,
                     from module.c:2:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: At top level:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:88: error: expected specifier-qualifier-list before ‘DECLARE_BITMAP’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpu_set’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:94: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpu_clear’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:100: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_setall’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:106: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_clear’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:112: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpu_test_and_set’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:121: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_and’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:128: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:128: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:128: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_or’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:135: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:135: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:135: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_xor’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:142: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:142: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:142: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_andnot’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:150: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:150: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:150: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_complement’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:157: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:157: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_equal’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:164: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:164: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_intersects’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:171: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:171: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_subset’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:178: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:178: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_empty’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:184: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_full’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:190: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_weight’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:196: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_shift_right’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:204: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:204: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_shift_left’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:212: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:212: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpumask_scnprintf’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:273: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpumask_parse’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:281: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpulist_scnprintf’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:289: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpulist_parse’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:295: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpu_remap’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:303: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:303: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_remap’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:311: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:311: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:311: error: ‘cpumask_t’ has no member named ‘bits’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:311: error: ‘cpumask_t’ has no member named ‘bits’
    In file included from /usr/src/linux-headers-2.6.17-10-386/include/asm/atomic.h:5,
                     from /usr/src/linux-headers-2.6.17-10-386/include/linux/spinlock.h:230,
                     from /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:10,
                     from module.c:2:
    /usr/src/linux-headers-2.6.17-10-386/include/asm/processor.h: At top level:
    /usr/src/linux-headers-2.6.17-10-386/include/asm/processor.h:76: error: ‘CONFIG_X86_L1_CACHE_SHIFT’ undeclared here (not in a function)
    /usr/src/linux-headers-2.6.17-10-386/include/asm/processor.h:76: error: requested alignment is not a constant
    In file included from /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:11,
                     from module.c:2:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/list.h:838:2: warning: #warning "don't include kernel headers in userspace"
    In file included from /usr/src/linux-headers-2.6.17-10-386/include/asm/local.h:4,
                     from /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:20,
                     from module.c:2:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/percpu.h: In function ‘__alloc_percpu’:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/percpu.h:44: error: ‘GFP_KERNEL’ undeclared (first use in this function)
    /usr/src/linux-headers-2.6.17-10-386/include/linux/percpu.h:44: warning: initialization makes pointer from integer without a cast
    /usr/src/linux-headers-2.6.17-10-386/include/linux/percpu.h:46: warning: incompatible implicit declaration of built-in function ‘memset’
    In file included from /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:22,
                     from module.c:2:
    /usr/src/linux-headers-2.6.17-10-386/include/asm/module.h:60:2: error: #error unknown processor family
    In file included from module.c:2:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h: At top level:
    /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:49: error: field ‘attr’ has incomplete type
    /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:60: error: field ‘kobj’ has incomplete type
    /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:561: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inter_module_register’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:563: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inter_module_unregister’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:564: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inter_module_get_request’
    /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:566: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inter_module_put’
    module.c: In function ‘mon_module_init’:
    module.c:7: error: ‘KERN_DEBUG’ undeclared (first use in this function)
    module.c:7: error: expected ‘)’ before string constant
    module.c: In function ‘mon_module_cleanup’:
    module.c:13: error: ‘KERN_DEBUG’ undeclared (first use in this function)
    module.c:13: error: expected ‘)’ before string constant
    Merci pour votre aide, remarques ou suggestion de tout arrêter

    Edit : Ptite précision, je suis sous Ubuntu 6.10 !

  2. #2
    Expert éminent sénior
    Avatar de Skyounet
    Homme Profil pro
    Software Engineer
    Inscrit en
    Mars 2005
    Messages
    6 380
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Software Engineer
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2005
    Messages : 6 380
    Points : 13 380
    Points
    13 380
    Par défaut
    Pour les noyaux 2.6, il faut utiliser un makefile.

    Le Makefile est donné dans le tuto.

    Avec le kernel 2.6, le #define MODULE est inutile.

    Pour le kernel 2.6, on peut utiliser cette commande :
    # make

    Avec le makefile suivant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    obj-m : module.o
     
    default:
    	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
     
    clean:
    	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
    Introduction à Silverlight 4 (new) ; Localisation d'une application Silverlight (new) ;
    Mon espace perso[/B]

    La connaissance s’acquiert par l’expérience, tout le reste n’est que de l’information. Albert Einstein[/SIZE]

  3. #3
    Membre régulier
    Profil pro
    Inscrit en
    Août 2002
    Messages
    168
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2002
    Messages : 168
    Points : 123
    Points
    123
    Par défaut
    D'accord, je n'avais pas essayé le makefile, car j'avais lu "on peut" et non "il faut"... J'essai cette alternative !

    Merci à toi !

  4. #4
    Expert éminent sénior
    Avatar de Skyounet
    Homme Profil pro
    Software Engineer
    Inscrit en
    Mars 2005
    Messages
    6 380
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Software Engineer
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2005
    Messages : 6 380
    Points : 13 380
    Points
    13 380
    Par défaut
    Citation Envoyé par Alexandre`
    D'accord, je n'avais pas essayé le makefile, car j'avais lu "on peut" et non "il faut"... J'essai cette alternative !

    Merci à toi !
    C'est ce que j'ai écris .

    Je vais rectifier.
    Introduction à Silverlight 4 (new) ; Localisation d'une application Silverlight (new) ;
    Mon espace perso[/B]

    La connaissance s’acquiert par l’expérience, tout le reste n’est que de l’information. Albert Einstein[/SIZE]

  5. #5
    Expert éminent
    Avatar de Michaël
    Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Juillet 2003
    Messages
    3 497
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux

    Informations forums :
    Inscription : Juillet 2003
    Messages : 3 497
    Points : 8 237
    Points
    8 237
    Par défaut
    salut,
    je pense que ton makefile n'est pas correct pour les noyaux 2.6. il ne génère pas de module pour les noyaux 2.6 mais pour les noyaux 2.4 (extension .o au lieu de .ko pour les 2.6). une manière simple de s'en rendre compte est d'insérer le module dans le noyau avecet ça dit
    insmod: error inserting 'module.o': -1 Invalid module format
    tu peux d'ailleurs voir dans la log
    Feb 3 10:03:44 debian kernel: No module found in object

    pour corriger ça, il faut changerenet là ça génère les bons fichiers

  6. #6
    Expert éminent sénior
    Avatar de Skyounet
    Homme Profil pro
    Software Engineer
    Inscrit en
    Mars 2005
    Messages
    6 380
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Software Engineer
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2005
    Messages : 6 380
    Points : 13 380
    Points
    13 380
    Par défaut
    Citation Envoyé par Michaël
    salut,
    je pense que ton makefile n'est pas correct pour les noyaux 2.6. il ne génère pas de module pour les noyaux 2.6 mais pour les noyaux 2.4 (extension .o au lieu de .ko pour les 2.6). une manière simple de s'en rendre compte est d'insérer le module dans le noyau avecet ça dittu peux d'ailleurs voir dans la log


    pour corriger ça, il faut changerenet là ça génère les bons fichiers
    Exact

    Je viens de regarder un de mes Makefile et c'est ce qu'il y a dedans. Je vais rectifier.

    EDIT : réctifié
    Introduction à Silverlight 4 (new) ; Localisation d'une application Silverlight (new) ;
    Mon espace perso[/B]

    La connaissance s’acquiert par l’expérience, tout le reste n’est que de l’information. Albert Einstein[/SIZE]

  7. #7
    Membre régulier
    Profil pro
    Inscrit en
    Août 2002
    Messages
    168
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2002
    Messages : 168
    Points : 123
    Points
    123
    Par défaut
    En utilisant le Makefile, tout fonctionne !
    Merci à vous !

  8. #8
    Membre régulier
    Profil pro
    Inscrit en
    Août 2002
    Messages
    168
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2002
    Messages : 168
    Points : 123
    Points
    123
    Par défaut
    Je reviens un peu à la charge avec un nouveau souci.

    Je ne sais pas si c'est du à la version du kernel mais je n'arrive pas à utiliser les macros pour les paramètres (MODULE_PARAM).

    J'ai ce message à la compilation :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    make -C /lib/modules/2.6.17-10-generic/build M=/home/alexandre/devs/C/drivers/0.1 modules
    make[1]: entrant dans le répertoire « /usr/src/linux-headers-2.6.17-10-generic »
      CC [M]  /home/alexandre/devs/C/drivers/0.1/module.o
    /home/alexandre/devs/C/drivers/0.1/module.c:11: error: expected declaration specifiers or ‘...’ before string constant
    /home/alexandre/devs/C/drivers/0.1/module.c:11: error: expected declaration specifiers or ‘...’ before string constant
    /home/alexandre/devs/C/drivers/0.1/module.c:11: warning: data definition has no type or storage class
    /home/alexandre/devs/C/drivers/0.1/module.c:11: warning: type defaults to ‘int’ in declaration of ‘MODULE_PARAM’
    /home/alexandre/devs/C/drivers/0.1/module.c:11: warning: function declaration isn’t a prototype
    /home/alexandre/devs/C/drivers/0.1/module.c:12: error: expected declaration specifiers or ‘...’ before string constant
    /home/alexandre/devs/C/drivers/0.1/module.c:12: error: expected declaration specifiers or ‘...’ before string constant
    /home/alexandre/devs/C/drivers/0.1/module.c:12: warning: data definition has no type or storage class
    /home/alexandre/devs/C/drivers/0.1/module.c:12: warning: type defaults to ‘int’ in declaration of ‘MODULE_PARAM_DESC’
    /home/alexandre/devs/C/drivers/0.1/module.c:12: warning: function declaration isn’t a prototype
    make[2]: *** [/home/alexandre/devs/C/drivers/0.1/module.o] Erreur 1
    make[1]: *** [_module_/home/alexandre/devs/C/drivers/0.1] Erreur 2
    make[1]: quittant le répertoire « /usr/src/linux-headers-2.6.17-10-generic »
    make: *** [default] Erreur 2
    Si je commente ça la compilation se passe bien... J'ai regarder dans l'entête module.h et j'ai pas trouvé de macro MODULE_PARAM... Est-ce normal ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    //MODULE_PARAM("param", "i");
    //MODULE_PARAM_DESC("param", "Paramètre de test");
    Merci de votre aide !

  9. #9
    Expert éminent sénior
    Avatar de Skyounet
    Homme Profil pro
    Software Engineer
    Inscrit en
    Mars 2005
    Messages
    6 380
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Software Engineer
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2005
    Messages : 6 380
    Points : 13 380
    Points
    13 380
    Par défaut
    Alors là grosse erreur de ma part, mais vraiment enorme je fais un gros mea-culpa, c'est pas

    MODULE_PARAM mais MODULE_PARM
    Introduction à Silverlight 4 (new) ; Localisation d'une application Silverlight (new) ;
    Mon espace perso[/B]

    La connaissance s’acquiert par l’expérience, tout le reste n’est que de l’information. Albert Einstein[/SIZE]

  10. #10
    Membre régulier
    Profil pro
    Inscrit en
    Août 2002
    Messages
    168
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2002
    Messages : 168
    Points : 123
    Points
    123
    Par défaut
    C'est incroyable, avant de poster je cherchais des infos la dessus et je tombe sur :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    The MODULE_PARM() macro has been replaced by explicit parameter declarations made using the new module_param() macro.
    Et après 4/5 lectures, j'ai toujours pas remarqué le A manquant....

    J'aurais du faire attention.

    Merci à toi ! Je test ça ce soir.

  11. #11
    Membre régulier
    Profil pro
    Inscrit en
    Août 2002
    Messages
    168
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2002
    Messages : 168
    Points : 123
    Points
    123
    Par défaut
    J'ai toujours un problème à la compilation et celui-ci semble toujours lié à l'utilisation de paramètres :/

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    make -C /lib/modules/2.6.17-11-generic/build M=/home/alexandre/devs/C/drivers/0.1 modules
    make[1]: entrant dans le répertoire « /usr/src/linux-headers-2.6.17-11-generic »
      CC [M]  /home/alexandre/devs/C/drivers/0.1/module.o
    /home/alexandre/devs/C/drivers/0.1/module.c:11: error: expected declaration specifiers or ‘...’ before string constant
    /home/alexandre/devs/C/drivers/0.1/module.c:11: error: expected declaration specifiers or ‘...’ before string constant
    /home/alexandre/devs/C/drivers/0.1/module.c:11: warning: data definition has no type or storage class
    /home/alexandre/devs/C/drivers/0.1/module.c:11: warning: type defaults to ‘int’ in declaration of ‘MODULE_PARM’
    /home/alexandre/devs/C/drivers/0.1/module.c:11: warning: function declaration isn’t a prototype
    /home/alexandre/devs/C/drivers/0.1/module.c:12:1: error: pasting "__mod_" and ""param"" does not give a valid preprocessing token
    /home/alexandre/devs/C/drivers/0.1/module.c:12:1: error: pasting ""param"" and "12" does not give a valid preprocessing token
    /home/alexandre/devs/C/drivers/0.1/module.c:12: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before string constant
    make[2]: *** [/home/alexandre/devs/C/drivers/0.1/module.o] Erreur 1
    make[1]: *** [_module_/home/alexandre/devs/C/drivers/0.1] Erreur 2
    make[1]: quittant le répertoire « /usr/src/linux-headers-2.6.17-11-generic »
    make: *** [default] Erreur 2
    Si vous avez une ptit idée du problème ?
    Merci !

  12. #12
    Expert éminent sénior
    Avatar de Skyounet
    Homme Profil pro
    Software Engineer
    Inscrit en
    Mars 2005
    Messages
    6 380
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Software Engineer
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2005
    Messages : 6 380
    Points : 13 380
    Points
    13 380
    Par défaut
    Ben avec le code ça serait bien.

    Introduction à Silverlight 4 (new) ; Localisation d'une application Silverlight (new) ;
    Mon espace perso[/B]

    La connaissance s’acquiert par l’expérience, tout le reste n’est que de l’information. Albert Einstein[/SIZE]

  13. #13
    Membre régulier
    Profil pro
    Inscrit en
    Août 2002
    Messages
    168
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2002
    Messages : 168
    Points : 123
    Points
    123
    Par défaut
    Désolé

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    #include <linux/module.h>
    #include <linux/init.h>
     
    MODULE_AUTHOR("Alexandre J.");
    MODULE_DESCRIPTION("test module");
    MODULE_SUPPORTED_DEVICE("none");
    MODULE_LICENSE("none");
     
    static int param;
     
    MODULE_PARM("parame", "i");
    MODULE_PARM_DESC("param", "Paramètre de test");
     
    static int __init mon_module_init(void)
    {
    	printk(KERN_DEBUG "Hello World !\n");
    	printk(KERN_DEBUG "parametre=%d \n", param);
    	return 0;
    }
     
    static void __exit mon_module_cleanup(void)
    {
        printk(KERN_DEBUG "Goodbye World!\n");
    }
     
    module_init(mon_module_init);
    module_exit(mon_module_cleanup);
    Merci

  14. #14
    Expert éminent sénior
    Avatar de Skyounet
    Homme Profil pro
    Software Engineer
    Inscrit en
    Mars 2005
    Messages
    6 380
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Software Engineer
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2005
    Messages : 6 380
    Points : 13 380
    Points
    13 380
    Par défaut
    Citation Envoyé par Alexandre`
    Désolé

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    #include <linux/module.h>
    #include <linux/init.h>
     
    MODULE_AUTHOR("Alexandre J.");
    MODULE_DESCRIPTION("test module");
    MODULE_SUPPORTED_DEVICE("none");
    MODULE_LICENSE("none");
     
    static int param;
     
    MODULE_PARM("parame", "i");
    MODULE_PARM_DESC("param", "Paramètre de test");
     
    static int __init mon_module_init(void)
    {
    	printk(KERN_DEBUG "Hello World !\n");
    	printk(KERN_DEBUG "parametre=%d \n", param);
    	return 0;
    }
     
    static void __exit mon_module_cleanup(void)
    {
        printk(KERN_DEBUG "Goodbye World!\n");
    }
     
    module_init(mon_module_init);
    module_exit(mon_module_cleanup);
    Merci
    Essaye ça

    Code c : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
     
    #include <linux/module.h>
    #include <linux/init.h>
     
    MODULE_AUTHOR("Alexandre J.");
    MODULE_DESCRIPTION("test module");
    MODULE_SUPPORTED_DEVICE("none");
    MODULE_LICENSE("none");
     
    static int param;
     
    MODULE_PARM_DESC(param, "Paramètre de test");
    MODULE_PARM(parame, "i");
     
    static int __init mon_module_init(void)
    {
    	printk(KERN_DEBUG "Hello World !\n");
    	printk(KERN_DEBUG "parametre=%d \n", param);
    	return 0;
    }
     
    static void __exit mon_module_cleanup(void)
    {
        printk(KERN_DEBUG "Goodbye World!\n");
    }
     
    module_init(mon_module_init);
    module_exit(mon_module_cleanup);
    Introduction à Silverlight 4 (new) ; Localisation d'une application Silverlight (new) ;
    Mon espace perso[/B]

    La connaissance s’acquiert par l’expérience, tout le reste n’est que de l’information. Albert Einstein[/SIZE]

  15. #15
    Membre régulier
    Profil pro
    Inscrit en
    Août 2002
    Messages
    168
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2002
    Messages : 168
    Points : 123
    Points
    123
    Par défaut
    J'ai beaucoup moins d'erreur en passant la var sans le mettre entre "" :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    make -C /lib/modules/2.6.17-11-generic/build M=/home/alexandre/devs/C/drivers/0.1 modules
    make[1]: entrant dans le répertoire « /usr/src/linux-headers-2.6.17-11-generic »
      CC [M]  /home/alexandre/devs/C/drivers/0.1/module.o
    /home/alexandre/devs/C/drivers/0.1/module.c:12: error: expected ‘)’ before string constant
    make[2]: *** [/home/alexandre/devs/C/drivers/0.1/module.o] Erreur 1
    make[1]: *** [_module_/home/alexandre/devs/C/drivers/0.1] Erreur 2
    make[1]: quittant le répertoire « /usr/src/linux-headers-2.6.17-11-generic »
    make: *** [default] Erreur 2
    Avec le code suivant (j'avais une ptite faute avant, j'avais laissé trainer un e)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    #include <linux/module.h>
    #include <linux/init.h>
     
    MODULE_AUTHOR("Alexandre J.");
    MODULE_DESCRIPTION("test module");
    MODULE_SUPPORTED_DEVICE("none");
    MODULE_LICENSE("none");
     
    static int param;
     
    MODULE_PARM_DESC(param, "Paramètre de test");
    MODULE_PARM(param, "i");
     
    static int __init mon_module_init(void)
    {
    	printk(KERN_DEBUG "Hello World !\n");
    	printk(KERN_DEBUG "parametre=%d \n", param);
    	return 0;
    }
     
    static void __exit mon_module_cleanup(void)
    {
        printk(KERN_DEBUG "Goodbye World!\n");
    }
     
    module_init(mon_module_init);
    module_exit(mon_module_cleanup);
    Merci

  16. #16
    Expert éminent sénior
    Avatar de Skyounet
    Homme Profil pro
    Software Engineer
    Inscrit en
    Mars 2005
    Messages
    6 380
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Software Engineer
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2005
    Messages : 6 380
    Points : 13 380
    Points
    13 380
    Par défaut
    Alors là je vois pas vraiment.

    Je tente de compiler le code sur une machine virtuelle (c'est pas gagné ).
    Introduction à Silverlight 4 (new) ; Localisation d'une application Silverlight (new) ;
    Mon espace perso[/B]

    La connaissance s’acquiert par l’expérience, tout le reste n’est que de l’information. Albert Einstein[/SIZE]

  17. #17
    Membre régulier
    Profil pro
    Inscrit en
    Août 2002
    Messages
    168
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2002
    Messages : 168
    Points : 123
    Points
    123
    Par défaut
    oki merci je continue de mon côté.

  18. #18
    Expert éminent sénior
    Avatar de Skyounet
    Homme Profil pro
    Software Engineer
    Inscrit en
    Mars 2005
    Messages
    6 380
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Software Engineer
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2005
    Messages : 6 380
    Points : 13 380
    Points
    13 380
    Par défaut
    Ayé j'ai trouvé
    Aparamment MODULE_PARM est déprécié, et on doit desormais utiliser module_param()

    Donc pour toi ça donne

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    module_param(param, int, 0);
    Le dernier argument c'est les permissions de bits (pas très bien compris faut que je regarde plus en détail).
    Introduction à Silverlight 4 (new) ; Localisation d'une application Silverlight (new) ;
    Mon espace perso[/B]

    La connaissance s’acquiert par l’expérience, tout le reste n’est que de l’information. Albert Einstein[/SIZE]

  19. #19
    Membre régulier
    Profil pro
    Inscrit en
    Août 2002
    Messages
    168
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2002
    Messages : 168
    Points : 123
    Points
    123
    Par défaut
    Effectivement tout fonctionne !
    Je cais regarder de plus pret cette fonction.

    En tout cas merci bcp

  20. #20
    Membre régulier
    Profil pro
    Inscrit en
    Août 2002
    Messages
    168
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2002
    Messages : 168
    Points : 123
    Points
    123
    Par défaut
    Si tu veux, je peux te donner les ptits points qui coincent avec ton tuto au fur et à mesure que j'avance.

    unregister_chrdev(); prend 2 paramètres (dans ma configuration) :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    int   unregister_chrdev(unsigned  int  major,  const  char *name);
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ret = unregister_chrdev(major, "module_test");
    Edit :

    Il semble manquer le "file" dans les entêtes de fonction de my_read_function et write (entre struct et *file).

Discussions similaires

  1. Problème compilation driver ethernet
    Par bogsy15 dans le forum Debian
    Réponses: 3
    Dernier message: 20/02/2007, 20h50
  2. Problème compilation (toolkit Maximum Entropy)
    Par yannick_frere dans le forum MFC
    Réponses: 4
    Dernier message: 07/03/2005, 09h47
  3. Problème compilation Version 8.0.1 sous Debian Sarge
    Par LIndien dans le forum PostgreSQL
    Réponses: 1
    Dernier message: 04/02/2005, 21h38
  4. [tomcat] [jsp] Problème avec driver OCI pour oracle
    Par nanardcompanie dans le forum Tomcat et TomEE
    Réponses: 3
    Dernier message: 01/07/2004, 09h54
  5. [Kylix] problème compilation kylix3 avec redhat 9.0
    Par madininaoursa dans le forum EDI
    Réponses: 1
    Dernier message: 02/07/2003, 16h21

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo