![]() |
|
Developing Applications and Modules for uClinux 2.4.x
by Tong Lai Yu and Felix Lo, July 2005
Developing Applications
Consider a simple example.
#include <stdlib.h>
#include <stdio.h>
int main( void )
{
printf("\nHello, Ocean Unicorn!\n");
return 0;
}
EXEC = tongdemo
OBJS = tongdemo.o
CFLAGS += -I.
all: $(EXEC)
$(EXEC): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
romfs:
$(ROMFSINST) /bin/$(EXEC)
clean:
-rm -f $(EXEC) *.elf *.gdb *.o
Add the following statment:
dir_$(CONFIG_USER_TONG_TONGDEMO) += tong
Add the following:
mainmenu_option next_comment comment 'Application of Tong' bool 'tongdemo' CONFIG_USER_TONG_TONGDEMO endmenu
Choose [*] Customize Vendor/User Settings (NEW)
In Application of Tong ---> , choose [*] tongdemo
Developing modules
Consier a simple example:
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
static int __init hello_init(void)
{
printk("Hello world from OU\n");
return 0;
}
static void __exit hello_exit(void)
{
printk("Byebye from OU\n");
}
module_init(hello_init);
module_exit(hello_exit);
EXPORT_NO_SYMBOLS;
If we have included in the kernel the applications ( commands ), lsmod, insmod, rmmod, then we should see something upon executing the commands. However, we have not succeeded in this part yet.
?Alternatively, we may need to enable the modules selection ( in make menuconfig ), and "make modules", "make modules_install" ...