Keil中配置GCC编译器开发STM32

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

一、下载编译链:
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.) *
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值