Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1333378
  • 博文数量: 124
  • 博客积分: 5772
  • 博客等级: 大校
  • 技术积分: 1647
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-27 10:39
文章分类

全部博文(124)

文章存档

2020年(1)

2019年(1)

2018年(5)

2017年(2)

2016年(17)

2015年(3)

2014年(7)

2013年(11)

2012年(13)

2011年(30)

2010年(34)

分类: LINUX

2010-09-27 21:59:07

编写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

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 )(uClinux XIP and shared lib patches from )) #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:


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>


得到了正确到执行结果。
完毕!!
阅读(1575) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-09-28 15:58:02

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com