Simplicity Studio通过makefile.targets实现post-build
来源:互联网 发布:淘宝贷款在哪里还 编辑:程序博客网 时间:2024/06/04 18:46
在开发产品的过程中,对于生成firmware文件通常会加入一些checksum或者flag,避免用户更新了错误的文件导致无法开机等严重后果。
有时是编写一个图形界面的程序,然后手动运行修改firmware文件,但是这样做比较繁琐,每次测试时都需要手动操作一次,其实很多编译工具都支持post-build的功能,可以在build之后自动执行一些命令来达到自动添加checksum和flag的目的。
现在来讲一下Silicon Simplicity Studio post-build的用法。
原本在Simplicity Studio的图像设备界面里是有post-build选项的,Project的Properties-> C/C++ Build-> Build Steps-> Post-build steps Command,Silicon的官方网站上介绍了些功能:Adding a post build step in Simplicity IDE
但是此功能有个问题,它是在编译出*.axf后就执行的,然后才生成bin和hex文件,想要针对bin或者hew文件做些文章很明显从先后顺序上看不合理,于是在官网上看到这个帖子:Post-build steps,在工程根目录添加makefile.targets的方式可以解决此问题,实践后有效。
以下是我的makefile.targets文件内容,针对链接中的范例加入了环境变量判断工程名字和路径等内容。
NewFileName=FW-FLAG.binCurFolder=$(notdir $(CURDIR))ProjectPath=$(subst /$(CurFolder),,$(CURDIR))Projectname=$(notdir $(ProjectPath))ProductName=$(shell cat $(ProjectPath)/Product_Name.inc)all: $(Projectname).axf post-build.NOTPARALLEL: post-build:-../AddIdentify "$(CURDIR)/$(Projectname).bin" "$(NewFileName)" $(ProductName)
- NewFileName:想要生成带checksum和flag的新文件名。
- CurFolder:当前文件夹名字,通过notdir去掉当前路径中的,GNU ARM v4.8.3 - Debug。
- ProjectPath:工程路径,通过当前路径中去掉编译路径来得到。
- Projectname:工程名,通过去掉路径得到,
- ProductName:自定义内容,可以通过从文件中读取,比如我的文件中写的是Product-BrightWaters
- all行,默认情况下生成的axf文件为项目名.axf。
- Post-build:想执行的命令,此处通过自己编写的AddIdentify.exe的控制台程序来给bin文件添加checksum和flag
文件中各变量的值有些繁琐,原本是想直接使用ProjName这样的变量,但是无法使用,可能是编译过程中IDE没有把相应变量传递给makefile.targets文件吧。
下边是我的AddIdentify示例程序:
int main(int argc, char* argv[]){ printf("\n************************\n Add identify to image\n"); nError = 0; printf("argc = %d\n",argc); for(int i = 0; i < argc; i++) { printf("argv[%d]: %s\n",i,argv[i]); }printf("-->Output: %s\n",szNewFile); return 0;}
可以通过printf将运行中的内容传递给Simplicity Studio显示。
编译结果:main函数的返回值会被Simplicity Studio识别为错误的个数。
根据自己的需要修改makefile.targets和AddIdentify,编译后直接生成所需要的文件,相当方便,有兴趣的就尝试一下吧。
- Simplicity Studio通过makefile.targets实现post-build
- Simplicity Studio--energyAware Commander 连接Jlink V8
- Makefile.build
- Post Build Event for CxxTest in Visual Studio 2005
- Visual Studio 在Post build Event 调用 signtool
- 关于Simplicity Studio使用math.h编译出错。
- 如何使用Simplicity Studio查看MCU内部Flash的数据
- android studio通过build.gradle动态改变AndroidMainfest.xml
- Android Studio 通过配置build.gradle打包签名文件
- Targets
- Android 通过post上传文件--HttpURLConnection实现
- Build Actions (pre-build and post-build)
- How to build multiple targets from a single Xcode Project
- makefile.build(ZT)
- make: *** No targets specified and no makefile found. Stop.
- make: *** No targets specified and no makefile found. Stop.解决方法
- memcached make: *** No targets specified and no makefile found. Stop.
- make: *** No targets specified and no makefile found. Stop.
- Git学习总结
- Java集合类
- 细说JVM系列:JVM内存空间分区
- windows中常用文件位置
- [leetcode]238. Product of Array Except Self -- Java 代码
- Simplicity Studio通过makefile.targets实现post-build
- 广义表及其存储方式简介
- 只为记录生活和工作的点滴
- MD5算法原理
- poj1039Pipe
- 【Qt开发】Qt中图像的显示与基本操作
- 二,Node的交互式环境(REPL)
- ubuntu下mongodb操作部分整理
- LIGHT OJ 1307 - Counting Triangles【二分枚举】