Eclipse J-Link ATMEL ARM ATSAME70Q21. Debugging when the code starts at a different address than 0x00400000

1

I am trying to use Eclipse with J-Link on an ATMEL ATSAME70Q21. I am able to debug code perfectly when the code start address is at the default address of 0x00400000. It downloads the code, stops at the main breakpoint, etc. All the debug commands seem to work fine.

When however I change the address to 0x00420000 on the linker file the code is downloaded but the break point at the main function is not hit. On the Console it can be seen a lot of messages (see below).

I tried to set the VTOR register to 0x0420000 by issuing the following command in Debug Configuration | Startup | Run/Restart Commands monitor memU32 0xE000ED08 = 0x0420000 but it still behaves the same way. I believe the ARM is trying to execute code at a different address than the starting point defined at memory 0x00420004...

Any ideas?

The console output can be found below. The Flash is programmed and verified. However the last 2 lines are a indication that something is wrong...


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
arm
embedded
asked on Stack Overflow Apr 8, 2019 by Eduardo Goncalves • edited Apr 8, 2019 by Eduardo Goncalves

1 Answer

1

You want to set the value at the address 0xE000ED08 so the command must be:

set *0xE000ED08 = 0x0420000

I'm also pretty sure that you'll need to set the stack pointer and the program counter to meaningful addresses which can be done this way:

set $sp = *(unsigned int*)0x0420000
set $pc = *(unsigned int*)0x0420004

Remember that the program counter on this device is actually 4 byte ahead.

answered on Stack Overflow Apr 8, 2019 by Vinci

User contributions licensed under CC BY-SA 3.0