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 s...
Altera_Forum
Honored Contributor
21 years agoPrevious answer is not enough to build a module independantly from Kernel. My goal is to have my source files on a separate directory (which is handled by a Software Configuration Manager, here ClearCase) with a Makefile to generate the .o module file.
I try to get back the compilation options from the .xxx.o.cmd file in kernel/build/drivers directory. I can now compile files and generate a module without any warning nor error. But this .o file is not recognized by insmod : it gives the following error message : No module found in object insmod: cannot insert "testModule_mod.o": Invalid module format (-1): Exec format error Here is the Makefile (a little bit ... complicated !). With this Makefile, I tried to re-compile one Kernel driver, and I'm very surprise to find an object with a different size (124kb instead of 126kb) : I surely made a mistake, but I can't see where (no errors, no warning... but a little small difference !).all: testModule_mod.o
testModule_mod.o: testModule.o
nios2-elf-ld -mnios2elf -r -o testModule_mod.o testModule.o
testModule.o: testModule.c Makefile
nios2-elf-gcc -nostdinc -Wp,-MD,.testModule.o.d -iwithprefix include -D__KERNEL__ -Iinclude -Iinclude2 -I/cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x/include -I/cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x/ -I$(LIBMYKERNEL) -I$(LIBKERNEL) -D__KERNEL__ -I/cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x/include -Iinclude -I/cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x/include2 -Iinclude2 -I/cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.kernel_0.1.5/linux-2.6.x/include -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -DNO_MM -pipe -D__linux__ -D__ELF__ -DNO_TEXT_SECTIONS -fno-builtin -O2 -g -G 0 -DUTS_SYSNAME=\"uClinux\" -I/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc-lib/nios2-elf/3.3.3/include -O2 -fomit-frame-pointer -DKBUILD_BASENAME=testModule -DMODULE -c -o testModule.o testModule.c