补丁打好后,我们还要做一些修改:
手动修改uClinux-dist/Makefile
在TFTPDIR = /tftpboot后加上:
LINUXTARGET=bzImage
否则make 不过。 在make image 时,cp命令,报找不到
$(ROOTDIR)/$(LINUXDIR)/arch/armnommu/root/zImage文件。不能生成image.rom文件。
make menuconfig
make dep
make clean
make lib_only
make user_only
make romfs
make image
make
生成image.rom后,通过共享文件夹uClinux Share 将image.rom传递到windows系统下。然后,切换到windows系统,将image.rom通过网线下载(我板子已经修好了)到ram,然后烧录到FLASH的0x100000位置,运行uclinux 没有反应。
错误在哪里呢?后来在立宇泰的论坛里找到了三个配置文件,(config_main/config_kernel/config_user)这三个文件都是make menuconfig时候用的。重新运行
make menuconfig
进入配置主界面。选中Customize Kernel Settings 和 user config setting(就是第二和第三项,具体记不清了)。退出保存,然后进入Customize Kernel Settings,选LOAD,输入文件所在路径。(例如:/mnt/hgfs/uClinux/config/config_kernel)注意,LOAD完成,此处去掉了USB选项。 保存,退出。 进入user config setting,同样方法LOAD config_user。保存,退出。然后,
make dep
make clean
make lib_only
make user_only
make romfs
make image
make
得到image.ram 和image.rom.。
将两个文件共享到windows下,用上面的方法,程序运行如下:
\>uclinux
Uncompressing Linux........................................................ done, booting the kernel.
接着,我想大家都应该期待helloworld吧。下面开始。
cd /usr/local/bin/uClinux-dist/user
mkdir myapp
然后,在myapp文件夹里新建两个文件:helloworld.c 和 Makefile
helloworld.c文件如下编写:
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
printf(“hello world ! \n”);
return 0;
}
Makefile 文件如下编写:
EXEC = helloworld
OBJS = helloworld.o
all: $(EXEC)
$(EXEC): $(OBJS)
$(CC) $(LDFLAGS) –o $@ $(OBJS) $(LDLIBS)
romfs:
$(ROMFSINST) /bin/$(EXEC)
clean:
rm –f $(EXEC) *.elf *.gdb *.o
编辑后,保存两个文件。然后修改uClinux-dist/user/Makefile 文件:
dir_$(CONFIG_USER_ZEBRA_RIPD_RIPD) += zebra
dir_$(CONFIG_USER_ZEBRA_ZEBRA_ZEBRA) += zebra
+ dir_$(CONFIG_USER_MYAPP_HELLOWORLD) +=myapp
dir_y += games
all: config
然后修改uClinux-dist/config/config.in 文件:
在文件最后添加:
comment "Debug tools"
bool 'tpt' CONFIG_USER_TIMEPEG_TPT
comment "Debug libraries"
bool 'ccmalloc' CONFIG_LIB_LIBCCMALLOC
endmenu
#############################################################################
+mainmenu_option next_comment
+comment 'My App'
+bool 'helloworld' CONFIG_USER_MYAPP_HELLOWORLD
+bool 'app1' CONFIG_USER_MYAPP_APP1
+ comment 'My App'
+endmenu
保存文件修改。
然后运行:make menuconfig
进入Kernel/library/Defaults Setting
空格键选中Custom Vector/User Setting, 保存退出。
程序自动进入Custom Vector/User Setting:
进入My App
空格选中 helloworld, 保存退出。
make user_only
make romfs
make image
make
得到image.rom 和 image.ram.
将image.rom 烧到板子上,运行结果如下:
\>uclinux
Uncompressing Linux......................................................... done, booting the kernel.
Linux version 2.4.24-uc0 (root@localhost) (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/)) #25 浜?6鏈?20 13:52:22 HKT 2006
Processor: Samsung S3C44B0X revision 0
Architecture: S3C44B0X
On node 0 totalpages: 2048
zone(0): 0 pages.
zone(1): 2048 pages.
zone(2): 0 pages.
Kernel command line: root=/dev/rom0 init=/linuxrc
Calibrating delay loop... 31.84 BogoMIPS
Memory: 8MB = 8MB total
Memory: 6228KB available (1618K code, 167K data, 44K init)
Dentry cache hash table entries: 1024 (order: 1, 8192 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: 2048 (order: 1, 8192 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
ttyS0 at I/O 0x1d00000 (irq = 3) is a S3C44B0
ttyS1 at I/O 0x1d04000 (irq = 2) is a S3C44B0
Blkmem copyright 1998,1999 D. Jeff Dionne
Blkmem copyright 1998 Kenneth Albanowski
Blkmem 1 disk images:
0: C0ECCF0-C1A78EF [VIRTUAL C0ECCF0-C1A78EF] (RO)
RAMDISK driver initialized: 16 RAM disks of 1024K 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)
VFS: Mounted root (romfs filesystem) readonly.
Freeing init memory: 44Shell 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
mount failed: No such file or directory
Command: chmod 777 /ramdisk
/ramdisk: No such file or directory
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
SIOCSIFADDR: No such device
eth0: unknown interface: No such dev蒫e
SIOCSIFNETMASK: No such device
eth0: unknown interface: No such device
pid 12: failed 65280
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
sbin
tmp
usr
var
/> cd bin
/bin> ls
arp
boa
expand
helloworld
httpd
ifconfig
inetd
init
ping
portmap
route
sh
snmpd
/bin> helloworld
hello world !
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |