一。STM32编译过程及程序组成
STM32编译过程
程序的组成、存储与运行
MDK生成的主要文件分析
1.STM32编译过程

1.源文件(Source code)--》目标文件(Object code)
.c(C语言)通过armcc生成.o,.s(汇编)通过armasm生成.o
2.Object code(目标文件)--》image(镜像文件)
.o通过armlink生成.rlf,.axf,.map
3.image(镜像文件)--》Flash format(可烧写文件)
通过fromelf生成.bin(二进制文件),.hex(ASCII文件)
(2)实例
随便打开一个工程,点击运行,运行结果的第一行有个地址,进入这个地址 。这个地址中就是用来编译的文件。
补充:armar.exe是可以把C语音改成固件库,就是移植程序时,不想复制C语言文件,直接封装成固件库


2.程序的组成,存储与运行
(1)程序组成


(2)程序运行程序


开始运行程序,就从xx.s中找到,开始运行__main(注意不是main),然后开始运行第一个图片
补充:生成反汇编指令 fromelf --text -c --output LedTask\LedTask.text LedTask\LedTask.axf
这个命令来生成汇编指令,是发现bug之后实在改不了,就看这个汇编
注意:未知原因,没有生成成功,地址不对可能

3.MDK生成的主要文件的分析
(1)map文件分析
1、Section Cross References
2、Removing Unused input sections from the image.
3、Image Symbol Table
4、Memory Map of the image
5、Image component sizes


会生成一个map文件,打开之后,可以看到程序使用了什么头文件,代码量在中断还是串口输出,还是FREERTOS。通过参考map改进代码。
(2)set文件分析

(3)hex文件分析

(4)bin文件分析
生成bin文件 fromelf --bin --output LedTask\LedTask.bin LedTask\LedTask.axf
