Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

problem with modules

Altera_Forum
Honored Contributor II
4,238 Views

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't be parsed... 

 

I followed the instructions all the way. Any ideas where I could have gone wrong?
0 Kudos
20 Replies
Altera_Forum
Honored Contributor II
2,357 Views

 

--- Quote Start ---  

originally posted by repa@Jun 29 2006, 02: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'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 ---  

 

modules.dep is the module dependency file. It only exists if you created module dependencies. If you build your module outside of the kernel tree your module won&#39;t be included. 

The good news: you can load your module with the insmod command. 

In the directory where your module is type: insmod hello.ko and you&#39;ll be flying!
0 Kudos
Altera_Forum
Honored Contributor II
2,357 Views

 

--- Quote Start ---  

originally posted by wgoossens@Jun 29 2006, 11:51 AM 

modules.dep is the module dependency file. it only exists if you created module dependencies. if you build your module outside of the kernel tree your module won&#39;t be included. 

the good news: you can load your module with the insmod command. 

in the directory where your module is type: insmod hello.ko and you&#39;ll be flying! 

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

--- quote end ---  

 

--- Quote End ---  

So the commands in the instructioncs don&#39;t make the dependencies? After "make menuconfig" it says I have to run "make dep" next, but when I do, it says that it&#39;s unnecessary now.  

 

Another problem: I can&#39;t find the module in uClinux, for some reason. What&#39;s the default location for it, if I&#39;ve followed the instructions?
0 Kudos
Altera_Forum
Honored Contributor II
2,357 Views

 

--- Quote Start ---  

originally posted by repa@Jun 29 2006, 05:12 AM 

(...) 

"make menuconfig" it says i have to run "make dep" next, but when i do, it says that it&#39;s unnecessary now.  

 

another problem: i can&#39;t find the module in uclinux, for some reason. what&#39;s the default location for it, if i&#39;ve followed the instructions? 

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

--- quote end ---  

 

--- Quote End ---  

 

 

In the 2.6 series the module dependencies are created when you run make modules_install. You probably shouldn&#39;t run that command (unless you know what you&#39;re doing).  

If you followed the huide your module will be in drivers/misc/hello.ko 

 

I don&#39;t want to question the way the examples works but I personally never write kernel modules INSIDE the kernel tree when developing them. I make a seperate directory with a makefile like: 

# If KERNELRELEASE is defined, we&#39;ve been invoked from the# kernel build system and can use its language. ifneq ($(KERNELRELEASE),)     obj-m := hello.ko# 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 

I found this somewhere on the net so: credits to the guy who wrote this (I forgot where I found it). 

You can make your module everywhere now.  

You should replace KERNELDIR with the correct directory for you and add your object to the obj-m variable. 

you can then build the code with: 

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

or a similar command depending on your compiler. 

 

Hope this helps you!
0 Kudos
Altera_Forum
Honored Contributor II
2,357 Views

Sorry, I forget to add modules_install in the wiki. 

It will install modules objects to romfs/lib/modules . 

Please run, in uClinux-dist-test dir, 

 

make 

make modules_install 

make linux image 

 

There is not need to run make dep in kernel 2.6 .
0 Kudos
Altera_Forum
Honored Contributor II
2,357 Views

Thanks to you both, hello.ko is now included!  

 

But now I get insmod: cannot insert `/lib/modules/2.6.16-uc0/kernel/drivers/misc/hello.ko&#39;: Invalid module format (-1): Exec format error modprobe: failed to load module hellowhen I try to modprobe it. Do I need a flag or something during making the kernel? 

 

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 

Yes, I work under root http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/wink.gif . I set up the linux just for this project, so no one else is using the computer and I can always reinstall linux if I manage to do some real damage http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif
0 Kudos
Altera_Forum
Honored Contributor II
2,357 Views

I had this problem before, but I can&#39;t recall if I had resolved it or not. Sorry. 

I will check again, and let you know later. 

Please try compile module into kernel, without module loading.
0 Kudos
Altera_Forum
Honored Contributor II
2,357 Views

 

--- Quote Start ---  

originally posted by hippo@Jun 30 2006, 02:53 AM 

i had this problem before, but i can&#39;t recall if i had resolved it or not. sorry. 

i will check again, and let you know later. 

please try compile module into kernel, without module loading. 

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

--- quote end ---  

 

--- Quote End ---  

 

 

I&#39;m having this exact same problem ... Has anybody resolved the issue ?? 

 

Thanks in advance.
0 Kudos
Altera_Forum
Honored Contributor II
2,357 Views

Has anyone solved this one yet?

0 Kudos
Altera_Forum
Honored Contributor II
2,357 Views

 

--- Quote Start ---  

originally posted by repa@Jul 9 2006, 11:48 PM 

has anyone solved this one yet? 

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

--- quote end ---  

 

--- Quote End ---  

 

I have made quite a few modules the way I described earlier outside of the kernel tree and it always worked (with the given Makefile). I&#39;m not sure if it will work with the modprobe stuff. But if you use insmod it will work.
0 Kudos
Altera_Forum
Honored Contributor II
2,357 Views

 

--- Quote Start ---  

originally posted by repa@Jul 10 2006, 03:48 PM 

has anyone solved this one yet? 

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

--- quote end ---  

 

--- Quote End ---  

 

 

Sort of...  

 

Discovered that mmap() is returning a NULL pointer during the module load. Seems that this comes from the call to ret = vma->vm_file->f_op->mmap(vma->vm_file, vma); in do_mmap_private() in linux-2.6.x/mm/nommu.c 

 

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. 

 

This seems like a big hack to me - I haven&#39;t worked out why the original isn&#39;t working, but i&#39;m sleepy http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif  

 

Hope this helps someone to work out the real issue... 

 

Mike
0 Kudos
Altera_Forum
Honored Contributor II
2,357 Views

insmod: cannot insert `/lib/modules/2.6.16-uc0/kernel/drivers/misc/hello.ko&#39;: 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&#39;t it? Because if it were, it should fail to everybody... I think. 

 

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 </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
0 Kudos
Altera_Forum
Honored Contributor II
2,357 Views

 

--- 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
0 Kudos
Altera_Forum
Honored Contributor II
2,357 Views

 

--- 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!
0 Kudos
Altera_Forum
Honored Contributor II
2,357 Views

 

--- 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
0 Kudos
Altera_Forum
Honored Contributor II
2,357 Views

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
0 Kudos
Altera_Forum
Honored Contributor II
2,357 Views

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
0 Kudos
Altera_Forum
Honored Contributor II
2,357 Views

 

--- 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
0 Kudos
Altera_Forum
Honored Contributor II
2,357 Views

 

--- 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
0 Kudos
Altera_Forum
Honored Contributor II
2,357 Views

 

--- 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" .
0 Kudos
Altera_Forum
Honored Contributor II
2,294 Views

 

--- 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.
0 Kudos
Reply