Eclipse J-Link ATMEL ARM ATSAME70Q21。当代码从不同于 0x00400000 的地址开始时进行调试
Posted
技术标签:
【中文标题】Eclipse J-Link ATMEL ARM ATSAME70Q21。当代码从不同于 0x00400000 的地址开始时进行调试【英文标题】:Eclipse J-Link ATMEL ARM ATSAME70Q21. Debugging when the code starts at a different address than 0x00400000 【发布时间】:2019-04-08 12:42:08 【问题描述】:我正在尝试在 ATMEL ATSAME70Q21 上使用带有 J-Link 的 Eclipse。 当代码起始地址位于默认地址 0x00400000 时,我能够完美地调试代码。 它下载代码,在主断点处停止等。所有调试命令似乎都工作正常。
但是,当我将链接器文件上的地址更改为 0x00420000 时,代码已下载,但未命中主函数处的断点。 在控制台上可以看到很多消息(见下文)。
我试图通过在调试配置中发出以下命令将 VTOR 寄存器设置为 0x0420000 |启动 |运行/重启命令 监控 memU32 0xE000ED08 = 0x0420000 但它的行为仍然相同。 我相信 ARM 正在尝试在与内存 0x00420004 中定义的起点不同的地址执行代码......
有什么想法吗?
控制台输出可以在下面找到。 Flash 被编程和验证。 但是最后两行表明有问题...
SEGGER J-Link GDB Server V6.34h Command Line Version
JLinkARM.dll V6.34h (DLL compiled Oct 9 2018 15:50:01)
Command line: -if swd -device ATSAME70Q21 -endian little -speed 1000 -port 2331 -swoport 2332 -telnetport 2333 -vd -ir -localhostonly 1 -log /home/user/svn/SDCO-504/AtmelSAM-2/FreeRTOS_IP_SAME70_v3/Debug/GDBlog -singlerun -strict -timeout 0 -nogui
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: localhost only
Generate logfile: on
Verify download: on
Init regs on start: on
Silent mode: off
Single run mode: on
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: ATSAME70Q21
Target interface: SWD
Target interface speed: 1000kHz
Target endian: little
Connecting to J-Link...
J-Link is connected.
Firmware: J-Link V10 compiled Sep 4 2018 11:24:21
Hardware: V10.10
SAM-ICE found !
S/N: 20125801
OEM: SAM-ICE
Feature(s): RDI, GDB
Checking target voltage...
Target voltage: 3.32 V
Listening on TCP/IP port 2331
Connecting to target...Connected to target
Waiting for GDB connection...Connected to 127.0.0.1
Reading all registers
Read 4 bytes @ address 0x00000000 (Data = 0x20459B48)
Read 2 bytes @ address 0x00000000 (Data = 0x9B48)
Received monitor command: speed 1000
Target interface speed set to 1000 kHz
Received monitor command: clrbp
Received monitor command: reset
Resetting target
Received monitor command: halt
Halting target CPU...
...Target halted (PC = 0x0040E410)
Received monitor command: regs
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= 20459B48, MSP= 20459B48, PSP= 00000000
R14(LR) = FFFFFFFF, R15(PC) = 0040E410
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
Reading all registers
Read 4 bytes @ address 0x0040E410 (Data = 0xB084B580)
Read 2 bytes @ address 0x0040E410 (Data = 0xB580)
Received monitor command: speed auto
Select auto target interface speed (2000 kHz)
Received monitor command: flash breakpoints 1
Flash breakpoints enabled
Read 4 bytes @ address 0x0040E410 (Data = 0xB084B580)
Read 2 bytes @ address 0x0040E410 (Data = 0xB580)
Downloading 16128 bytes @ address 0x00420000 - Verified OK
Downloading 16080 bytes @ address 0x00423F00 - Verified OK
Downloading 16112 bytes @ address 0x00427DD0 - Verified OK
Downloading 16128 bytes @ address 0x0042BCC0 - Verified OK
Downloading 16064 bytes @ address 0x0042FBC0 - Verified OK
Downloading 14764 bytes @ address 0x00433A80 - Verified OK
Downloading 8 bytes @ address 0x0043742C - Verified OK
Downloading 2536 bytes @ address 0x00437434 - Verified OK
Comparing flash [....................] Done.
Verifying flash [....................] Done.
Writing register (PC = 0x 420000)
Read 4 bytes @ address 0x00420000 (Data = 0x20459B48)
Read 2 bytes @ address 0x00420000 (Data = 0x9B48)
Read 2 bytes @ address 0x0042FD5A (Data = 0xF7FF)
Read 2 bytes @ address 0x0042FD5A (Data = 0xF7FF)
Received monitor command: clrbp
Received monitor command: reset
Resetting target
Received monitor command: halt
Halting target CPU...
...Target halted (PC = 0x0040E410)
Received monitor command: memU32 0xE000ED08 = 0x0420000
Writing 0x00420000 @ address 0xE000ED08
Read 2 bytes @ address 0x0042FD5A (Data = 0xF7FF)
Read 2 bytes @ address 0x0042FD5A (Data = 0xF7FF)
Read 2 bytes @ address 0x0042FD5A (Data = 0xF7FF)
Received monitor command: regs
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= 20459B48, MSP= 20459B48, PSP= 00000000
R14(LR) = FFFFFFFF, R15(PC) = 0040E410
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
Reading all registers
Read 4 bytes @ address 0x0040E410 (Data = 0xB084B580)
Read 2 bytes @ address 0x0040E410 (Data = 0xB580)
Read 2 bytes @ address 0x0042FD5A (Data = 0xF7FF)
Read 2 bytes @ address 0x0042FD5A (Data = 0xF7FF)
WARNING: Failed to read memory @ address 0xFFFFFFFE
WARNING: Failed to read memory @ address 0xFFFFFFFE
【问题讨论】:
通常这将来自您的 C 链接器,应该从那里进行更改,以便生成正确的向量表。您的应用程序代码从哪里开始无关紧要,重要的是重置向量在哪里,然后从那里获取它。重置向量将调用 CRT,该 CRT 将调用 main()。通常您可以定义启动函数的名称,然后链接器会为您处理一切。至于如何从 Total Eclipse 中做到这一点,我不知道。 【参考方案1】:您想在地址 0xE000ED08 处设置值,因此命令必须是:
set *0xE000ED08 = 0x0420000
我也很确定您需要将堆栈指针和程序计数器设置为有意义的地址,这可以通过这种方式完成:
set $sp = *(unsigned int*)0x0420000
set $pc = *(unsigned int*)0x0420004
请记住,此设备上的程序计数器实际上提前 4 个字节。
【讨论】:
谢谢。有用。 :) 我在哪里可以找到描述这些命令(set $...)和其他命令的手册?我认为这是 GDB 服务器的命令,但我找不到任何描述可用命令的手册。只有命令行调用... 我已经从这里 (darkdust.net/files/GDB%20Cheat%20Sheet.pdf) 打印了 GDB 备忘单,并将其固定在我办公室屏幕上方的墙上。 ;) 对于其他任何内容,您可以随时查看官方文档:sourceware.org/gdb/current/onlinedocs/gdb以上是关于Eclipse J-Link ATMEL ARM ATSAME70Q21。当代码从不同于 0x00400000 的地址开始时进行调试的主要内容,如果未能解决你的问题,请参考以下文章
J-Link固件烧录以及使用J-Flash向arm硬件板下载固件程序
Eclipse MCU J-Link 调试器在 ldrb r3,[r7,#8] 上崩溃。地址有效 - [编辑 - 硬件问题]