您的位置:控制工程论坛网论坛 » 嵌入式系统 » Uclinux中怎么添加自己得应用程序

xilinxue

xilinxue   |   当前状态:在线

总积分:16186  2025年可用积分:0

注册时间: 2008-06-26

最后登录时间: 2020-03-22

空间 发短消息加为好友

Uclinux中怎么添加自己得应用程序

xilinxue  发表于 2008/10/23 13:07:51      834 查看 0 回复  [上一主题]  [下一主题]

手机阅读

step 1:
    创建一个自己的Application: 请首先认真阅读uClinux 2.4.x Kernel的目录内的document.directry:
    ../document.tion/Adding-User-Apps-HOWTO.txt
    通过阅读this document.以帮助您自己动手创建一个application.
step 2:
    创建一个自己的application工程后,您可以利用Linux(Redhat等)在PC上编译,在PC上通过执行(./youappexe)来验证您的程序是否有bug or error等.但是这个在PC上看起来可以run的"可执行程序/文件"不是您的基于ARM/DragonBall/ColdFire/PowerPC等单片机环境的"可执行程序/文件",因为PC(x86)平台使用的文件系统和您的目标板子(单片机板子)的uClinux使用的文件系统不相同,uClinux的ROMFS格式的可执行程序/文件是不能被PC上的Linux(Redhat等)所认识的.假设您创建的new application:
../user/MyApp/demo.c
    假设您已经完全按照下面的要求(*在../document.tion/Adding-User-Apps-HOWTO.txt中也是这样要求的 *):
      ../user/MyApp/demo.c的内容 -----
#include <stdlib.h>
#include <stdio.h>
void main(void)
{
  printf("Hello world! This is my first app. from WangZF,2002/11/04\n");
}
  ../user/MyApp/Makefile的内容和格式 -----

EXEC = demo
OBJS = demo.o

all: $(EXEC)

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

romfs:
  $(ROMFSINST) /bin/$(EXEC)
clean:
  rm -f $(EXEC) *.elf *.gdb *.o
    然后编译它,仅在当前的应用程序目录执行:make,结果自己看吧,正如您的预料。
step 3:
  增加下面的内容到../user/Makefile中:
dir_$(CONFIG_USER_MYAPP_DEMO)     += myapp
它的作用是让编译器可以访问到您创建的MyApp目录的Makefile. 它被加到那一行并不重要,这个文件中的各路径排列是按照英文字母顺序,您也不比独具匠心,按照这个顺序把您的MyApp目录的路径加进去吧!

step 4:
  下一步是修改uClinux 2.4.x系统中对编译器来讲最重要的2个文件:
  ../Config/config.in   (1)
  ../Config/Configure.help   (2)
  ../Config/autoconf.h   (3) {[<(这个文件不能手工修改,系统会自动修改它)>]}

step 5:
  open 'config.in' file,首先把下面的内容拷贝:

#############################################################################

mainmenu_option next_comment
comment 'My New Application'

bool 'demo'   CONFIG_USER_MYAPP_DEMO
bool 'app1'   CONFIG_USER_MYAPP_APP1
bool 'app2'   CONFIG_USER_MYAPP_APP2
bool 'app3'   CONFIG_USER_MYAPP_APP3
comment "My New Application"

endmenu

#############################################################################

step 6:
    make xconfig, 看到下面的画面!您的工作非常成功!

  (sorry! i don't send .jpg files to website)

step 7:
    相信下面的几步大家都很熟悉:
    make dep
    make clean
    make lib_only(可以仅1次,不必要每次都来)
    make user_only(每次修改过您的应用程序之后,这一步后面的都必须重来)
    make romfs
    make image
    make
step 8:
    download image.rom to your board! run it!
1楼 0 0 回复