Forum Discussion
Altera_Forum
Honored Contributor
20 years agoproblem with modules
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?20 Replies
- Altera_Forum
Honored Contributor
--- 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'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'll be flying!
- Altera_Forum
Honored Contributor
--- 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'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'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't make the dependencies? After "make menuconfig" it says I have to run "make dep" next, but when I do, it says that it's unnecessary now. Another problem: I can't find the module in uClinux, for some reason. What's the default location for it, if I've followed the instructions?
- Altera_Forum
Honored Contributor
--- 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's unnecessary now.
another problem: i can't find the module in uclinux, for some reason. what's the default location for it, if i'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't run that command (unless you know what you're doing). If you followed the huide your module will be in drivers/misc/hello.ko I don'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:
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:# If KERNELRELEASE is defined, we'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
or a similar command depending on your compiler. Hope this helps you!ARCH=nios2nommu CROSS_COMPILE=nios2-linux-uclibc- make - Altera_Forum
Honored Contributor
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 . - Altera_Forum
Honored Contributor
Thanks to you both, hello.ko is now included!
But now I get
when 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: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
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.gifif ; 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 - Altera_Forum
Honored Contributor
I had this problem before, but I can'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. - Altera_Forum
Honored Contributor
--- Quote Start --- originally posted by hippo@Jun 30 2006, 02:53 AM i had this problem before, but i can'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'm having this exact same problem ... Has anybody resolved the issue ?? Thanks in advance.
- Altera_Forum
Honored Contributor
Has anyone solved this one yet?
- Altera_Forum
Honored Contributor
--- 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'm not sure if it will work with the modprobe stuff. But if you use insmod it will work.
- Altera_Forum
Honored Contributor
--- 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't worked out why the original isn't working, but i'm sleepy http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif Hope this helps someone to work out the real issue... Mike