Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
21 years ago

Kernel module compiling/loading

Hello,

After a couple of days of trying, we've finally successfully compiled a 'hello world' module and was able to load it under NiosII uClinux v1.3. Along the way we found 2 bugs that caused major problems:

1) Problem:

Stage 2 of the module compile doesn't work under Cygwin (Nios II SDK shell). The modpost.exe program is not correctly reading in the Module.symvers file since Module.symvers has DOS line endings.

Solution:

run dos2unix on Module.symvers (in the kernel build directory) before trying to compile your module. A better solution would be to fix modpost.exe (read_dump() function in scripts/mod/modpost.c) to handle DOS line endings.

2) Problem:

Module wouldn't load using insmod. Unresolved symbol error for printk.

After tracking this down we found that the problem was that the ksymtab table was not long-word aligned.

Solution:

Change /linux-2.6.x/arch/nios2nommu/kernel/vmlinux.lds.S to add

. = ALIGN(4);

before the ksymtab section. So it should look something like:

/* Kernel symbol table: Normal symbols */

. = ALIGN(4);

__start___ksymtab = .;

*(__ksymtab)

__stop___ksymtab = .;

These 2 changes fixed all of the problems we were seeing.

Hope this helps.

--

Terry Graessle
No RepliesBe the first to reply