MDK-Debug设置之Download to Flash

µVISION DEBUGGER: ERROR 57: ILLEGAL ADDRESS IN DEBUGGER OUTPUT WINDOW


Information in this article applies to:

  • MDK-ARM All Versions
  • ULINK2/ULINKpro USB-JTAG Adapter

SYMPTOMS

After starting a debug session on a Cortex-M device the following message is printed in the debugger output window:

*** error 57: illegal address (...)

Why is there an illegal address access?

CAUSE

This can be caused by the debugger when, for example, a memory window's Address field points to a location that cannot be accessed during debugging. Furthermore, this can be caused when the option Download to Flash in Options for Target — Debug — Settings — Debug — Download Options is enabled.

Download to Flash writes code to all memory areas, including those areas defined as Flash. This behavior is not allowed. Instead of writing code directly to Flash memory, you need to program Flash with a Flash programming algorithm. Check the Target Driver Setup — Flash Download dialog.

The Download to Flash option is useful, for example, within systems that have indirect access to the boot memory, like NAND Flash, but execute from SDRAM. In such cases, the SDRAM area is defined as Flash. The code will be processed by a Flash programming algorithm and written to NAND Flash. When booting, the code is copied from NAND to SDRAM and executed there. But when debugging, the code needs to be downloaded to SDRAM by the debugger. With this option, one target can be used for debugging from SDRAM as well as for flashing the application from NAND.

RESOLUTION

Please disable Download to Flash in Options for Target — Debug — Settings — Debug. Now, the illegal address error disappears. If you want to update the target before debugging, please enable Options for Target — Utilities — Update Target before Debugging.

MORE INFORMATION

  • Refer to Debug in the ULINK2 User's Guide.
  • Refer to Debug in the ULINK2 User's Guide.
  • Refer to Debug in the ULINKpro User's Guide.
  • Refer to Debug in the ULINKpro User's Guide.
### Keil5 中魔术棒设置与 DAP 的相关配置 #### 仿真器的配置 在Keil5中进行STM32F103项目的开发时,为了使调试功能正常工作,需正确配置DAP仿真模式。具体操作是在项目窗口点击魔术棒图标进入项目选项对话框,在Debug标签页下拉菜单选择DAP作为目标设备接口方式[^1]。 对于Utilities部分,则应激活Use Debug Driver选项来加载相应的驱动支持。完成上述设定后保存更改并验证系统能否顺利识别所连接的硬件工具链;这一步骤可通过观察IDE状态栏或查阅官方文档获取进一步指导[^2]。 #### 程序烧录后的自动执行及其他必要调整事项 确保应用程序能够在写入闪存区之后立即启动运行是一项重要考量。为此目的而做的参数微调同样位于Project Options界面内的Target分类之下。 另外值得注意的是芯片的具体型号选定以及Hex文件导出路径指定等细节处理也都在此范围内得以体现。特别是后者涉及到最终固件镜像格式的选择,这对于后续利用第三方工具实施在线更新至关重要[^3]。 ```python # 示例代码用于展示如何生成HEX文件 def generate_hex_file(): # 进入项目属性设置页面 project_options = open_project_settings() # 导航至输出项(Output)分组下的创建十六进制文件(Create HEX File)复选框位置 hex_output_option = locate_create_hex_checkbox(project_options) # 启用该选项以允许构建过程中自动生成.hex结果 enable(hex_output_option) generate_hex_file() ``` #### 解决可能遇到的问题 当面对诸如`Flash Download failed`这样的错误提示时,除了确认基本连线无误之外,还需仔细检查包括但不限于电源供应在内的各项物理条件是否满足要求。此外,适当降低波特率(bps)数值有助于提高通信稳定性从而减少潜在冲突的发生几率[^4]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值