ubuntu8.04上搭建uClinux编译开发环境并用skyeye仿真

今天装skyeye遇到了问题,装完以后和视频上给的不一样,但看了一位网友的博客后才确认自己装的是对的,下面是我加了一点注解,修改了些链接,大部分还是借鉴了网友的,感谢~~~


<1>arm-elf-tools-20040427无法完成对uClinx-dist-20070130的编译,推荐用arm- uclinux-tools尝试,或者用arm-elf-tools-20040427对uClinux-dist-20040408进行编译。(我选择的是编译uclinux-disk-20040408)
<2>另外arm-linux-gcc与arm-elf-gcc的区别:arm-linux-gcc是针对arm+linux的开发环境 的,kernel使用的是linux,不是uclinux,arm是有硬件MMU的,而arm-elf-gcc是针对没有MMU的arm+uclinux 的开发环境,kernel使用的是uclinux,硬件是廉价的无MMU的arm芯片

1.系统环境:
    ubuntu8.04
2.准备工作:
    <1>arm-linux-gcc(我是从另一本书里的光盘安装的,很长时间了,没有的朋友从下面下,链接未验证现在是否有效)

  下载地址:ARM Linux
        ftp.arm.linux.org.uk/pub/armlinux/toolchain/        arm-linux-gcc版本2.95.3, 3.0和3.2
        Handhelds.org
        ftp.handhelds.org/projects/toolchain/        arm-linux-gcc 版本3.3.2和3.4.1
        ELDK 4.1
        ftp.denx.de/pub/eldk/4.1/        arm-linux-gcc版本4.0.0
    <2>arm-elf-tools(arm-elf-tools-20030314.sh/arm-elf-tools-20040427.sh)
    下载地址:   http://opensrc.sec.samsung.com/download.html(在页面的最下方)

    <3>arm-uclinux-tools
    下载地址:  http://opensrc.sec.samsung.com/download.html  (也在下方,但我做得时候貌似没用着阿,晕)

    <4>uClinux-dist(20040408.tar.gz)
    下载地址:  http://www.uclinux.org/pub/uClinux/dist/ (我是从这下的)

    <5>skyeye,skyeye-testsuits,skyeye-with-gdb
    下载地址:    http://sourceforge.net/project/showfiles.php?group_id=85554 (我从这下的)

3.搭建过程:
    以下操作均在root用户下进行(在每个命令前加sudo)
    (1)首先安装交叉编译工具链arm-elf-tools-20040427.sh
    #./arm-elf-tools-20040427.sh
    即可安装成功
    如出现错误提示如下:
    tail: 无法打开 “+43” 读取数据: 没有那个文件或目录 (我的就出现了这个问题,别急,往下看)
    gunzip: stdin: not in gzip format
    按如下步骤操作:
    #tail -n+43 arm-elf-tools-20040427.sh >> arm-elf-tools.tar.gz
    #tar vxzf arm-elf-tools.tar.gz
    即可得到文件夹usr,然后复制或移动它到/目录下
    #cp -r usr /
    如出现提示无法覆盖/local/man,如下操作:
    #cp -r usr/local/man /usr/share/
    (2)测试交叉编译是否安装成功
    创建Hello.c内容如下:
    #include<stdio.h>
    int main()
    {
    printf("Hello!This is Embedded Linux!");
    return 0;
    }
    编译如下:
    #arm-elf-gcc -Wl,-elf2flt -o Hello Hello.c
    #ls
    Hello Hello.c Hello.gdb
    可以看到编译生成BFLT格式的Hello(可用file Hello命令查看)和Hello.gdb表示编译成功
    (3)安装skyeye (原帖有三种,我都试了,这里只推荐比较舒服的安装方法)
    <1>一个简单的方法是在ubuntu8.04的新立得软件包管理器中搜索skyeye,可以看到有skyeye-1.2.3,安装即可
    <2>或者用命令#sudo apt-get install skyeye
    (3)测试skyeye是否安装成功
    #skyeye
   

    **************************** WARNING **********************************
    If you want to run ELF image, you should use -e option to indicate
    your elf-format image filename. Or you only want to run binary image,
    you need to set the filename of the image and its entry in skyeye.conf.
    ***********************************************************************

    big_endian is false.
    Failed to open skyeye config file skyeye.conf in the same directory
    error: No such file or directory
    ------------------------- SkyEye -V1.2 ---------------------------
    Usage: SkyEye [options] -e program [program args]
    Default mode is STANDALONE mode
    ------------------------------------------------------------------
    Options:
    -e exec-file        the (ELF executable format)kernel file name.
    -l load_address,load_address_mask
                    Load ELF file to another address, not its entry.
    -b                  specify the data type is big endian when non "-e" option.
    -d                  in GDB Server mode (can be connected by GDB).
    -c config-file      the skyeye configure file name.
    -h                  The SkyEye command options, and ARCHs and CPUs simulated.
    ------------------------------------------------------------------
    ----------- Architectures and CPUs simulated by SkyEye-------------
    -------- ARM architectures ---------
    at91
    lpc
    s3c4510b
    s3c44b0x
    s3c44b0
    s3c3410x
    ep7312
    lh79520
    ep9312
    cs89712
    sa1100
    pxa_lubbock
    pxa_mainstone
    at91rm92
    s3c2410x
    s3c2440
    sharp_lh7a400
    ns9750
    lpc2210
    ps7500
    integrator
    -------- BlackFin architectures ----
    bf533
   
    出现如上即安装成功
    如果没有出现上述情形,可检查一下环境变量
    (5)测试skyeye-testsuite-2.3.tar.bz2
    #tar vxjf skyeye-testsuite-2.3.tar.bz2
    #cd skyeye-testsuite-2.3
    #ls
    linux rtems u-boot uClinux
    #cd uClinux
    #ls
    at91       bf533          exec_skyeye_dbct.sh s3c3410x s3c4510
    auto_test coldfire-5249 exec_skyeye.sh       s3c44b0x test_report_2007-11-15
    #cd at91
    #ls
    at91_with_framebuffer_touchscreen uclinux_cs8900a
    linux-2.6.x                        uclinux_rtl8019
    找一个测试一下吧
    #cd uclinux_cs8900a
    #ls
    linux romfs.img skyeye.conf skyeye_dbct.conf
    #skyeye -e linux
    big_endian is false.
    arch: arm
    cpu info: armv3, arm7tdmi, 41007700, fff8ff00, 0
    mach info: name at91, mach_init addr 0x8057550
    ethmod num=1, mac addr=0:0:0:0:0:0, hostip=10.0.0.1
    uart_mod:0, desc_in:, desc_out:, converter:
    SKYEYE: use arm7100 mmu ops
    Loaded ROM   ./romfs.img
    start addr is set to 0x01000000 by exec file.
    Linux version 2.4.27-uc1 (skyeyeuser@debian) (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/)) #3 Tue Aug 9     18:57:29 CST 2005
    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: 2916KB available (903K code, 178K 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-1512BFF [VIRTUAL 1400000-1512BFF] (RO)
    RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
    Cirrus Logic CS8900A driver for Linux (V0.02)
    eth0: CS8900A rev D detected
    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
    mount: /etc/mtab: Read-only file system
    Command: mount -t ext2 /dev/ram0 /var
    mount: /etc/mtab: Read-only file system
    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 <[email protected]>
    For further information check:
    http://www.uclinux.org/

    Command: /bin/ifconfig eth0 up 10.0.0.2
    Execution Finished, Exiting

    Sash command shell (version 1.1.1)
    />
    看到如上情形,运行成功
    ctrl+c退出到#
    (6)编译uClinux内核
    #tar vxzf uClinux-dist-20040408.tar.gz
    生成文件夹uClinux-dist,将其移动到/usr/src/
    #mv uClinux-dist /usr/src/
    然后进入uClinux-dist下
    #cd /usr/src/uClinux-dist/
    <1>菜单界面配置
    #make menuconfig
    选择如下:   
    --- Select the Vendor you wish to target
             (GDB) Vendor
     --- Select the Product you wish to target
              (ARMulator) GDB Products  
    (linux-2.4.x) Kernel Version
    (uClibc) Libc Version        
    [ ] Default all settings (lose changes)
    [ ] Customize Kernel Settings        
    [ ] Customize Vendor/User Settings
    [ ] Update Default Vendor Settings
    然后Esc退出
    Do you wish to save your new kernel configuration?
                   < Yes >      < No >  
    选择yes
    如果在make menuconfig后出现错误提示,则需安装libncurses5,在新立得里安装或者
    #sudo apt-get install libncurses5-dev
    安装完后再make menuconfig
    <2>图形界面配置
    #make xconfig
    选择同上
    如果出现错误提示,则需安装tck,tk两个包,在新立得中安装,也可自己下载后安装,下载地址:

    http://www.tcl.tk/software/tcltk/downloadnow85.html
    将两个包解压后得到tcl8.5.2,tk8.5.2
    #cd tcl8.5.2
    #cd unix
    #./configure --prefix=/usr/
    #make install
    同样的方法将tk装上,在/usr/bin下会看到wish8.5,因为make xconfig调用的是wish,所以我们做一个链接
    # ln /usr/bin/wish8.5 /usr/bin/wish
    然后可以make xconfig
    无论你用菜单界面还是图形界面配置成功了,我们就可以编译uClinux的内核了
    命令进入uClinux-dist
    建立内核依赖关系,只在第一次编译内核时使用
    #make dep
    ~
    ~
    ~
    经过一段时间,如果没有错,可以进行下一步了,编译内核
    #make
    完成后可以在/images中看到这么几个文件
    image.bin linux.data linux.text romfs.img
    用romfs.img生成boot.rom文件系统
    #ln -s images/romfs.img boot.rom
    在/uClinux-dist就可以得到一个boot.rom
    编写skyeye的配置文件,新建文件skyeye.conf,在其加入以下信息:
   
    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=./boot.rom
    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

    完成这一步就可以在skyeye中运行我们编译的内核了
    #skyeye -e linux-2.4.x/linux
   
    big_endian is false.
    arch: arm
    cpu info: armv3, arm7tdmi, 41007700, fff8ff00, 0
    mach info: name at91, mach_init addr 0x8057550
    uart_mod:0, desc_in:, desc_out:, converter:
    SKYEYE: use arm7100 mmu ops
    Loaded ROM   ./boot.rom
    start addr is set to 0x01000000 by exec file.
    Linux version 2.4.24-uc0 (wenwu@wenwu-desktop) (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/)) #2 2008年 5月        11日 星期日 9:10:23 CST
    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: 2968KB available (850K 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-14AC3FF [VIRTUAL 1400000-14AC3FF] (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 <[email protected]>
    For further information check:
    http://www.uclinux.org/

    Execution Finished, Exiting

    Sash command shell (version 1.1.1)
    />
    出现如上情形,运行成功
    (7)模拟运行自己的应用程序
    找到前面曾编译的程序Hello.c,将编译生成的BFLT格式的Hello(是hello,不是hello.gdb,我刚开始就弄反了)移动到/uClinux-dist/romfs/bin中(注意在shell中用root)
    然后重新编译内核
    #make
    运行
    #skyeye -e linux-2.4.x/linux
    ```
    ```
    ```
    (省略)
    Sash command shell(version 1.1.1)
    />cd bin
    /bin>./Hello
    Hello!This is Embedded Linux!
    /bin>
    至此在ubuntu8.04上搭建uClinux编译开发环境并用skyeye进行仿真已经告一段落。

   我按照上面的方法弄完了,但无法像视频教程中开两个终端ping,这个我等搞定后再更新

你可能感兴趣的:(ubuntu8.04上搭建uClinux编译开发环境并用skyeye仿真)