完成hello程序(初学uclinux第一个程序)
时间:2006-04-29 来源:im
过程不麻烦,uclinux解压目录下有romfs文件夹
自己编辑hello.c程序
#include <stdio.h>
int main(void)
{
int i;
for(i = 0; i < 6; i++){
printf("i = %d ",i);
printf("Hello, embedded linux!\n");
}
return 0;
}
执行命令:arm-elf-gcc -Wl,-elf2flt -o hello hello.c
得到名为hello的文件
[root@server test]# file hello
hello: BFLT executable - version 4 ram
还有另外一个hello.gdb文件
把hello文件copy到romfs/文件夹下的bin/子文件夹中
执行命令
genronfs -f romfs.img -d romfs/
产生的romfs.img 文件便可以用来启动uclinux
在skyeye.conf 中指定romfs.img的位置
然后可在skyeye目录下执行
#./skyeye -e (名为linux 文件位置)
进入uclinux系统后
执行hello命令
结果为
Sash command shell (version 1.1.1)
/> 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!
/>
自己编辑hello.c程序
#include <stdio.h>
int main(void)
{
int i;
for(i = 0; i < 6; i++){
printf("i = %d ",i);
printf("Hello, embedded linux!\n");
}
return 0;
}
执行命令:arm-elf-gcc -Wl,-elf2flt -o hello hello.c
得到名为hello的文件
[root@server test]# file hello
hello: BFLT executable - version 4 ram
还有另外一个hello.gdb文件
把hello文件copy到romfs/文件夹下的bin/子文件夹中
执行命令
genronfs -f romfs.img -d romfs/
产生的romfs.img 文件便可以用来启动uclinux
在skyeye.conf 中指定romfs.img的位置
然后可在skyeye目录下执行
#./skyeye -e (名为linux 文件位置)
进入uclinux系统后
执行hello命令
结果为
Sash command shell (version 1.1.1)
/> 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!
/>
相关阅读 更多 +