mdk debug.ini script for debugging programs in ram

Reference source: KEIL-MDK startup script for debugging programs in memory.
Usage reference: RAM debugging method of STM32F10x program based on firmware library under Keil v5 MDK

Save the following contents as Debug_RAM.ini file:

/*  使用说明
 
    1,使用默认的链接控制文件;
    2,工程选项的Debug标签页中,初始化文件(Initialization File)选择:Debug_RAM.ini
    3,配置代码在内存中的起始地址。
    4,【重要】Utilities标签页中,取消选择:Update Target before Debugging
    5,不要点击“Flash=>Download”下载,直接点击“Debug=>Start Debug Session”开始调试。
 
*/
/*----------------------------------------------------------------------------
 * Name:    Debug_RAM.ini
 * Purpose: RAM Debug Initialization File
 *----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
  Setup()  configure PC & SP for RAM Debug
 *----------------------------------------------------------------------------*/
FUNC void Setup (void) {
  SP = _RDWORD(0x20000000);          // Setup Stack Pointer
  PC = _RDWORD(0x20000004);          // Setup Program Counter
  _WDWORD(0xE000ED08, 0x20000000);   // Setup Vector Table Offset Register
}
 
FUNC void OnResetExec (void)  {      // executes upon software RESET
  Setup();                           // Setup for Running
}
 
load %L incremental
 
Setup();                             // Setup for Running
 
g, main

Note: When using Keil's reset key, you first need to press the stop icon to pause the CPU, and then press reset. Otherwise, the reset will still start from the default position. As shown below:
Insert image description here

Guess you like

Origin blog.csdn.net/weixin_40837318/article/details/131616936
RAM