1. 程式人生 > 其它 >MDK debug時出現*** error 65: access violation at問題

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) {
// Debug MCU Configuration
// <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
其他不用關心