- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
When build the hello_world.c, I encount a error, Is any one can help me out? the hello_world.c as follows:#include <linux/init.h># include <linux/module.h># include <linux/kernel.h>
static int hello_init(void)
{
printk (KERN_ALERT "Hello, world!\n");
return 0;
}
static void hello_exit (void)
{
printk (KERN_ALERT "Goodbye, cruel world\n");
}
module_init (hello_init);
module_exit (hello_exit);
MODULE_LICENSE("Dual BSD/GPL");
and the problem as follows: $ nios2-linux-uclibc-gcc linux-2.6.x/drivers/misc/hello.c -o hello -elf2flt="-s 4000"
In file included from /opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/linux/sched.h:16,
from /opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/linux/module.h:9,
from linux-2.6.x/drivers/misc/hello.c:6:
/opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/linux/signal.h:2:2: warning:# warning "You should include <signal.h>. This time I will do it for you."
In file included from /opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/linux/sched.h:79,
from /opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/linux/module.h:9,
from linux-2.6.x/drivers/misc/hello.c:6:
/opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/linux/resource.h:2:2: warning:# warning "You should include <sys/resource.h>. This time I will do it for you."
In file included from /opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/asm/cache.h:25,
from /opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/linux/cache.h:5,
from /opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/linux/module.h:10,
from linux-2.6.x/drivers/misc/hello.c:6:
/opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/asm/nios.h:4:26: nios2_system.h: No such file or directory
In file included from linux-2.6.x/drivers/misc/hello.c:6:
/opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/linux/module.h:41: error: field `attr' has incomplete type
/opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/linux/module.h:49: error: field `kobj' has incomplete type
linux-2.6.x/drivers/misc/hello.c: In function `hello_init':
linux-2.6.x/drivers/misc/hello.c:14: error: `KERN_ALERT' undeclared (first use in this function)
linux-2.6.x/drivers/misc/hello.c:14: error: (Each undeclared identifier is reported only once
linux-2.6.x/drivers/misc/hello.c:14: error: for each function it appears in.)
linux-2.6.x/drivers/misc/hello.c:14: error: syntax error before string constant
linux-2.6.x/drivers/misc/hello.c: In function `hello_exit':
linux-2.6.x/drivers/misc/hello.c:19: error: `KERN_ALERT' undeclared (first use in this function)
linux-2.6.x/drivers/misc/hello.c:19: error: syntax error before string constant
It says the 'KERN_ALERT' was not declared, but what try 'make', it has no problem. Is that it need include other files in hello_world.c? How to build executable file for nios independent? I hope anyone can help me out? ths!
Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
didn't you try
make ARCH=nios2nommu CROSS_COMPILE=nios2-linux-uclibc- -C ~/uClinux-dist/linux-2.6.x M=`pwd` modules
which you will need to compile device drivers instead of nios2-linux-uclibc-gcc linux-2.6.x/drivers/misc/hello.c -o hello -elf2flt="-s 4000"
which suits for user programm. You will find detailed explanation in the kernel docs. hope this helps, but i'm not a kernel crack maybe you take a look at the nioswiki for the module programming example. by the way let me ask you, what do you want to do? do you want to write a device driver or a user program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by helmchen@Feb 3 2007, 10:52 PM didn't you try
make arch=nios2nommu cross_compile=nios2-linux-uclibc- -c ~/uclinux-dist/linux-2.6.x m=`pwd` modules
which you will need to compile device drivers
instead of
nios2-linux-uclibc-gcc linux-2.6.x/drivers/misc/hello.c -o hello -elf2flt="-s 4000"
which suits for user programm.
you will find detailed explanation in the kernel docs.
hope this helps, but i'm not a kernel crack
maybe you take a look at the nioswiki for the module programming example.
by the way let me ask you, what do you want to do?
do you want to write a device driver or a user program.
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=21184)</div> --- Quote End --- hi Helmchen, thank you very much for your reply, I'm porting uCLinux on my own NiosII board, and start develope programme according to hippo's post: http://forum.niosforum.com/forum/index.php?showtopic=3174 (http://forum.niosforum.com/forum/index.php?showtopic=3174) when come to 11 tips, I have tied code he provided: -----------------
nios2-linux-uclibc-gcc hello.c -o hello -elf2flt
cp hello ~/rootfs/bin
Rebuild the kernel image for initramfs, boot nios2 uClinux, and run hello
----------------- Here the 'hello.c' is a user programme, I mistake it to a device driver, and use nios2-linux-uclibc-gcc linux-2.6.x/drivers/misc/hello.c -o hello -elf2flt="-s 4000"
which is applied for user programme, so got the errors. Now I write a "hello world" user programme, and compiled successfully according the code. Thanks again! And I have a question: I have make a "hello_world" module which is a simple device driver, but I can only dynamic add it by "modprobe hello_world". Do you know how to add it with static method,namely add this module in when the kernel start?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
<div class='quotetop'>QUOTE </div>
--- Quote Start --- Do you know how to add it with static method,namely add this module in when the kernel start?[/b] --- Quote End --- Again please read about module programming in the nioswiki. nioswiki/module programming (http://nioswiki.jot.com/wikihome/operatingsystems/%c2%b5clinux/moduleprogramming)- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
<div class='quotetop'>QUOTE </div>
--- Quote Start --- Do you know how to add it with static method,namely add this module in when the kernel start?[/b] --- Quote End --- Device Drivers --> Misc devices ---> <*> example hello module Press <Space> several times to select the mode of the driver, <M> is module <*> is static linked to kernel < > unselect- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to know where i can find the hello module after the image is download into the DE2.Is it in the dir of /bin? but i can not find it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by liuxiaoping@Mar 25 2007, 09:57 PM i want to know where i can find the hello module after the image is download into the de2.is it in the dir of /bin? but i can not find it.
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=22486)
--- quote end ---
--- Quote End --- All kernel modules will be in the /lib/modules/ <kernel version> tree. Don't mix up kernel modules with user apps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To hippo:
I am very sorry for my mistake,in fact,i did not find the module in the dir /lib,not /bin.In the dir of bin,i use the command ls,but there is only a file,i don't know why?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Make sure you have the hello.c in linux-2.6.x/drivers/misc, and you have updated Kconfig an Makefile in that dir.
After "make" and "make linux images", in the uClinux-dist dir, please check if you have the hello.ko "tree linux-2.6.x/drivers/misc" "tree romfs/lib" Or you may check some other drivers or fs as modules, and find the modules of them.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page