S3C44B0 调试笔记 —uClinux部分【转】

S3C44B0 调试笔记

——uClinux部分

 

       上班时间很少有机会搞这些东西,基本上都是下班在家里搞,不过在公司写写文挡还是可以的。调试uClinux也是断断续续进行的。以前根本没接触过linux,搞起来可真是头都要大了。虽说到最后调通比前面耗时少很多,主要原因是网上很多参考资料。但个人感觉这部分难度要更大一些。

       接着前面的说吧,编译出一个uClinux的内核出来,就必须在linux环境下,windows下是编译不了的(如果可行的话,我很愿意那样做)。一阵迷惑,根本没有方向,从何下手。后来在44B0 QQ群里有人指点使用vmware + FC4。Vmware是一款虚拟平台软件,它支持在windows系统中运行linux,就好象cygwin一样,大家都说cygwin很复杂,不是很好用,我也不想去试了。FC4是FedoraCore 4的缩写,是Red Hat Linux平台的一个版本。

       到网上下载vmware5,然后在windows下直接安装就可以了。安装后运行vmware,进行FC4的安装,这部分挺简单的,关于这方面的细节可以到网上查一下。注意一点,linux的空间尽量多分一点儿,最好不要小于8G。给篇参考文章:http://blog.21ic.com/more.asp?name=robertchai&id=13409

       到网上下载这三个文件:  arm-elf-tools-20030314.sh

uClinux-dist-20040408.tar.gz

uClinux-20040408-ARMSYS.rar

参考下载地址:

http://www.uclinux.org/pub/uClinux/m68k-elf-tools/arm-elf-tools-20030314.sh

http://www.uclinux.org/pub/uClinux/dist/uClinux-dist-20040408.tar.gz

http://www.hzlitai.com.cn/download/uClinux-20040408-ARMSYS.rar

放到同一个文件夹中,例如:uClinux Share

       然后就可以在windows上通过vmware启动FC4了,注意,启动之前修改一下linux光盘指向的内容,将光盘设置到VMware\VMwareWorkstation\linux.iso,这里放的是vmware-tools。然后启动就可以了。一下子就进入到了linux的世界。我以前从没玩过linux,但感觉linux还是很不错的。接下来就是安装vmware-tools,我们用这个工具主要是用于window系统和linux系统文件共享。

       让虚拟机运行于窗口状态,不要全屏,按ctrl+alt让鼠标释放出来。在vmware的菜单栏上选择“虚拟机”/"安装虚拟机工具“。然后切换到客户操作系统,即linux。 双击linux的光盘图标进入linux的虚拟光盘,可以看到两个文件,一个是压缩包,一个是rmp包。右键点击rmp包,“用install Packages打开“。(如果不能正常打开虚拟光盘,可以从linux的终端里运行mount /media/cdrom)上述操作完成后,进入/usr/bin目录,查找vmware-config-tools.pl.(ls /usr/bin/*.pl).找到后,运行它。即(./vmware-config-tools.pl)注意,斜杠前有一个点。一路回车即可完成安装。

    完成后,我们就可以在/mnt/hgfs中,看到我们刚才在vmware里设置的windows共享文件夹“uClinux Share”。接下来就是搭建uClinux交叉编译环境。

    首先,我们安装arm-elf-tools。将arm-elf-tools-20030314.sh拷贝到根目录,运行安装:sh arm-elf-tools-20030314.sh

#ls /usr/local/bin        

可以看到arm-elf-gcc已经安装ok.

       然后,安装uClinux-dist内核。将uClinux-dist-20040408.tar.gz拷贝到/usr/local/bin  解压 uClinux-dist-20040408.tar.gz 文件到uClinux-dist 目录:

        tar xvzfuClinux-dist-20040408.tar.gz

此时当前工作目录下增加了一个名为uClinux-dist 的目录。

       接着,我们安装patch。将/usr/local/bin/uClinux-dist/vector/Samsung/4510B文件夹重命名成/usr/local/bin/uClinux-dist/vector/Samsung/44B0,将uClinux-20040408-ARMSYS.rar拷贝到uClinux-dist目录下,运行:

       tar xvzfuClinux-ARMSYS-20040801.tar.gz

       解压补丁包后,生成patch文件uClinux-20040408-ARMSYS.patch。然后,安装patch文件:

       patch –p1 <uClinux-20040408-ARMSYS.patch

安装过程中可能会出现一些错误信息,可以手动地按照patch文件的内容在指定的文件处进行修改一下。主要修改对象是uClinux-dist/vector/Samsung/44B0文件夹中的两个文件:Makefile 和 rc。提醒大家注意这两个文件。(建议修改这两个文件之前,进行一次编译)

 

       补丁打好后,我们还要做一些修改:

       手动修改uClinux-dist/Makefile

       在TFTPDIR = /tftpboot后加上:
       LINUXTARGET=bzImage

       否则make 不过。 在make image  时,cp命令,报找不到

       $(ROOTDIR)/$(LINUXDIR)/arch/armnommu/root/zImage文件。不能生成image.rom文件。

       makemenuconfig

       makedep

       makeclean

       makelib_only

       makeuser_only

       makeromfs

       makeimage

       make

       生成image.rom后,通过共享文件夹uClinux Share 将image.rom传递到windows系统下。然后,切换到windows系统,将image.rom通过网线下载(我板子已经修好了)到ram,然后烧录到FLASH的0x100000位置,运行uclinux 没有反应。

 

       错误在哪里呢?后来在立宇泰的论坛里找到了三个配置文件,(config_main/config_kernel/config_user)这三个文件都是make menuconfig时候用的。重新运行

       makemenuconfig

       进入配置主界面。选中Customize Kernel Settings 和  user config setting(就是第二和第三项,具体记不清了)。退出保存,然后进入Customize Kernel Settings,选LOAD,输入文件所在路径。(例如:/mnt/hgfs/uClinux/config/config_kernel)注意,LOAD完成,此处去掉了USB选项。 保存,退出。 进入user config setting,同样方法LOAD config_user。保存,退出。然后,

       makedep

       makeclean

       makelib_only

       makeuser_only

       makeromfs

       makeimage

       make

       得到image.ram 和image.rom.。

 

       将两个文件共享到windows下,用上面的方法,程序运行如下:

\>uclinux
Uncompressing Linux........................................................done, booting the kernel.

 

Linux version 2.4.24-uc0(root@localhost) (gcc version 2.95.320010315 (release)(ColdFire patches - 20010318 from http://fiddes.net/coldfire/)(uClinuxXIP and shared lib patches from http://www.snapgear.com/))#13 涓?6鏈?7 16:08:36 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=/ lnuxrc

然后就停止了。死机。。。。。。

    后来发现这里是我的中断向量表出现了问题,中断地址应该指向uClinux运行的地址空间,即0x0c0000xx。修改之后编译得到boot.bin,烧录到FLASH的零地址。然后再次运行uClinux:

\>uclinux
Uncompressing Linux........................................................done, booting the kernel.

Linux version 2.4.24-uc0(root@localhost) (gcc version 2.95.320010315 (release)(ColdFire patches - 20010318 from http://fiddes.net/coldfire/)(uClinuxXIP and shared lib patches from http://www.snapgear.com/))#23 涓€ 6鏈?19 19:00:06 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: 6252KB available (1591Kcode, 170K 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 byUNIFIX

Linux NET4.0 for Linux 2.4

Based upon Swansea UniversityComputer 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. JeffDionne

Blkmem copyright 1998 KennethAlbanowski

Blkmem 1 disk images:

0: C700000-CEFFFFF [VIRTUALC700000-CEFFFFF] (RO)

RAMDISK driver initialized: 16 RAMdisks of 1024K size 1024 blocksize

NET4: Linux TCP/IP 1.0 for NET4.0

IP Protocols: ICMP, UDP, TCP

IP: routing cache hash table of512 buckets, 4Kbytes

TCP: Hash tables configured(established 512 bind 512)

Kernel panic: VFS: Unable to mountroot fs on 1f:00

然后又DOWN掉了。。。。。。。。。

    后来找到了问题,问题出在文件系统romfs。

修改:/uClinux-dist/Linux-2.4.x/Driver/Block/blkmem.c

-#ifdef CONFIG_BOARD_SNDS100

+//#ifdef CONFIG_BOARD_SNDS100
extern char romfs_data[];
extern char romfs_data_end[];
-#endif

+//#endif

 

#ifdef CONFIG_BOARD_MBA44

-{0, 0xc700000, -1},  /*{0,0x100000, -1}*/

+{0, romfs_data, -1}, /*{0,0x100000, -1}*/
#endif

 

修改后

make linux

make

运行结果:

\>uclinux
Uncompressing Linux........................................................done, booting the kernel.

Linux version 2.4.24-uc0(root@localhost) (gcc version 2.95.320010315 (release)(ColdFire patches - 20010318 from http://fiddes.net/coldfire/)(uClinuxXIP and shared lib patches from http://www.snapgear.com/))#23 涓€ 6鏈?19 19:00:06 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.84BogoMIPS

Memory: 8MB = 8MB total

Memory: 6252KB available (1591Kcode, 170K 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 byUNIFIX

Linux NET4.0 for Linux 2.4

Based upon Swansea UniversityComputer 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. JeffDionne

Blkmem copyright 1998 KennethAlbanowski

Blkmem 1 disk images:

0: C0ECCF0-C1A0CEF [VIRTUAL C0ECCF0-C1A0CEF] (RO)

RAMDISK driver initialized: 16 RAMdisks of 1024K size 1024 blocksize

NET4: Linux TCP/IP 1.0 for NET4.0

IP Protocols: ICMP, UDP, TCP

IP: routing cache hash table of512 buckets, 4Kbytes

TCP: Hash tables configured (established512 bind 512)

VFS: Mounted root (romfsfilesystem) readonly.

Freeing init memory: 44Shellinvoked to run file: /etc/rc
Command: hostname Samsung
Command: /bin/expand /etc/ramfs.img /dev/ram0
Command: /bin/expand /etc/騛mfs2048.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 device
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)
/>

长出一口气,终于通了。

接着,我想大家都应该期待helloworld吧。下面开始。

cd/usr/local/bin/uClinux-dist/user

mkdirmyapp

然后,在myapp文件夹里新建两个文件:helloworld.c 和 Makefile

helloworld.c文件如下编写:

#include <stdlib.h>

#include <stdio.h>

 

int main(void)

{

       printf(“helloworld ! \n”);

       return0;

}

 

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_optionnext_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, 保存退出。

makeuser_only

makeromfs

makeimage

make

得到image.rom 和 image.ram.

 

将image.rom 烧到板子上,运行结果如下:

\>uclinux

UncompressingLinux......................................................... done, bootingthe kernel.

 

Linuxversion 2.4.24-uc0 (root@localhost) (gcc version2.95.3 20010315 (release)(ColdFire patches - 20010318 fromhttp://fiddes.net/coldfire/)(uClinux XIP and shared lib patches fromhttp://www.snapgear.com/)) #25 浜?6鏈?20 13:52:22 HKT 2006

 

Processor:Samsung S3C44B0X revision 0

 

Architecture:S3C44B0X

 

On node 0totalpages: 2048

 

zone(0):0 pages.

 

zone(1):2048 pages.

 

zone(2):0 pages.

 

Kernelcommand line: root=/dev/rom0 init=/linuxrc

 

Calibratingdelay loop... 31.84 BogoMIPS

 

Memory:8MB = 8MB total

 

Memory:6228KB available (1618K code, 167K data, 44K init)

 

Dentrycache hash table entries: 1024 (order: 1, 8192 bytes)

 

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

 

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

 

Buffercache hash table entries: 1024 (order: 0, 4096 bytes)

 

Page-cachehash table entries: 2048 (order: 1, 8192 bytes)

 

POSIXconformance testing by UNIFIX

 

LinuxNET4.0 for Linux 2.4

 

Basedupon Swansea University Computer Society NET3.039

 

InitializingRT netlink socket

 

Startingkswapd

 

ttyS0 atI/O 0x1d00000 (irq = 3) is a S3C44B0

 

ttyS1 atI/O 0x1d04000 (irq = 2) is a S3C44B0

 

Blkmemcopyright 1998,1999 D. Jeff Dionne

 

Blkmemcopyright 1998 Kenneth Albanowski

 

Blkmem 1disk images:

 

0:C0ECCF0-C1A78EF [VIRTUAL C0ECCF0-C1A78EF] (RO)

 

RAMDISKdriver initialized: 16 RAM disks of 1024K size 1024 blocksize

 

NET4:Linux TCP/IP 1.0 for NET4.0

 

IPProtocols: ICMP, UDP, TCP

 

IP:routing cache hash table of 512 buckets, 4Kbytes

 

TCP: Hashtables configured (established 512 bind 512)

 

VFS:Mounted root (romfs filesystem) readonly.

 

Freeinginit 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

mountfailed: 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

Welcometo

          ____ _  _

         / __| ||_|                

    _  _| |  | | _ ____  _  _  _  _

   | | | | | | || |  _ \| | | |\ \/ /

   | |_| | |__| || | | | | |_| |/    \

   | ___\____|_||_|_| |_|\____|\_/\_/

   | |

   |_|

 

Forfurther information check:

http://www.uclinux.org/

 

ExecutionFinished, Exiting

 

Sashcommand shell (version 1.1.1)

/> ls

bin

dev

etc

home

lib

mnt

proc

sbin

tmp

usr

var

/> cdbin

/bin>ls

arp

boa

expand

helloworld

httpd

ifconfig

inetd

init

ping

portmap

route

sh

snmpd

/bin>helloworld

helloworld !

 

 

 

 

 

 

 

                                                                             Robertchain@163.com

                                                                                    http://robertchai.21ic.org

 

 

 

 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值