一、下载编译链:
https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads
在此我下载的是:gcc-arm-none-eabi-10.3-2021.10-win32.zip

二、安装GCC编译链
直接解压到D盘:

三、配置Keil工程选项:
1、选择使用GCC进行编译

2、配置编译选项
1)配置CC的编译规则

2)Assembler规则

3)Linker选项

四、STM32F103RCTX_FLASH.ld文件(基于STM32F103RCTX系列,其他系列只需要简单修改即可)
/* Entry Point */
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
_Min_Heap_Size = 0x200 ; /* required amount of heap */
_Min_Stack_Size = 0x400 ; /* required amount of stack */
/* Memories definition */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 48K
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 256K
}
/* Sections */
SECTIONS
{
/* The startup code into "FLASH" Rom type memory */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH
/* The program code and other data into "FLASH" Rom type memory */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH
/* Constant data into "FLASH" Rom type memory */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) *

本文介绍如何使用GCC编译器配置STM32F103RC系列微控制器的Keil工程,并解决常见编译错误,如strexb/strexh错误及sbrkr.c未定义引用问题。

4047

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



