QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1496|回复: 2

如何往uClinux 内核中添加自己应用程序

[复制链接]
发表于 2006-5-25 14:52:50 | 显示全部楼层 |阅读模式
请问各位,如何往uClinux 内核中添加自己应用程序?
急!
2天了!
发表于 2006-5-25 20:31:30 | 显示全部楼层
内核里怎么添加应用程序????
楼主加油,等你知道怎么加的时候,帮忙吧 X 加进去~~~




PS:你看看 gensplash ,他好像会在内核里放个应用。
但应该是 initrd 的。
回复

使用道具 举报

 楼主| 发表于 2006-5-26 09:06:01 | 显示全部楼层
小弟终于搞明白了,随便编了个小程序,编译、下载、运行都成功。
原来uClinux的文档里就有一个介绍你如何添加应用程序的文件:
      /uClinux-dist/Documents/Adding-User-Apps-HOWTO
只要按照这个文件所说的方法去做就行啦,这个文件的内容如下(里面的英文内容全部都是原文,中文是本人添加的):
Adding User Applications to the uClinux Distribution
----------------------------------------------------

D. P. Siddons
9th Dec. 2001


This document gives simple instructions for adding a user-written application to
the uClinux configuration system. Entries must be added to three files, and an
apropriate Makefile must exist in the user application source directory, which
must be put in user (all directory names here are given relative to the uClinux
top directory. In my system this is /home/peter/uClinux-dist).  

Files to edit:

user/Makefile
   Add a line to the file like
   
   dir_$(CONFIG_USER_FOO_FOO)            += foo   (这里原"foo"就是你的应用程序名,比如应用程序ping可以写成:CONFIG_USER_PING_PING    +=ping)
   
   This adds the directory 'foo' to the list of directories to be built. I added
   mine in alphabetical order. The order doesn't seem to matter.
  
config/Configure.help
   This file contains the text which is presented on request during the
config.
   Add a block like
   
   CONFIG_USER_FOO_FOO
     This program does fooey things to your bars.
   
   The text must be indented two spaces, and there must be no empty lines. Lines
   should be <70 chars long.

config/config.in在这个文件里,每个被加载的应用程序都有一个项比如ls,ping,rm等程序,每个项都以两行"********************"隔开,大家可以参考些已经的项来添加你自己的应用程序)
   Add a line in the apropriate menu section (i.e. in the program group you want
   your app to show up in during 'make config'; I used 'misc'), like
   
   bool 'foo'           CONFIG_USER_FOO_FOO
   
   The repetition of FOO allows for directories which contain multiple
   executables. Thus, if the user directory 'foo' contained code to make 'foo'
   and 'bar', each gets its own config line if an additional entry is made like
   
   bool 'bar'           CONFIG_USER_FOO_BAR  
   

Next, there needs to be a proper /user/foo/Makefile. The Makefile should follow
the following template:

   --------------------------------------------   
   EXEC = foo
   OBJS = foo.o

   all: $(EXEC)

   $(EXEC): $(OBJS)
        $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)

   romfs:
        $(ROMFSINST)    /bin/$(EXEC)

   clean:
        -rm -f $(EXEC) *.elf *.gdb *.o
   ---------------------------------------------
   
   If more than one executable is built in the foo directory, as above, then the
   Makefile should look like
   
   ------------------------------------------------------------
   EXECS = foo bar
   OBJS = foo.o bar.o

   all: $(EXECS)

   $(EXECS): $(OBJS)
        $(CC) $(LDFLAGS) -o $@ [email protected] $(LDLIBS)

   romfs:
        $(ROMFSINST) -e CONFIG_USER_FOO_FOO             /bin/foo
        $(ROMFSINST) -e CONFIG_USER_FOO_BAR             /bin/bar
   --------------------------------------------------------------
   
   More complex makefiles are of course possible. The reader is encouraged to
   browse the user tree for examples.
   
   When all this is set up, doing the standard 'make xconfig; make dep; make'
   should build the app and install it in romfs and hence in the target system
   image.bin.

在你的makefile写完后,先make你自己写的应用程序
然后再回来uClinux-dist目录下执行以下命令:
make menuconfig
make dep
make lib_only
make user_only
make romfs
make image
make
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-23 08:49 , Processed in 0.043899 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表