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++
12600 Discussions

Kernel module compiling/loading

Altera_Forum
Honored Contributor II
947 Views

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