Forum Discussion

20 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    insmod: cannot insert `/lib/modules/2.6.16-uc0/kernel/drivers/misc/hello.ko': Invalid module format (-1): Exec format error
    modprobe: failed to load module hello

    I have the same problem!

    If you comment out the whole if (vma->vm_file) {} block in do_mmap_private(), then the function will make a private copy and modules seem to insert ok.

    In my linux-2.6.x/mm/nommu.c file there seems not to be any do_mmap_private function... :-( Anyway... is a little strange that the error could be in the nommu.c, isn't it? Because if it were, it should fail to everybody... I think.

    I have a question regarding the Makefile posted by wgoosens. I've tried to compile a module with this makefile, but it seems to me that there is something missing in it, because when I try to run make, it says

    <div class='quotetop'>QUOTE </div>

    --- Quote Start ---

    make -k all

    make: Nothing to be done for `all&#39;.[/b]

    --- Quote End ---

    Maybe it&#39;s very simple, but I don&#39;t know what to add. To my eyes, it seems that I should add the objects to be compiled, for example, but I don&#39;t exactly how to do it.

    What am I missing?

    Thank you

    AleX
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    originally posted by abg@Jul 21 2006, 02:16 AM

    in my linux-2.6.x/mm/nommu.c file there seems not to be any do_mmap_private function... :-( anyway... is a little strange that the error could be in the nommu.c, isn&#39;t it? because if it were, it should fail to everybody... i think.

    <div align='right'><{post_snapback}> (index.php?act=findpost&pid=17035)

    --- quote end ---

    --- Quote End ---

    The error isn&#39;t in nommu.c - its just where I worked around it. The error comes from the call to a file mmap via a function pointer, which then returns NULL.

    Which version of the source are you using? If its a bit older, your do_mmap_private may be rolled up into do_mmap_pgoff (also in nommu.c)

    Anyway, I believe the reason module loading is failing is because of the ramfs_nommu_mmap function being a stub (see linux-2.6.x/fs/ramfs/file-nommu.c)...

    int ramfs_nommu_mmap(struct file *file, struct vm_area_struct *vma)
    {
        return 0;
    }

    Shouldn&#39;t this be setting vma->vm_start to something at least?

    If your modules reside somewhere other than ramfs, everything seems to work OK. Try loading your modules from a filesystem on a CF card or something...

    Mike
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    originally posted by abg@Jul 20 2006, 10:16 AM

    ...

    i have a question regarding the makefile posted by wgoosens. i&#39;ve tried to compile a module with this makefile, but it seems to me that there is something missing in it, because when i try to run make, it says

    <div class='quotetop'>quote

    --- quote end ---

    --- quote start ---

    make -k all

    make: nothing to be done for `all&#39;.

    --- Quote End ---

    Maybe it&#39;s very simple, but I don&#39;t know what to add. To my eyes, it seems that I should add the objects to be compiled, for example, but I don&#39;t exactly how to do it.

    What am I missing?

    Thank you

    AleX

    <div align='right'><{post_snapback}> (index.php?act=findpost&pid=17035)</div>

    [/b]

    --- Quote End ---

    You should name your objects in the obj-m variable.

    If your module is named module.c make sure you have

    # If KERNELRELEASE is defined, we&#39;ve been invoked from the#  kernel build system and can use its language.
    ifneq ($(KERNELRELEASE),)
    obj-m := module.o#  Otherwise we were called directly from the command#  line; invoke the kernel build system.
    else
    KERNELDIR = /usr/src/cross/linux-2.6.11
    PWD := $(shell pwd)
    default:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
    endif

    Is see that in the Makefile I posted I listed hello.ko and it should be .o NOT .ko

    Next execute make as you would when compiling the kernel:

    ARCH=nios2nommu CROSS_COMPILE=nios2-linux-uclibc- make

    I hope these two steps will help you!
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    originally posted by miked@Jul 21 2006, 02:43 AM

    if your modules reside somewhere other than ramfs, everything seems to work ok. try loading your modules from a filesystem on a cf card or something...

    --- Quote End ---

    I have the same problem when the module reside in ramfs. When I move it to a jffs2 file system, the module loads fine.

    Hein
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi!

    I have been using the Makefile proposed by "wgoosens", and it worked. But now I have seen that I have to use the uClinux kernel 2.4.x, and it doesn&#39;t work with it. Someone knows a way to compile modules with uClinux kernel 2.4.x?

    If anybody asks, I have to use version 2.4 because I&#39;m porting code that was compiled with linux 2.4, and I&#39;ve found many things different (include files, and more) that makes the porting less straightforward.

    thank you

    aLeX
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    mmm... it&#39;s possible that uClinux doesn&#39;t have nios2 port in version 2.4.x? I can see somewhat referencing "niosnommu", but not nios2...

    aLeX
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    originally posted by miked@Jul 21 2006, 02:43 AM

    anyway, i believe the reason module loading is failing is because of the ramfs_nommu_mmap function being a stub (see linux-2.6.x/fs/ramfs/file-nommu.c)...

    int ramfs_nommu_mmap(struct file *file, struct vm_area_struct *vma)
    {
        return 0;
    }

    shouldn&#39;t this be setting vma->vm_start to something at least?

    if your modules reside somewhere other than ramfs, everything seems to work ok. try loading your modules from a filesystem on a cf card or something...

    mike

    <div align='right'><{post_snapback}> (index.php?act=findpost&pid=17040)</div>

    --- Quote End ---

    I had the same problem when boa was serving files from ramfs using mmap. Looks like it is fixed in kernel version 2.6.18. ramfs_nommu_mmap now looks like this:

    int ramfs_nommu_mmap(struct file *file, struct vm_area_struct *vma)
    {
            return vma->vm_flags & VM_SHARED ? 0 : -ENOSYS;
    }

    I changed this in my kernel version 2.6.16 and now my boa problem was gone.

    Hein
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    originally posted by repa@Jun 30 2006, 10:36 AM

    ...

    during "make modules_install" i got these, after "install drivers/misc/hello.ko" and right before the end of the make:
    if ; then ../user/busybox/examples/depmod.pl -l vmlinux -ae -f system.map -b /root/uclinux-dist-test/romfs/lib/modules -r 2.6.16-uc0; fi
    unknown option: ae
    unknown option: r

    --- Quote End ---

    Hi,

    Was this issue resolved?

    I am facing the same problem while following the ModuleProgramming Wiki.

    (I prefer to dynamically load my modules)

    Thanks,

    Didi
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    originally posted by didi+jan 3 2007, 03:01 am--><div class='quotetop'>quote (didi @ jan 3 2007, 03:01 am)</div>

    --- quote start ---

    <!--quotebegin-repa@Jun 30 2006, 10:36 AM

    ...

    during "make modules_install" i got these, after "install drivers/misc/hello.ko" and right before the end of the make:
    if ; then ../user/busybox/examples/depmod.pl -l vmlinux -ae -f system.map -b /root/uclinux-dist-test/romfs/lib/modules -r 2.6.16-uc0; fi
    unknown option: ae
    unknown option: r

    --- Quote End ---

    Hi,

    Was this issue resolved?

    I am facing the same problem while following the ModuleProgramming Wiki.

    (I prefer to dynamically load my modules)

    Thanks,

    Didi

    <div align='right'><{post_snapback}> (index.php?act=findpost&pid=20326)</div>

    [/b]

    --- Quote End ---

    The later uClinux-dist-20060803 and nios2 patches do not have such issue. The wiki was updated. And don&#39;t use "make modules_install".

    Run "make" and "make linux image" .
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    originally posted by repa@Jun 29 2006, 09:17 AM

    i follow http://nioswiki.jot.com/wikihome/operating...duleprogarmming (http://nioswiki.jot.com/wikihome/operatingsystems/moduleprogarmming) but when i type in "modprobe hello" what i get is "modprobe could not parse modules.dep".

    /lib/modules/modules.dep is empty, which could explain why it couldn&#39;t be parsed...

    i followed the instructions all the way. any ideas where i could have gone wrong?

    <div align='right'><{post_snapback}> (index.php?act=findpost&pid=16511)

    --- quote end ---

    --- Quote End ---

    I got this message some times, till i notice that when kernel is loading - it display its building time, and this time wasn&#39;t my recent build.

    So it&#39;s possible for some reason that you successfully download new build (with the driver) but the board run old build (without the driver) and so you get this message.

    (In such case I can see twice "Uncompressing Linux..." message).

    After some repeating downloads, the new build ran at last, and the driver also load successfully.