歡迎您光臨本站 註冊首頁

在uClinux文件系統中增加應用程序

←手機掃碼閱讀     火星人 @ 2014-03-09 , reply:0

  編寫hello.c程序,代碼如下:

  #include <stdio.h>

  int main()

  {

  int i;

  for(i=0;i<6;i )

  {

  printf("i=%d\n",i);

  printf("Hello,embedded linux\n");

  }

  return 0;

  }

  編譯hello.c

  linux-dist$">stuyou@UBUNTU:/usr/local/src/uClinux-dist$ sudo arm-elf-gcc -elf2flt -o hello hello.c

  生成hello,hello.gdb

  掛載romfs

  stuyou@UBUNTU:/usr/local/src/uClinux-dist/images$ mkdir romfs_dir

  stuyou@UBUNTU:/usr/local/src/uClinux-dist/images$ sudo mount -o loop romfs.img romfs_dir

  拷貝hello

  stuyou@UBUNTU:/usr/local/src/uClinux-dist/images$ sudo cp ../hello ./romfs_dir

  出錯

  cp: cannot create regular file `romfs_dir/bin/hello': Read-only file system

  複製根文件系統到一個新到目錄中

  stuyou@UBUNTU:/usr/local/src/uClinux-dist/images$ sudo mkdir new_romfs

  stuyou@UBUNTU:/usr/local/src/uClinux-dist/images$ sudo cp -r romfs_dir/* new_romfs

  拷貝hello

  stuyou@UBUNTU:/usr/local/src/uClinux-dist/images$ sudo cp ../hello new_romfs/bin

  生成新的romfs映像

  stuyou@UBUNTU:/usr/local/src/uClinux-dist/images$ sudo genromfs -f romfs_new.img -d new_romfs/

  修改skyeye.conf,使之使用新的映像

  #skyeye config file sample

  arch:arm

  cpu: arm7tdmi

  mach: at91

  mem_bank: map=M, type=RW, addr=0x00000000, size=0x00004000

  mem_bank: map=M, type=RW, addr=0x01000000, size=0x00400000

  mem_bank: map=M, type=R, addr=0x01400000, size=0x00400000, file=./romfs_new.img

  mem_bank: map=M, type=RW, addr=0x02000000, size=0x00400000

  mem_bank: map=M, type=RW, addr=0x02400000, size=0x00008000

  mem_bank: map=M, type=RW, addr=0x04000000, size=0x00400000

  mem_bank: map=I, type=RW, addr=0xf0000000, size=0x10000000

  #set nic info

  #net: type=cs8900a, base=0xfffa0000, size=0x20,int=16, mac=0:4:3:2:1:f, ethmod=tuntap, hostip=10.0.0.1

  net: type=cs8900a, ethmod=tuntap, hostip=10.0.0.1

  uart: mod = term

  #dbct: state=on

  在skyeye上啟動uClinux

  stuyou@UBUNTU:/usr/local/src/uClinux-dist/images$ skyeye -c skyeye.conf -e linux

  得到如下啟動信息:

  Your elf file is little endian.

  arch: arm

  cpu info: armv3, arm7tdmi, 41007700, fff8ff00, 0

  mach info: name at91, mach_init addr 0x80605a0

  ethmod num=1, mac addr=0:0:0:0:0:0, hostip=10.0.0.1

  failed to setup_module (name:net, type:cs8900a)

  tapif_init: icotl TUNSETIFF erroruart_mod:0, desc_in:, desc_out:, converter:

  SKYEYE: use arm7100 mmu ops

  Loaded ROM ./romfs_new.img

  exec file "linux"'s format is elf32-little.

  load section .init: addr = 0x01000000 size = 0x0000a000.

  load section .text: addr = 0x0100a000 size = 0x000dccd0.

  load section .data: addr = 0x010e8000 size = 0x00009ce4.

  not load section .bss: addr = 0x010f1d00 size = 0x000220a0 .

  not load section .debug_abbrev: addr = 0x00000000 size = 0x0003d30e .

  not load section .debug_info: addr = 0x00000000 size = 0x0186c1ff .

  not load section .debug_line: addr = 0x00000000 size = 0x00304551 .

  not load section .debug_pubnames: addr = 0x00000000 size = 0x0000c30b .

  not load section .debug_aranges: addr = 0x00000000 size = 0x00002438 .

  call armul_InitSymTable,kernel filename is linux.

  start addr is set to 0x01000000 by exec file.

  Linux version 2.4.31-uc0 (root@UBUNTU) (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/)) #1 Thu May 13 15:02:46 CST 2010

  Processor: Atmel AT91M40xxx revision 0

  Architecture: EB01

  On node 0 totalpages: 1024

  zone(0): 0 pages.

  zone(1): 1024 pages.

  zone(2): 0 pages.

  Kernel command line: root=/dev/rom0

  Calibrating delay loop... 15.82 BogoMIPS

  Memory: 4MB = 4MB total

  Memory: 2936KB available (883K code, 180K data, 40K init)

  Dentry cache hash table entries: 512 (order: 0, 4096 bytes)

  Inode cache hash table entries: 512 (order: 0, 4096 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: 1024 (order: 0, 4096 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

  Atmel USART driver version 0.99

  ttyS0 at 0xfffd0000 (irq = 2) is a builtin Atmel APB USART

  ttyS1 at 0xfffcc000 (irq = 3) is a builtin Atmel APB USART

  Blkmem copyright 1998,1999 D. Jeff Dionne

  Blkmem copyright 1998 Kenneth Albanowski

  Blkmem 1 disk images:

  0: 1400000-15123FF [VIRTUAL 1400000-15123FF] (RO)

  RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize

  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 512 bind 512)

  NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.

  VFS: Mounted root (romfs filesystem) readonly.

  Shell invoked to run file: /etc/rc

  Command: hostname GDB-armulator

  Command: /bin/expand /etc/ramfs.img /dev/ram0

  Command: mount -t proc proc /proc

  Command: mount -t ext2 /dev/ram0 /var

  Command: mkdir /var/tmp

  Command: mkdir /var/log

  Command: mkdir /var/run

  Command: mkdir /var/lock

  Command: mkdir /var/empty

  Command: cat /etc/motd

  Welcome to

  GDB/armulator support by

  For further information check:

  http://www.uclinux.org/

  Execution Finished, Exiting

  Sash command shell (version 1.1.1)

  />

  切換到/bin目錄下

  /> cd bin

  /bin> ls

  bcdm

  boa

  busybox

  dhcpcd

  expand

  false

  gdbserver

  hello

  ifconfig

  inetd

  init

  login

  mount

  mtdm

  ping

  reboot

  route

  sh

  telnetd

  thdm

  true

  umount

  看到了hello,執行

  /bin> ./hello

  i=0

  Hello,embedded linux

  i=1

  Hello,embedded linux

  i=2

  Hello,embedded linux

  i=3

  Hello,embedded linux

  i=4

  Hello,embedded linux

  i=5

  Hello,embedded linux

  /bin>

  得到了正確到執行結果.

  完畢!!


[火星人 ] 在uClinux文件系統中增加應用程序已經有557次圍觀

http://coctec.com/docs/linux/show-post-50743.html