1、1,Agenda,嵌入式软件开发环境概述 GCC GDB A Simple Example MAKE,2,嵌入式软件开发模型,嵌入式系统的一个特点在于其开发的特殊性与困难性。 开发机器 != 执行机器开发环境 != 执行环境 专门的开发环境与开发工具- VxWorks系统配套的Tornado集成开发工具- Linux系统配套的gcc,gdb等开发工具,3,嵌入式软件开发环境,4,嵌入式软件开发环境,宿主机 开发机器(编辑器、编译器、调试器、.)负责程序的编译和部分调试工作。 目标机 程序运行的机器,负责程序的运行和部分调试工作。 交叉编译是指宿主机和目标机是不同的系统,5,嵌入式软件开发环境,
2、6,Agenda,嵌入式软件开发环境概述 GCC GDB A Simple Example MAKE,7,GCC,Linux下的编译器 GNU项目的C编译器四个步骤- 预处理 preprocessing- 编译 compilation- 汇编 assembly- 连接 linking,8,GCC,9,GCC,-g Produce Debug Information -Wall Warning in detail -E Preprocess only; do not compile, assemble or link -S Compile only; do not assemble or lin
3、k -c Compile and assemble. But do not link -o Place the output into ,10,GCC,GCC的组件,11,Agenda,嵌入式软件开发环境概述 GCC GDB A Simple Example MAKE,12,GDB,Linux下软件调试工具 远端调试- 通过串口或网口调试目标设备- target命令:指定调试目标和建立连接的GDB命令,13,GDB,14,GDB,15,GDB,常用命令,16,Agenda,嵌入式软件开发环境概述 GCC GDB A Simple Example MAKE,17,A Simple Example
4、 Hello.c,18,A Simple Example - Compilation,19,A Simple Example - Debugging,20,Agenda,嵌入式软件开发环境概述 GCC GDB A Simple Example MAKE,21,Make,The make utility automatically determines which pieces of a large program need to be recompiled, and issues commands to recompile them.A Program for Directing Recomp
5、ilation GNU Make是一个自动化的工具。 根据依赖关系自动决定项目的那些部分需要重新编译。 基本原理:如果某个源程序文件被修改,那么依赖这个源程序文件的所有目标文件,都需要重新编译。,22,依赖关系,23,Makefile,Makefile文件控制make程序的执行 一个项目拥有一个或多个makefile文件 每个makefile文件由多条rules构成 每条rule描述了一个依赖关系,并有一系列的行为,24,Makefile Rule,Rule的格式为: target : prerequisites command Target 依赖prerequisites的目标 Prereq
6、uisites 被依赖的源程序,例如c文件或h文件 Command需要执行的命令 当prerequisites任何一个文件的时戳新于target的时戳时,就执行command。,25,A Simple Makefile,26,A Simple Makefile,编译edit项目$ make 删除edit项目中的目标文件$ make clean clean是一个伪目标clean没有任何prerequisites,只有显式的make clean才能执行clean目标的command,27,A Little More Practical Makefile,28,More Abstract,29,Mo
7、re Abstract,SUFFIXES The SUFFIXES thing tells make that files that are possible targets, fall under three categories: files that end in .c, files that end in .o and files that end in nothing. .c.o$(CC) $(CFLAG) c $Tells make how to make .o files from .c files.,30,More Abstract,$ are the dependencies
8、 that changed causing the target to need to be rebuilt $ is the target $ are all the dependencies from the current rule,31,More Abstract,.o:$(CC) $(CFLAG) $ -o $Tells how to make the executable file from the .o files.,32,Enhanced Example,33,Appendix,实做一个简单的Makefile 项目依赖关系图,34,Makefile Demo,35,Makefile Demo,36,Makefile Demo,37,Makefile Demo,38,Makefile Demo,39,Makefile Demo,