1、什么情况需要SRAM启动??
- 调试阶段,需要频繁更新程序,可以SRAM启动,加快调试,减少flash擦写损耗
- 程序SWD/JTAG接口已经配置为普通端口,程序启动后无法程序更新,可在SRAM中启动后,再更新flash程序
- 程序已经开启了读保护,可在SRAM启动后,进行读保护关闭
2、stm32 boot启动方式如下
配置boot 为1:1,则可从SRAM内启动
3、stm32f103c8t6 SRAM启动方法(HAL工程为例)
-
KEIL工程配置
注意:Use Memory Layout form Target Dialog 一定要勾选上,这样才会自动更新 对应的sct文件
-
RAM.ini 文件
由于即便通过boot设定,将启动区映射到了SRAM,但程序依旧不能跳转到对应的Reset_Handle,需要RAM.ini进行引导
/******************************************************************************/
/* RAM.INI: RAM Initialization File */
/******************************************************************************/
// <<< Use Configuration Wizard in Context Menu >>> //
/******************************************************************************/
/* This file is part of the uVision/ARM development tools. */
/* Copyright (c) 2005-2007 Keil Software. All rights reserved. */
/* This software may only be used under the terms of a valid, current, */
/* end user licence from KEIL for a compatible version of KEIL software */
/* development tools. Nothing else gives you the right to use this software. */
/******************************************************************************/
FUNC void Setup (void) {
SP = _RDWORD(0x20000000); // Setup Stack Pointer
PC = _RDWORD(0x20000004); // Setup Program Counter
_WDWORD(0xE000ED08, 0x20000000); // Setup Vector Table
}
LOAD !L INCREMENTAL // Download
Setup(); // Setup for Running
g, main
- 中断向量修改
int main(void)
{
/* USER CODE BEGIN 1 */
SCB->VTOR = SRAM_BASE;
/* USER CODE END 1 */
...
}