一、安装下载arm-gcc 编译器:
二、在keil中配置gcc:

三、配置工程选项
1.配置gcc编译规则:
Misc Controls : -mcpu=cortex-m3 -mthumb -fdata-sections -ffunction-sections
注:
1.这里我用的cortex-m3,如果你是m4内核就改成4)
2.-mthumb的意义是:使用这个编译选项生成的目标文件是Thumb的
3.-fdata-sections和-ffunction-sections (-ffunction-sections 和 -fdata-sections 将每个函数或符号创建为一个sections,其中每个sections名与function或data名保持一致)

2.配置汇编规则:
Misc Controls : -mcpu=cortex-m3 -mthumb

3配置链接规则:
这里要添加链接脚本,一般可以在官方提供的固件库包找到类似的(链接规则)
Misc Controls : -Wl,--gc-sections
注:
1.-wl, 表示后面的参数 --gc-sections 传递给链接器( -Wl,--gc-sections 指示链接器去掉不用的section(其中-wl, 表示后面的参数 --gc-sections 传递给链接器),这样就能减少最终的可执行程序的大小了。)

4.找到适合自己芯片的链接文件(在官方例程有):

其内容:
/*
*****************************************************************************
**
** File : stm32_flash.ld
**
** Abstract : Linker script for STM32F207IG Device with
** 1MByte FLASH, 128KByte SRAM
**
** Set heap size, stack size and stack location according
** to application requirements.
**
** Set memory bank area and size if external memory is used.
**
** Target : STMicroelectronics STM32
**
** Environment : Atollic TrueSTUDIO(R)
**
** Distribution: The file is distributed “as is,” without any warranty
** of any kind.
**
** (c)Copyright Atollic AB.
** You may use this file as-is or modify it according to the needs of your
** project. Distribution of this file (unmodified or modified) is not
** permitted. Atollic AB permit registered Atollic TrueSTUDIO(R) users the
** rights to distribute the assembled, compiled & linked contents of this
** file as part of an applic


4046

被折叠的 条评论
为什么被折叠?



