Forum Discussion
Altera_Forum
Honored Contributor
21 years agoKernel development on Nios Linux 2.6 distribution
The Nios II Linux 2.6 distribution is not really biased for kernel development, but since this is all what I have, what way you suggest I should develop my drivers?
I understood importing the source files into a kernel project was good just for debugging the kernel, so that you actually see where you are going. So any changes should be made directly to the kernel directory in the Eclipse plug-in directory. Am I right? Okay, I can do the changes there, but how can I get them into the IDE reasonably? There's no "open file" option in the IDE! If I develop my driver as a module, could I just use the Linux application project as a basis and just fix the makefile so that it will be compiled as a module? Will there be a problem with the kernel include files? Thanks for any ideas in advance! -Tervis21 Replies
- Altera_Forum
Honored Contributor
Sorry, the error was in my Makefile (a blank space in my Kernel name).
However, I still have a problem coming from MODPOST :$ make make -C /cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x O=/cygdrive/c/altera/kits/nios2/bin/eclipse/workspace/KERNEL_MUX2/build SUBDIRS=/cygdrive/c/altera/kits/nios2/bin/eclipse/workspace/jgxeoe_driver modules make: Entering directory `/cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x' no emulation specific options. CC /cygdrive/c/altera/kits/nios2/bin/eclipse/workspace/jgxeoe_driver/JGXEOE.o /cygdrive/c/altera/kits/nios2/bin/eclipse/workspace/jgxeoe_driver/JGXEOE.c:51: warning: function declaration isn't a prototype … /cygdrive/c/altera/kits/nios2/bin/eclipse/workspace/jgxeoe_driver/.JGXEOE.o.d: done. Building modules, stage 2. MODPOST Signal 11 make: *** Error 139 make: *** Error 2 make: *** Error 2 make: Leaving directory `/cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x' make: *** Error 2 - Altera_Forum
Honored Contributor
I was talking with Marc the other day and I sent him an e-mail that I was hoping to get to you.
He sent me some additional info and I noticed that modpost was attempting to use the vmlinux file as input which isn't how the Makefile/modpost is supposed to work. Can you post or send me your Makefile as well as a directory listing of where you're compiling your module? Just so you know, I was able to compile a hello_world module using the same instructions that I posted before under the 1.3 distro so I'm fairly confident it works. Let's try to get you up and running. - Altera_Forum
Honored Contributor
omr22,
We just encountered the same problem you are seeing with modpost: Building modules, stage 2. MODPOST Signal 11 make[3]: *** [__modpost] Error 139 make[2]: *** [modules] Error 2 After much debugging, we finally tracked it down to the Modules.symvers file (which is generated when the kernel is compiled) has DOS line endings instead of unix. The read_dump() function in modpost.c is not properly parsing the symbols read in from this file which is causing the error you're seeing. If you run dos2unix on Modules.symvers to convert it to a unix text file before building your module it should build without error. When you compile your kernel, if you add the V=1 option to the make command you'll see much more information about the commands which are run. You should see a call to scripts/mod/modpost which has the Modules.symvers file as one of it's inputs. Even though we've apparently gotten the module to build without error; we're still having problems getting the module to load using busybox insmod: # insmod /modules/hello-1.ko insmod: cannot insert `/modules/hello-1.ko': Unknown symbol in module (-1): No such file or directory When I run it on the console I see additional error messages that indicate that the unresolved symbol is 'printk'. Has anyone else encountered this problem? Thanks, Terry - Altera_Forum
Honored Contributor
Hello,
I tried to build my kernel module hello.c as described in this contribution, using Makefile specified here. But make command executed from NIOSII shell returns following errors and, I understand that it needs appropriate ptf file, but I dont know what to do...
I hope someone can help, thank you, Jan$ make make -C /cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2l inux.kernel_0.1.5/linux-2.6.x O=/cygdrive/c/altera/kits/nios2/bin/eclipse/worksp ace/kernel_mod/build SUBDIRS=/cygdrive/c/altera/kits/nios2/bin/eclipse/workspace /kernel_mod modules make: Entering directory `/cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/c om.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x' /cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.ker nel_0.1.5/linux-2.6.x/Makefile:461: .config: No such file or directory no emulation specific options. /cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.ker nel_0.1.5/linux-2.6.x/arch/nios2nommu/Makefile:124: *** Run "make hwselect SYSPT F=<system.ptf>" first. Stop. make: *** Error 2 make: Leaving directory `/cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/co m.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x' make: *** Error 2 /cygdrive/c/altera/kits/nios2/bin/eclipse/workspace/kernel_mod $ - Altera_Forum
Honored Contributor
hello,
second call http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif I still did not solved - can anyone help me with the problem described in the text above? thanks, Jan - Altera_Forum
Honored Contributor
In the same directory, run the following command (let's assume the ptf file from the core is c:/work/project1/linux.ptf):
then you will be able to build the kernel.$ make hwselect SYSPTF=/cygdrive/c/work/project1/linux.ptf - Altera_Forum
Honored Contributor
hi wentao,
Problem still not solved, I tried as you wrote and this error occured (my project directory is kernel_mod):
I also tried to run this command in ...../linux-2.6.x/arch/nios2nomu dir, which contains Makefile, which produced the error with "hwselect" and I got another error:/cygdrive/c/altera/kits/nios2/bin/eclipse/workspace/kernel_mod $ make hwselect SYSPTF=/cygdrive/c/altera/kits/nios2/examples/ver ilog/niosII_cyclone_1c20/linux/linux_1c20.ptf make: *** No rule to make target `hwselect'. Stop. /cygdrive/c/altera/kits/nios2/bin/eclipse/workspace/kernel_mod $
it is clear to me, that I need to compile all together, but I dont know where or how to specify appropriate PTF and it also the mystery for me, why another users did not received this error... only for completion - I use nios2linux_1.3, with regards jan/cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.ker nel_0.1.5/linux-2.6.x/arch/nios2nommu $ make hwselect SYSPTF=/cygdrive/c/altera/kits/nios2/examples/ver ilog/niosII_cyclone_1c20/linux/linux_1c20.ptf gcc: No input files mkdir -p /arch/nios2nommu/ Can't open perl script "/arch/nios2nommu/scripts/hwselect.pl": No such file or d irectory make: *** Error 2 /cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.ker nel_0.1.5/linux-2.6.x/arch/nios2nommu $ - Altera_Forum
Honored Contributor
Hi jan,
I guess the command line "make hwselect ..." can be used only when you want to build kernel directly in the source tree. I will check this with Ken when he is back from vacation tomorrow. I am not using eclipse and able to run it directly from the root directory of the kernel source. Regards, wentao - Altera_Forum
Honored Contributor
--- Quote Start --- originally posted by ken@Nov 26 2004, 09:37 AM that's an extremely complicated makefile... have you tried using the makefile i provided in this thread? it does allow for building outside of the kernel tree. as a bonus, it also pulls in all the necessary rules for building the module properly from the original kernel source instead of requiring you to specify the rules manually.give it a try, and post any errors that you get when you try running "make". it worked like a charm when i did it.
in fact, here's the makefile tailored to your situation:
--- Quote End --- Hello, I used the Makefile you provided to compile my own simple Hello World kernel module. I want to build up a more sophisticated driver by adding calls to the Nios II HAL, but I can't get the module to compile whenever I include a HAL header file. For instance, addingconfig_test_mod=m ifneq ($(kernelrelease),) # this is the section of the makefile that builds the module inside the kernel obj-$(config_test_mod) := testmodule_mod.o else # this section is for building the module outside of the source# $(eclipse_workspace) is assumed to be defined externally by the environment # please reference the articles on http://www.lwn.net regarding# kernel module development for more information about this makefile kdir := $(kernel_plugin)/linux-2.6.x $(error you need to specify the kernel project that this module is being built for before this will work!)# delete the above line after you have modified the variable below to its proper setting kernel_project := your_kernel_project builddir := $(eclipse_workspace)/$(kernel_project)/build pwd := $(shell pwd) default: $(make) -c $(kdir) o=$(builddir) subdirs=$(pwd) modules endif
to#include "alt_types.h"
does not compile. Adding the proper directories to the include path using the Nios IDE does not fix the problem. Since we compile the kernel module using the Nios SDK Shell, adding the path in the IDE doesn't help, I suspect. I'd like to add#include <stdio.h> int main() { printf("Hello World\n"); return 0; }
to the Makefile you provided, but I'm not sure how to do it in a clean way (ie. without modifying %eclipse_plugins%/com.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x/Makefile). Summarizing, I would like to create a kernel module that calls HAL functions. Please explain how this can be done http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif Thank you, jwistead.-I<HAL directories> - Altera_Forum
Honored Contributor
Hello,
I am still having this problem, and I've tried *everything* I can think of to fix it myself. Please let me know if I can provide any more information to help solve it. Thank you, jwistead.