天嵌 ARM开发社区

 找回密码
 注册
查看: 3624|回复: 4

invalid module format 问题?

[复制链接]
gilbert0571 发表于 2009-10-20 23:12:55 | 显示全部楼层 |阅读模式
程序:
/*  
*  hello-1.c - The simplest kernel module.
*/
#include <linux/module.h>        /* Needed by all modules */
#include <linux/kernel.h>        /* Needed for KERN_EMERG */

int init_module(void)
{
        printk("<0>Hello gilbert !\n");

        /*
         * A non 0 return means init_module failed; module can't be loaded.
         */
        return 1;
}

void cleanup_module(void
{
        printk( KERN_EMERG "Goodbye gilbert !\n");
}

module_init(init_module);
module_exit(cleanup_module);

makefile文件:

KERNELDIR = /opt/EmbedSky/linux-2.6.30.4 #你所使用内核的目录
PWD := $(shell pwd)
INSTALLDIR = /home/mylib/modules

CROSS_COMPILE    =arm-linux-
CC    = $(CROSS_COMPILE)gcc

obj-m := hello-1.o

modules:
        $(MAKE) -C $(KERNELDIR) M=$(PWD) modules

modules_install:
        cp hello-1.ko $(INSTALLDIR)

clean:
        rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions

.PHONY:
        modules modules_install clean

下到板子运行:
[root@EmbedSky /mnt]# insmod hello-1.ko
hello_1: version magic '2.6.30.4 mod_unload ARMv4 ' should be '2.6.30.4-EmbedSky
mod_unload ARMv4 '
insmod: cannot insert 'hello-1.ko': invalid module format

用的源码版本和gcc版本都是一样~怎么解决?
 楼主| gilbert0571 发表于 2009-10-20 23:36:51 | 显示全部楼层
问题找到了:我用的内核是直接从官网上下的!用自己编译的内核就能跑起来。现在要问的是官网的内核改了哪里?version magic '2.6.30.4 mod_unload ARMv4 ' should be '2.6.30.4-EmbedSky mod_unload ARMv4 '   多了个'-Embedsky'。怎么改啊~~?
亚瑟王 发表于 2009-10-22 10:23:47 | 显示全部楼层
你用的内核镜像是我们提供的话,我们配置内核时添加了EmbedSky的信息进去,解决办法:你用我们提供的内核镜像做为源头进行编译就可以了。
亚瑟王 发表于 2009-10-22 10:24:23 | 显示全部楼层
或者你使用你自己移植的内核源码编译的镜像和驱动模块,反正一句话,内核和驱动模块要配套。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号 )

GMT+8, 2024-5-18 07:14 , Processed in 1.046869 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表