MDK debug时出现*** error 65: access violation at问题
简介
本文针对的是访问内存权限的问题,其他问题暂时不讨论。
问题描述
使用mdk arm调试keil工程的时候遇到错误*** error 65: access violation at 0xE0042004 : no 'write' permission,如下图:
问题分析
访问内存地址没有权限,可能是没有读权限,可能是没有写权限或者执行权限。
解决办法
办法1:
进入debug模式,调出memory map工具(在debug选项下),添加对应的内存映射范围,并设置权限;
如下图所示:
办法2:
新建一个*.ini文件,把内存映射范围和权限添加进去(使用MAP命令),然后把这个文件设置为debug初始化脚本。示例如下:
//
/ STM32DBG.INI: STM32 Debugger 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. /
//
MAP 0xE0042004, 0xE0042104 READ WRITE // allow R/W access to IO space
FUNC void DebugSetup (void) {
//
// <o1.0> DBG_SLEEP Debug Sleep Mode
// <o1.1> DBG_STOP Debug Stop Mode
// <o1.2> DBG_STANDBY Debug Standby Mode
// <o1.5> TRACE_IOEN Trace I/O Enable
// <o1.6..7> TRACE_MODE Trace Mode
// <0=> Asynchronous
// <1=> Synchronous: TRACEDATA Size 1
// <2=> Synchronous: TRACEDATA Size 2
// <3=> Synchronous: TRACEDATA Size 4
// <o1.8> DBG_IWDG_STOP Independant Watchdog Stopped when Core is halted
// <o1.9> DBG_WWDG_STOP Window Watchdog Stopped when Core is halted
// <o1.10> DBG_TIM1_STOP Timer 1 Stopped when Core is halted
// <o1.11> DBG_TIM2_STOP Timer 2 Stopped when Core is halted
// <o1.12> DBG_TIM3_STOP Timer 3 Stopped when Core is halted
// <o1.13> DBG_TIM4_STOP Timer 4 Stopped when Core is halted
// <o1.14> DBG_CAN_STOP CAN Stopped when Core is halted
//
_WDWORD(0xE0042004, 0x00000027); // DBGMCU_CR
_WDWORD(0xE000ED08, 0x20000000); // Setup Vector Table Offset Register
}
DebugSetup(); // Debugger Setup
关键语句:MAP 0xE0042004, 0xE0042104 READ WRITE
其他不用关心
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律