嵌入式操作系统 4 SkyEye 简介 陈香兰 (xlanchen@ustceducn) 计算机应用教研室 @ 计算机学院嵌入式系统实验室 @ 苏州研究院中国科学技术大学 Fall 2014 November 28, 2014 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 2014 2014) 1 / 46
Outline 1 SkyEye 简介 2 SkyEye 的安装 SkyEye 的安装试用 skyeye 下载 skyeye 源代码, 编译并安装 3 启动 Linux 执行自己的程序添加 hello 到 uclinux 的根文件系统中在 ArmLinux 中运行 hello 4 编译 linux 编译 armlinux 编译 µclinux 5 小结和作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 2014 2014) 2 / 46
Outline 1 SkyEye 简介 2 SkyEye 的安装 3 启动 Linux 执行自己的程序 4 编译 linux 5 小结和作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 2014 2014) 3 / 46
SkyEye 简介 SkyEye is an Open Source Software Project (GPL Licence) Origin from GDB/Armulator, 在 Sourceforge 上可以获得 Skyeye 的相关代码 SkyEye 的起源和发展 陈渝 : 做一个用软件实现的嵌入式开发硬件模拟器, 可以在模拟器上运行各种操作系统, 这样就可以在没有开发板的情况下学习和研究操作系统 SkyEye 的目标 : to provide an integrated simulation environment in Linux and Windows, simulates/emulates typical Embedded Computer Systems 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 2014 2014) 4 / 46
SkyEye 简介 Now the following OS and system softwares can run in SkyEye: uc/os-ii-2x with network support uclinux based on Linux24x/26x with Network/LCD/TouchScreen/Flash Mem support ARM Linux 24x/26x with Network/LCD/TouchScreen/Flash Mem support Nucleus Rtems Ecos lwip on uc/os-ii applications on uc/osii, uclinux,arm Linux 可对上述软件系统进行源码级的分析 调试和测试 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 2014 2014) 4 / 46
SkyEye 简介 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 2014 2014) 4 / 46
SkyEye 模拟硬件介绍 Now the following hardwares can be simulated by SkyEye: CPU CORE: ARM7TDMI, ARM720T,StrongARM, XScale, Blackfin APPLICATION CPU: Atmel AT91X40/AT91RM9200,Cirrus CIRRUS LOGIC EP7312/EP9312 CS89712,Intel SA1100/SA1110, Intel PXA 25x/27x, Samsung 4510B/44B0/2410/2440, Sharp LH7xxxx, NS9750, Philips LPC22xx, BF533 MEMORY: RAM, ROM, Flash Peripheral: Timer, UART,NIC chip,lcd, TouchScreen, etc 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 2014 2014) 5 / 46
SkyEye 模拟硬件介绍 存储器管理单元和缓存单元 MMU Memory Management Unit, 存储器管理单元, 是用来管理虚拟内存系统的硬件 MMU 的两个主要功能是 : 1 将虚地址转换成物理地址 ; 2 控制存储器的存取权限 MMU 关掉时, 虚地址直接输出到物理地址总线 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 2014 2014) 5 / 46
SkyEye 模拟硬件介绍 存储器管理单元和缓存单元 TLB, Translation Lookaside Buffers 在 MMU 中, 存放从虚拟地址到物理地址的匹配表 保存的内容包括 : 虚址及其对应的物理地址, 权限, 域和映射类型 当 CPU 对一虚拟地址进行存取时, 首先搜索 TLB 表以查找对应的物理地址等信息, 如果没有查到, 则进行查找 translation table, 称为 Translation Table Walk( 简称 TTW) 经过 TTW 过程后, 将查到的信息保存到 TLB 然后根据 TLB 表项的物理地址进行读写 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 2014 2014) 5 / 46
SkyEye 模拟硬件介绍 存储器管理单元和缓存单元 CACHE, 缓存单元主要用于缓存内存中的数据, 其读写速度远快于内存的读写速度, 所以可以提高 CPU 的内存数据的访问效率 write/read buffer 硬件单元 write/read buffer 硬件单元的作用与 CACHE 的作用类似 MMU CACHE write/read buffer 一般是高性能 CPU 的重要组成部分, 且不同类型 CPU 的 MMU CACHE write/read buffer 的逻辑行为也有一定的差异 为了支持模拟多种类型 CPU 的 MMU/CACHE,SkyEye 包含了一个通用的 MMU/CACHE 模拟实现 通过对一些参数的调整可以支持模拟多种类型的 MMU/CACHE 物理结构和逻辑行为 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 2014 2014) 5 / 46
SkyEye 模拟硬件介绍 网络芯片 目前 SkyEye 模拟了网络芯片 8019AS, 其特点是 :NE2000 兼容, 内建 16KRAM 缓冲区,10MB 传输速率 虽然目前模拟的开发板上不一定有网络芯片 8019AS, 但可以在模拟的开发板上加上网络芯片 8019AS 的模拟 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 2014 2014) 5 / 46
Outline 1 SkyEye 简介 2 SkyEye 的安装 SkyEye 的安装试用 skyeye 下载 skyeye 源代码, 编译并安装 3 启动 Linux 执行自己的程序 4 编译 linux 5 小结和作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 2014 2014) 6 / 46
Outline 1 SkyEye 简介 2 SkyEye 的安装 SkyEye 的安装试用 skyeye 下载 skyeye 源代码, 编译并安装 3 启动 Linux 执行自己的程序添加 hello 到 uclinux 的根文件系统中在 ArmLinux 中运行 hello 4 编译 linux 编译 armlinux 编译 µclinux 5 小结和作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 2014 2014) 7 / 46
SkyEye 的安装 1 Linux 操作系统 当前使用的主机操作系统是 ubuntu-1404 或者 Kubuntu-1404 ubuntu-1404 自带的编译器是 gcc-482 2 Windows+MingW 或 cygwin 请自行摸索 在 Kubuntu 上安装 SkyEye 有两种安装方法 1 直接安装二进制代码 2 下载源代码, 编译并安装 sudo apt get install skyeye 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 2014 2014) 8 / 46
在 ubuntu-1404 上直接安装 skyeye 在 ubuntu-1404 中, 使用命令 sudo apt get install skyeye 安装 skyeye-125, 版本有些老 使用 sky < tab > 可以出现完整的 skyeye 命令 skyeye -h SkyEye 125 Bug report: skyeye-developer@listsgroclinuxorg 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 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 2014 2014) 9 / 46
在 ubuntu-1404 上直接安装 skyeye 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 BlackFin architectures - bf533 bf537 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 2014 2014) 9 / 46
Outline 1 SkyEye 简介 2 SkyEye 的安装 SkyEye 的安装试用 skyeye 下载 skyeye 源代码, 编译并安装 3 启动 Linux 执行自己的程序添加 hello 到 uclinux 的根文件系统中在 ArmLinux 中运行 hello 4 编译 linux 编译 armlinux 编译 µclinux 5 小结和作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 10 / 46
试用 skyeye-125 I 下载 skyeye-125 配套的测试包 skyeye-testsuite-125tarbz2 解压缩 tar -jvxf skyeye-testsuite-125tarbz2 进入测试包目录 cd skyeye-testsuite-125 1 试运行 armlinux cd linux cd ep7312 cd 26x skyeye -e vmlinux -c skyeyeconf 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 11 / 46
试用 skyeye-125 II 2 试运行 uclinux cd uclinux cd at91 cd uclinux_cs8900a skyeye -e linux -c skyeyeconf 注意 : 运行 testsuite 下的例子时, 有些可能会出错 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 12 / 46
Outline 1 SkyEye 简介 2 SkyEye 的安装 SkyEye 的安装试用 skyeye 下载 skyeye 源代码, 编译并安装 3 启动 Linux 执行自己的程序添加 hello 到 uclinux 的根文件系统中在 ArmLinux 中运行 hello 4 编译 linux 编译 armlinux 编译 µclinux 5 小结和作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 13 / 46
下载 skyeye 源代码, 编译并安装 最新版本情况 skyeye-134_rc1targz testsuite-134_rc1targz 解压缩后进入 skyeye-134 的目录, 根据 INSTALL 文件 /configure make lib make install_lib make 编译 skyeye 过程中会出现很多错误, 提示需要安装一些软件 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 14 / 46
Outline 1 SkyEye 简介 2 SkyEye 的安装 3 启动 Linux 执行自己的程序添加 hello 到 uclinux 的根文件系统中在 ArmLinux 中运行 hello 4 编译 linux 5 小结和作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 15 / 46
Outline 1 SkyEye 简介 2 SkyEye 的安装 SkyEye 的安装试用 skyeye 下载 skyeye 源代码, 编译并安装 3 启动 Linux 执行自己的程序添加 hello 到 uclinux 的根文件系统中在 ArmLinux 中运行 hello 4 编译 linux 编译 armlinux 编译 µclinux 5 小结和作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 16 / 46
1 准备交叉编译环境 对于 µclinux, 要使用 arm-elf- 工具链下载 arm-elf-tools-20030314sh 运行 /arm-elf-tools-20030314sh 安装使用 arm-elf-<tab> 查看是否安装成功 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 17 / 46
2 准备 hello helloc 循环输出 HelloWorld! #include <stdioh> int main(void){ while(1) printf( HelloWorld!\n ); return 0; } 交叉编译 hello arm-elf-gcc -elf2flt -o hello helloc 查看 hello 的文件类型信息 file hello ḥello: BFLT executable - version 4 ram 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 18 / 46
3 添加 hello 到 µclinux 的根文件系统中 挂载 mkdir romfs_dir sudo mount -o loop romfsimg romfs_dir sudo mount -o loop romfsimg romfs_dir/ mount: warning: romfs_dir/ seems to be mounted read-only 直接拷贝 hello 到 romfs_dir? 报错!!WHY? sudo cp hello romfs_dir/bin/ cp: 无法创建普通文件 romfs_dir/bin/hello : 只读文件系统 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 19 / 46
3 添加 hello 到 µclinux 的根文件系统中 复制根文件系统到一个新的目录中 sudo cp -r romfs_dir/* new_romfs/ 拷贝 hello sudo cp hello new_romfs/bin 生成新的 romfs 映像 sudo genromfs -f romfs_newimg -d new_romfs/ 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 19 / 46
4 建立新的 skyeye 配置文件 复制 skyeyeconf 为 skyeye_newconf cp skyeyeconf skyey_newconf 修改 skyeye_newcong, 使之使用新的 romfs 映像 romfs_newimg #skyeye config file sample 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_newimg 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=10001 net: type=cs8900a, ethmod=tuntap, hostip=10001 #dbct: state=on 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 20 / 46
5 运行 运行 skyeye skyeye -c skyeyeconf -e linux 见到命令提示符 /> 后, 运行 bin/hello 将会进入 HelloWorld! 死循环 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 21 / 46
Outline 1 SkyEye 简介 2 SkyEye 的安装 SkyEye 的安装试用 skyeye 下载 skyeye 源代码, 编译并安装 3 启动 Linux 执行自己的程序添加 hello 到 uclinux 的根文件系统中在 ArmLinux 中运行 hello 4 编译 linux 编译 armlinux 编译 µclinux 5 小结和作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 22 / 46
1 建立交叉编译环境 下载交叉编译工具 ftp://ftparmlinuxorguk/pub/armlinux/toolchain cross-2953tarbz2 解压缩到 /usr/local/arm 目录下或当前工作目录下 tar -jxf cross-2953tarbz2 设置执行路径, 在 bashrc 中添加交叉编译器的 bin 目录 exprot PATH = $PATH : /usr/local/arm/2953/bin 然后, 退出控制台, 重新启动控制台目的 : 使得更新后的 bashrc 文件起作用 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 23 / 46
1 建立交叉编译环境 检查是否建立好交叉编译环境 arm-linux- < tab > arm-linux-<tab> arm-linux-addr2line arm-linux-gasp arm-linux-protoize arm-linux-ar arm-linux-gcc arm-linux-ranlib arm-linux-as arm-linux-gcj arm-linux-readelf arm-linux-c++ arm-linux-ld arm-linux-size arm-linux-c++filt arm-linux-nm arm-linux-strings arm-linux-g++ arm-linux-objcopy arm-linux-strip arm-linux-g77 arm-linux-objdump arm-linux-unprotoize 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 23 / 46
1 建立交叉编译环境 试运行 arm-linux-gcc, 查看其版本 : arm-linux-gcc -v arm-linux-gcc -v Reading specs from /usr/local/arm/2953/lib/gcc-lib/arm-linux/2953/specs gcc version 2953 20010315 (release) 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 23 / 46
2 准备 hello helloc 循环输出 HelloWorld! #include <stdioh> int main(void){ while(1) printf( HelloWorld!\n ); return 0; } 交叉编译, 选择静态编译 arm linux gcc static o hello helloc file hello hello: ELF 32-bit LSB executable, ARM, version 1, statically linked, for GNU/Linux 200, not stripped 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 24 / 46
3 将 hello 加入到根文件系统中 选择 skyeye-testsuite-125/linux/ep7312/26x 查看所使用的根文件系统是哪一个 vi skyeyeconf cpu: arm720t mach: ep7312 mem_bank: map=m, type=rw, addr=0x00000000, size=0x00400000 mem_bank: map=i, type=rw, addr=0x80000000, size=0x00010000 mem_bank: map=m, type=rw, addr=0xc0000000, size=0x00200000 mem_bank: map=m, type=rw, addr=0xc0200000, size=0x00600000, file=/initrd_oldimg mem_bank: map=m, type=rw, addr=0xc0800000, size=0x00800000 #lcd:type=ep7312,mod=gtk #dbct:state=on 挂载根文件系统到 rootfs 上 mkdir rootfs sudo mount -o loop initrd_oldimg rootfs/ 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 25 / 46
3 将 hello 加入到根文件系统中 拷贝 hello 到根文件系统中 : 报错!!WHY? sudo cp hello rootfs/bin sudo cp hello rootfs/bin cp: 写入 rootfs/bin/hello 出错 : 设备上没有空间 cp: 扩展 rootfs/bin/hello 失败 : 设备上没有空间 查看 initrd_oldimg 的文件大小信息, 发现其大小为 6MB 查看 skyeyeconf 文件中, 加载 initrd_oldimg 的存储空间大小, 也是 6MB 怎么办? 改变映像的大小? 改变 skyeyeconf 中存储空间大小? 一种可能的解决方法 : 删除旧的映像中目前用不到的内容 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 25 / 46
3 将 hello 加入到根文件系统中 1 建立一个新的映像文件, 并格式化为 ext2 文件系统 dd of = myinitrd6mimg if = /dev/zero bs = 2048 count = 3072 mke2fs -F -v -m0 myinitrd6mimg 2 将 rootfs 的内容拷贝到一个 temp 目录中 sudo umount rootfs/ sudo mount -o loop initrd_oldimg rootfs/ mkdir temp sudo cp -r rootfs/* temp/ sudo umount rootfs 3 删除 temp 中 usr/local/lib 目录下的 minigui 目录 ( 暂时用不到 ) sudo rm -r usr/local/lib/minigui 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 25 / 46
3 将 hello 加入到根文件系统中 4 复制 temp 到新的映像文件中, 复制 hello 到新的映像文件中 mkdir rootfs_new sudo mount -o loop myinitrd6mimg rootfs_new/ sudo cp -r temp/* rootfs_new/ sudo cp hello rootfs_new/bin sudo umount rootfs_new 完整的解决方案后面再介绍 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 25 / 46
4 建立新的 skyeye 配置文件 复制 skyeyeconf 到 skyeye_newconf 修改 skyeye_newcong, 使其使用新的映像文件 cpu: arm720t mach: ep7312 mem_bank: map=m, type=rw, addr=0x00000000, size=0x00400000 mem_bank: map=i, type=rw, addr=0x80000000, size=0x00010000 mem_bank: map=m, type=rw, addr=0xc0000000, size=0x00200000 mem_bank: map=m, type=rw, addr=0xc0200000, size=0x00600000, file=/myinitrd6mimg mem_bank: map=m, type=rw, addr=0xc0800000, size=0x00800000 #lcd:type=ep7312,mod=gtk #dbct:state=on 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 26 / 46
5 运行 skyeye -e vmlinux -c skyeye_newconf Welcome to / \ / \ / \_/ \ _ / _ \ / /\ /\ \ / /_\ \ / / \_/ \ \ _ \ \ \/ / / / \ \ \ \ _ _ / \ /_/ \_\ \_\ _ _ _ _ _ \ \_/\_/ ARMLinux for Skyeye For further information check: http://hpclabcstsinghuaeducn/~skyeye/ Command: #/bin/demobmp Execution Finished, Exiting Command: /bin/sh Sash command shell (version 111) /> 运行 hello 进入 HelloWorld! 死循环 bin/hello 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 27 / 46
Outline 1 SkyEye 简介 2 SkyEye 的安装 3 启动 Linux 执行自己的程序 4 编译 linux 编译 armlinux 编译 µclinux 5 小结和作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 28 / 46
Outline 1 SkyEye 简介 2 SkyEye 的安装 SkyEye 的安装试用 skyeye 下载 skyeye 源代码, 编译并安装 3 启动 Linux 执行自己的程序添加 hello 到 uclinux 的根文件系统中在 ArmLinux 中运行 hello 4 编译 linux 编译 armlinux 编译 µclinux 5 小结和作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 29 / 46
1 准备交叉编译环境 I 直接安装 sudo apt-get install gcc-arm-linux-gnueabi arm-linux-gnueabi-<tab> arm-linux-gnueabi-<tab> arm-linux-gnueabi-addr2line arm-linux-gnueabi-ar arm-linux-gnueabi-as arm-linux-gnueabi-c++filt arm-linux-gnueabi-cpp arm-linux-gnueabi-cpp-47 arm-linux-gnueabi-dwp arm-linux-gnueabi-elfedit arm-linux-gnueabi-gcc arm-linux-gnueabi-gcc-47 arm-linux-gnueabi-gcc-ar-47 arm-linux-gnueabi-gcc-nm-47 arm-linux-gnueabi-gcc-ranlib-47 arm-linux-gnueabi-gcov arm-linux-gnueabi-gcov-47 arm-linux-gnueabi-gprof arm-linux-gnueabi-ld arm-linux-gnueabi-ldbfd arm-linux-gnueabi-ldgold arm-linux-gnueabi-nm arm-linux-gnueabi-objcopy arm-linux-gnueabi-objdump arm-linux-gnueabi-ranlib arm-linux-gnueabi-readelf arm-linux-gnueabi-size arm-linux-gnueabi-strings arm-linux-gnueabi-strip 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 30 / 46
1 准备交叉编译环境 II 或者下载 arm-linux-tools-20061213targz 安装 在主机的系统根目录下或在当前目录下解压缩 sudo tar zvxf arm-linux-tools-20061213targz 查看安装是否成功 /usr/local/bin/arm-linux-<tab> arm-linux-addr2line arm-linux-g77 arm-linux-jv-scan arm-linux-addr2nameawk arm-linux-gcc arm-linux-ld arm-linux-ar arm-linux-gcc-344 arm-linux-ldreal arm-linux-arm-linux-gcjh arm-linux-gccbug arm-linux-nm arm-linux-as arm-linux-gcj arm-linux-objcopy arm-linux-c++ arm-linux-gcjh arm-linux-objdump arm-linux-c++filt arm-linux-gcov arm-linux-ranlib arm-linux-cpp arm-linux-gnatbind arm-linux-readelf arm-linux-elf2flt arm-linux-grepjar arm-linux-size arm-linux-flthdr arm-linux-jar arm-linux-strings arm-linux-g++ arm-linux-jcf-dump arm-linux-strip 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 31 / 46
1 准备交叉编译环境 III 查看版本信息 /usr/local/bin/arm-linux-gcc -v Reading specs from /home/xlanchen/workspace/usr/local/bin//lib/gcc/arm-linux/344/specs Configured with: /configure target=arm-linux disable-shared prefix=/usr/local with-headers=/home/gerg/new-waveixdp425/linux-24x/include with-gnu-as with-gnu-ld enable-multilib Thread model: posix gcc version 344 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 32 / 46
编译 armlinux 从 kernelorg 上找到 china 的镜像网站, 下载 linux-2626tarbz2 在工作目录 $WDIR 中解压缩, 后执行如下命令 ( 或者使用 CROSS_COMPILE=arm-linux-gnueabi-) cd linux-2626 make ARCH=arm CROSS_COMPILE=arm-linux- s3c2410_defconfig make ARCH=arm CROSS_COMPILE=arm-linux- menuconfig 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 33 / 46
编译 armlinux 修改如下 : 修改 include/asm-arm/arch-s3c2410/maph #define S3C2410_CS6 (0xC0000000UL) 修改 include/asm-arm/arch-s3c2410/memoryh #define PHYS_OFFSET (0xC0000000UL) Boot options Default kernel command string: mem=32m console=ttysac0 root=/dev/ram initrd=0xc0800000,0x00800000 rw Device Driver Character Driver Serial Driver, 取消 8250/16550 and compatible serial support 选项 [ 可选 ]File systems 中, 仅仅保留 ext2 [ 可选 ]Networking, 取消 Networking support [ 可选 ]Device Driver, 取消 I2C support 和 USB support 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 33 / 46
编译 armlinux 编译 make ARCH=arm CROSS_COMPILE=arm-linux- 需要等待较长时间 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 33 / 46
准备根文件系统 在后面的课程中准备 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 34 / 46
Outline 1 SkyEye 简介 2 SkyEye 的安装 SkyEye 的安装试用 skyeye 下载 skyeye 源代码, 编译并安装 3 启动 Linux 执行自己的程序添加 hello 到 uclinux 的根文件系统中在 ArmLinux 中运行 hello 4 编译 linux 编译 armlinux 编译 µclinux 5 小结和作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 35 / 46
1 准备交叉编译环境 I 下载 arm-linux-tools-20061213targz 在主机的系统根目录下或在当前目录下解压缩 sudo tar zvxf arm-linux-tools-20061213targz 查看安装是否成功 /usr/local/bin/arm-linux-<tab> arm-linux-addr2line arm-linux-g77 arm-linux-jv-scan arm-linux-addr2nameawk arm-linux-gcc arm-linux-ld arm-linux-ar arm-linux-gcc-344 arm-linux-ldreal arm-linux-arm-linux-gcjh arm-linux-gccbug arm-linux-nm arm-linux-as arm-linux-gcj arm-linux-objcopy arm-linux-c++ arm-linux-gcjh arm-linux-objdump arm-linux-c++filt arm-linux-gcov arm-linux-ranlib arm-linux-cpp arm-linux-gnatbind arm-linux-readelf arm-linux-elf2flt arm-linux-grepjar arm-linux-size arm-linux-flthdr arm-linux-jar arm-linux-strings arm-linux-g++ arm-linux-jcf-dump arm-linux-strip 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 36 / 46
1 准备交叉编译环境 II 查看版本信息 /usr/local/bin/arm-linux-gcc -v Reading specs from /home/xlanchen/workspace/usr/local/bin//lib/gcc/arm-linux/344/specs Configured with: /configure target=arm-linux disable-shared prefix=/usr/local with-headers=/home/gerg/new-waveixdp425/linux-24x/include with-gnu-as with-gnu-ld enable-multilib Thread model: posix gcc version 344 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 37 / 46
2 配置并编译 uclinux 1 下载源代码 uclinux-dist-20140504tarbz2 2 解压缩 tar -jvxf uclinux-dist-20140504tarbz2 3 配置并编译 export LDLIBS=-ldl( 可能需要 ) make xconfig 在 vendor/product 选项中选择 GDB/ARMulator Kernel 版本选择 24x 其他选项不变 ( 使用缺省选项 ) make dep; make 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 38 / 46
2 配置并编译 uclinux 4 查看编译出来的内核映像 images 目录下 images/ bootrom linux romfs-instlog linux-24x 目录下的 linux 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 38 / 46
看一看 Linux 的链接命令, 了解 linux 文件的组成 arm-linux-ld -p -X -T arch/armnommu/vmlinuxlds arch/armnommu/kernel/head-armvo arch/armnommu/kernel/init_tasko init/maino init/versiono init/do_mountso \ start-group \ arch/armnommu/kernel/kernelo arch/armnommu/mm/mmo arch/armnommu/mach-atmel/atmelo kernel/kernelo mmnommu/mmnommuo fs/fso ipc/ipco \ drivers/char/charo drivers/serial/serialo drivers/block/blocko drivers/misc/misco drivers/net/neto drivers/media/mediao \ net/networko \ arch/armnommu/lib/liba /media/xlanchen/store/work/5 教学 /2014FallEmbeddedOS/uClinux-dist/linux-24x/lib/liba /usr/local/lib/gcc/arm-linux/344/soft-float/libgcca \ end-group \ -o linux 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 39 / 46
看一看 romfs 的生成命令, 了解 romfs 来源 genromfs -v -V ROMdisk -f /media/xlanchen/store/work/5 教学 /2014FallEmbeddedOS/uClinux-dist/images/bootrom -d /media/xlanchen/store/work/5 教学 /2014FallEmbeddedOS/uClinux-dist/romfs 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 40 / 46
看一看 romfs 中的内容 1 到 romfs 目录看看 2 根据编译的输出信息查看 3 挂载起来看一看 编译输出信息如下 : < 目录深度 >< 文件 / 目录名 >[ 设备号,inode 节点号 ]<mode><size>[link] 0 ROMdisk [0xffffffff, 0xffffffff] 37777777777, sz 0, at 0x0 1 [0x824, 0x8e3c42 ] 0040775, sz 0, at 0x20 1 [0x824, 0x8e2a1a ] 0040755, sz 0, at 0x40 [link to 0x20 ] 1 etc [0x824, 0x8e3c45 ] 0040775, sz 0, at 0x60 2 rc [0x824, 0x8e3c86 ] 0100644, sz 207, at 0x80 2 [0x824, 0x8e3c42 ] 0040775, sz 0, at 0x170 [link to 0x20 ] 2 passwd [0x824, 0x8e3c8a ] 0100644, sz 21, at 0x190 2 [0x824, 0x8e3c45 ] 0040775, sz 0, at 0x1d0 [link to 0x60 ] 2 version [0x824, 0x8e3c8b ] 0100664, sz 73, at 0x1f0 2 inetdconf [0x824, 0x8e3ca3 ] 0100664, sz 44, at 0x260 2 ramfsimg [0x824, 0x8e3c9f ] 0100644, sz 2874, at 0x2b0 2 services [0x824, 0x8e3c88 ] 0100644, sz 8205, at 0xe10 2 motd [0x824, 0x8e3c89 ] 0100644, sz 343, at 0x2e40 2 inittab [0x824, 0x8e3c87 ] 0100644, sz 49, at 0x2fc0 1 bin [0x824, 0x8e3c43 ] 0040775, sz 0, at 0x3020 2 telnetd [0x824, 0x8e3ca2 ] 0100744, sz 45764, at 0x3040 2 [0x824, 0x8e3c42 ] 0040775, sz 0, at 0xe330 [link to 0x20 ] 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 41 / 46
3 在 skyeye 上运行 uclinux 从 skyeye-testsuite-125/uclinux/at91/uclinux_cs 8900a/ 目录下复制 skyeyeconf 和 romfsimg 运行 : skyeye -e linux -c skyeyeconf 直接使用编译生成的 bootrom 失败但由于配置不一致, 在进入 shell 之前有个别错误 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 42 / 46
3 在 skyeye 上运行 uclinux skyeyeconf 的内容如下 : skyeyeconf #skyeye config file sample 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=/romfsimg 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=10001 net: type=cs8900a, ethmod=tuntap, hostip=10001 #dbct: state=on 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 42 / 46
3 在 skyeye 上运行 uclinux 进入 uclinux 界面如下 : Welcome to _ / _ _ \ \ \/ / _ _ / \ \ _ _ _ _ \ \_/\_/ _ GDB/ARMulator support by <davidm@snapgearcom> For further information check: http://wwwuclinuxorg/ Command: /bin/ifconfig eth0 up 10002 SIOCGIFFLAGS: No such device SIOCSIFADDR: No such device pid 11: failed 512 Execution Finished, Exiting init: Booting to single user mode Sash command shell (version 111) /> 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 42 / 46
Outline 1 SkyEye 简介 2 SkyEye 的安装 3 启动 Linux 执行自己的程序 4 编译 linux 5 小结和作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 43 / 46
小结 1 SkyEye 简介 2 SkyEye 的安装 SkyEye 的安装试用 skyeye 下载 skyeye 源代码, 编译并安装 3 启动 Linux 执行自己的程序添加 hello 到 uclinux 的根文件系统中在 ArmLinux 中运行 hello 4 编译 linux 编译 armlinux 编译 µclinux 5 小结和作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 44 / 46
Project3 在 skyeye 上成功跑出 armlinux 和 µclinux 可以使用现成的映像 [ 可选, 加分 ] 可以自己编译 分别将 hello 加入到 armlinux 和 µclinux 的根文件系统中, 在 skyeye 上启提交报告, 要求要说明 难度 : 被使用的 armlinux 和 µclinux 的版本和 Linux 内核的版本 [ 可选, 加分 ] 若自己编译了内核, 给出编译 armlinux 和 µclinux 的交叉编译 hello 的交叉编译器的版本和编译过程给出关键输出的图示 armlinux>µclinux> 使用现成的内核 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 45 / 46
Thanks! The end 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 @ 计算机学院嵌入式系统实验室嵌入式操作系统 @ 苏州研究院中国科学技术大学 November 28, Fall 20142014) 46 / 46