baconer 发表于 2005-5-18 22:52:01

请教:怎么在uClinux中加入自己的程序

我在skyeye中编译uClinux通过,看到了welcom to uClinux
想把一组语音编码的C语言程序加到里面去,但是不知道怎么弄???
请求高手指点!!

super2005 发表于 2005-5-19 08:46:27

http://www.linuxsir.org/bbs/showthread.php?t=106835

limingth 发表于 2005-5-19 10:12:14

uClinux AddApp User Guide for lumit4510 :

说明: 如何给 uClinux 添加自己的应用程序

-------------------------------------------------------------------------

Step 1 :
1. cd uClinux-dist
2. cd user
3. mkdir myapp
4. cd myapp
5. vi demo.c

#include <stdlib.h>
#include <stdio.h>

int main(void)
{
      printf("Hello world! \n");
      printf(" - let us make it together \n");
      printf("--------------------\n");
      printf("http://www.lumit.org\n");
      return 0;
}

6. vi 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

7. vi uClinux-dist/user/Makefile
   添加一行dir_$(CONFIG_USER_MYAPP_DEMO)      += myapp
   
    309 # add by liming
    310 dir_$(CONFIG_USER_MYAPP_DEMO)      += myapp
    311

8. vi uClinux-dist/Config/config.in
    增添以下内容到文件最后
#############################################################################

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

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

   
9. 进行重新编译内核和文件系统的步骤
       make dep
       make clean
       make lib_only (可以仅1次,不必要每次都来)
       make user_only (每次修改过您的应用程序之后,这一步后面的都必须重来)
       make romfs
       make image
       make
   注意,如果前面已经编译成功过一次,那么后面只需进行 make user_only; make romfs; make

10. 下载内核,运行看看:
\>load
No begin address for download, use default address 0x8000
Mini TFTP Server 1.0 (IP : 192.168.168.101 PORT: 69)
Load image file from host
Type tftp -i 192.168.168.101 put filename at the host PC
Press ESC key to exit
Starting the TFTP download...
................................................
Received 18baec Bytes, END...
Boot Image? (y/n) yLinux version 2.4.20-uc0 ([email protected]) (gcc version 2.95.3 20010315 (release)(ColdFire patches - 20010318 from http://fiddes.net/coldfire/)(uClinux XIP and shared lib patches from http://www.snapgear.com/)) #7 Wed Aug 25 22:07:14 HKT 2004
Processor: Samsung S3C4510B revision 6
Architecture: SNDS100
On node 0 totalpages: 4096
zone(0): 0 pages.
zone(1): 4096 pages.
zone(2): 0 pages.
Kernel command line: root=/dev/rom0
Calibrating delay loop... 49.86 BogoMIPS
Memory: 16MB = 16MB total
Memory: 14452KB available (1510K code, 157K data, 40K init)
Dentry cache hash table entries: 2048 (order: 2, 16384 bytes)
Inode cache hash table entries: 1024 (order: 1, 8192 bytes)
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 4096 (order: 2, 16384 bytes)
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Samsung S3C4510 Serial driver version 0.9 (2001-12-27) with no serial options enabled
ttyS00 at 0x3ffd000 (irq = 5) is a S3C4510B
ttyS01 at 0x3ffe000 (irq = 7) is a S3C4510B
Blkmem copyright 1998,1999 D. Jeff Dionne
Blkmem copyright 1998 Kenneth Albanowski
Blkmem 1 disk images:
0: BE7E8-18BBE7 (RO)
RAMDISK driver initialized: 16 RAM disks of 1024K size 1024 blocksize
Samsung S3C4510 Ethernet driver version 0.1 (2002-02-20) <[email protected]>
eth0: 00:40:95:36:35:34
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 1024 bind 1024)
VFS: Mounted root (romfs filesystem) readonly.
Freeing init memory: 40K
Shell invoked to run file: /etc/rc
Command: hostname Samsung
Command: /bin/expand /etc/ramfs.img /dev/ram0
Command: /bin/expand /etc/ramfs2048.img /dev/ram1
Command: mount -t proc proc /proc
Command: mount -t ext2 /dev/ram0 /var
Command: mount -t ext2 /dev/ram1 /ramdisk
Command: chmod 777 /ramdisk
Command: mkdir /var/config
Command: mkdir /var/tmp
Command: mkdir /var/log
Command: mkdir /var/run
Command: mkdir /var/lock
Command: ifconfig lo 127.0.0.1
Command: route add -net 127.0.0.0 netmask 255.255.255.0 lo
Command: ifconfig eth0 192.168.168.101 netmask 255.255.255.0 up
Command: cat /etc/motd
Welcome to
          ____ __
         /__| ||_|               
    _   _| || | _ _____   ___
   | | | | || || |_ \| | | |\ \/ /
   | |_| | |__| || | | | | |_| |/    \
   |___\____|_||_|_| |_|\____|\_/\_/
   | |
   |_|

For further information check:
http://www.uclinux.org/

Execution Finished, Exiting

Sash command shell (version 1.1.1)
/> ls
bin
dev
etc
home
lib
mnt
proc
ramdisk
sbin
tmp
usr
var
/>
/> cd bin
/bin> ./demo
Hello world!
- let us make it together
--------------------
http://www.lumit.org
/bin>


参考链接:
http://www.lumit.org/dn_document.htm
http://www.ucdragon.com/bbs/printpage.asp?BoardID=1&id=106

limingth 发表于 2005-5-19 10:41:58

还有一个方法是在本版常见问题解答里面有的,直接通过 编译命令 来实现的,可参考
http://www.linuxfans.org/nuke/modules.php?name=Forums&file=viewtopic&t=50744

Q:
如何在uclinux中增加自己的用户程序?

A:(from liming)
一个 hello.c 的例子:
in file: hello.c
#include <stdio.h>

int main(void)
{
printf( "hello, world!
This is a test. My name is liming!
" );
return 1;
}

in file: makefile
all:
arm-elf-gcc -Os -Dlinux -D__linux__ -Dunix -D__uClinux__ -DEMBED - I/home/liming/mytest/uClinux-dist/lib/libc/include -I/home/liming/ mytest/uClinux-dist/lib/libm -I/home/liming/mytest/uClinux-dist - fno-builtin -nostartfiles -D__PIC__ -fpic -msingle-pic-base -I/ home/liming/mytest/uClinux-dist/linux-2.4.x/include -c -o hello.o hello.c

接上面的 makefile

arm-elf-gcc -Os -Dlinux -D__linux__ -Dunix -D__uClinux__ -DEMBED - I/home/liming/mytest/uClinux-dist/lib/libc/include -I/home/liming/ mytest/uClinux-dist/lib/libm -I/home/liming/mytest/uClinux-dist - fno-builtin -nostartfiles -D__PIC__ -fpic -msingle-pic-base -I/ home/liming/mytest/uClinux-dist/linux-2.4.x/include -Wl,-elf2flt / home/liming/mytest/uClinux-dist/lib/libc/crt0.o -o hello hello.o - L/home/liming/mytest/uClinux-dist/lib/libc/. -L/home/liming/mytest/ uClinux-dist/lib/libc/lib -L/home/liming/mytest/uClinux-dist/lib/ libm -L/home/liming/mytest/uClinux-dist/lib/libnet -L/home/liming/ mytest/uClinux-dist/lib/libdes -L/home/liming/mytest/uClinux-dist/ lib/libpcap -L/home/liming/mytest/uClinux-dist/lib/libssl -lc


我是 用了比较取巧的办法,直接到
/home/liming/mytest/uClinux-dist/romfs/bin
下添加了上面 hello.c 和 makefile
然后直接重新 make ,不要 make clean
就可以了。
另外, 需要把上面相关的目录改为你自己主机上的目录。 试试?

pascal_deng 发表于 2005-5-24 14:39:31

第2种方法,uClinux-dist/romfs/bin
我的uClinux-dist下怎么没有/romfs文件夹?

limingth 发表于 2005-5-25 10:02:49

make romfs 试试
页: [1]
查看完整版本: 请教:怎么在uClinux中加入自己的程序