Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIMRT1050 + mbed uploading and debuging with J-link #5

Open
EthanGuo1995 opened this issue Sep 17, 2020 · 5 comments
Open

MIMRT1050 + mbed uploading and debuging with J-link #5

EthanGuo1995 opened this issue Sep 17, 2020 · 5 comments

Comments

@EthanGuo1995
Copy link

In my limited experience with PlatformIO IDE, I have been searching for a long time on network but nothing useful.
So I wonder if I can get some help here about how would I modify configuration in file platformio.ini to upload and debug my project with J-link.

My platformio.ini shows as follows:

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:mimxrt1050_evk]
platform = nxpimxrt
board = mimxrt1050_evk
board_build.mcu = MIMXRT1052DVL6A
board_build.upload.offset_address = 0x60000000
framework = mbed
debug_tool    = jlink
upload_protocol = jlink
MCU: MIMXRT1052
platform: nxpimxrt
board: MIMXRT1050-EVK
framework: framework-mbed 6.60200.200722 (6.2.0)
IDE: PlatformIO IDE (VSCode)

Thanks in advance.

@valeros
Copy link
Member

valeros commented Sep 17, 2020

Hi @EthanGuo1995 ! A few comments:

  • Looks like you incorrectly specified the offset address, it should be board_upload.offset_address = 0x60000000.
  • If you're overriding the MCU and using JLink as the debug tool, then it might be a good idea to override the JLink device as well board_debug.jlink_device = MIMXRT1052DVL6A

Everything else looks fine.

@EthanGuo1995
Copy link
Author

Hi @EthanGuo1995 ! A few comments:

  • Looks like you incorrectly specified the offset address, it should be board_upload.offset_address = 0x60000000.
  • If you're overriding the MCU and using JLink as the debug tool, then it might be a good idea to override the JLink device as well board_debug.jlink_device = MIMXRT1052DVL6A

Everything else looks fine.

Thanks you!!! It can work.

And How would I debug the target. Is that correct showing as follows:

......

; Debug options
; debug_tool    = jlink
debug_tool = custom
debug_server =
    JLinkGDBServer
    -singlerun
    -if
    SWD
    -select
    USB
    -port
    2331
    -device
    MIMXRT1052DVL6A

@valeros
Copy link
Member

valeros commented Sep 17, 2020

Why do you need a custom debug server? It should work with debug_tool = jlink.

@EthanGuo1995
Copy link
Author

Why do you need a custom debug server? It should work with debug_tool = jlink.

Emmm. I have changed it back now. But it still didnot work, showing message on console like this:

SEGGER J-Link GDB Server V6.52 Command Line Version

JLinkARM.dll V6.52 (DLL compiled Sep 27 2019 17:50:11)

Command line: -singlerun -if SWD -select USB -device MIMXRT1052DVL6B -port 2331
-----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:              off
Verify download:               off
Init regs on start:            off
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:                 MIMXRT1052DVL6B
Target interface:              SWD
Target interface speed:        4000kHz
Target endian:                 little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link V9 compiled Dec 13 2019 11:14:50
Hardware: V9.60
S/N: 59600174
Feature(s): RDI, GDB, FlashDL, FlashBP, JFlash
Checking target voltage...
Target voltage: 3.33 V
Listening on TCP/IP port 2331
Connecting to target...
Connected to target
Waiting for GDB connection...
Reading symbols from d:\workspace\marlin\mbed-test\.pio\build\mimxrt1050_evk\firmware.elf...
undefinedC:\Users\EthanGuo\.platformio\packages\toolchain-gccarmnoneeabi\bin\arm-none-eabi-gdb.exe: warning: Couldn't determine a path for the index cache directory.
PlatformIO Unified Debugger -> http://bit.ly/pio-debug
PlatformIO: debug_tool = jlink
PlatformIO: Initializing remote target...
0x60004606 in sleep_manager_unlock_deep_sleep_internal () at C:\users\ethanguo\.platformio\packages\framework-mbed\platform\source\mbed_power_mgmt.c:197
197	        MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_HAL, MBED_ERROR_CODE_UNDERFLOW), "DeepSleepLock underflow (< 0)", deep_sleep_lock);
Select auto target interface speed (2000 kHz)
Connected to 127.0.0.1
Reading all registers
Read 4 bytes @ address 0x60004606 (Data = 0xD3F74288)
Received monitor command: clrbp
Received monitor command: speed auto
Select auto target interface speed (2000 kHz)
Received monitor command: reset
Resetting target
Loading section .flash_config, size 0x200 lma 0x60000000

......(omiting)

Loading section .ram_function, size 0x280 lma 0x60049694
Start address 0x6000259c, load size 294772
Resetting target
Received monitor command: halt
Halting target CPU...
...Target halted (PC = 0x00201414)
Downloading 512 bytes @ address 0x60000000

......(omiting)

Downloading 640 bytes @ address 0x60049694
ERROR: Timeout while preparing target, core does not stop. (PC = 0x2000017E, XPSR = 0x41000000, SP = 0x20000B18)!
----------------------------------------------- Registers -------------------------------------------------------------------------------------
    	PC   = 00000000
Current:	R0   = 00000000,	R1   = 00000000,	R2   = 00000000,	R3   = 00000000
    	R4   = 00000000,	R5   = 00000000,	R6   = 00000000,	R7   = 00000000
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Failed to initialize RAMCode
Can not read register 15 (R15) while CPU is runningCan not read register 7 (R7) while CPU is runningCan not read register 6 (R6) while CPU is runningCan not read register 5 (R5) while CPU is runningCan not read register 4 (R4) while CPU is runningCan not read register 3 (R3) while CPU is runningCan not read register 2 (R2) while CPU is runningCan not read register 1 (R1) while CPU is runningCan no
Writing register (PC = 0x6000259c)
WARNING: Target connection lost.
WARNING: Failed to read memory @ address 0x6000259C
WARNING: Failed to read memory @ address 0x6000AB20
Transfer rate: 23988 KB/sec, 11337 bytes/write.
Temporary breakpoint 1 at 0x6000ab20: file src\main.cpp, line 20.
PlatformIO: Initialization completed
PlatformIO: Resume the execution to `debug_init_break = tbreak main`
PlatformIO: More configuration options -> http://bit.ly/pio-debug
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x6000ab20

Command aborted.
Setting breakpoint @ address 0x6000AB20, Size = 2, BPHandle = 0x0000
WARNING: No more breakpoint resources left
ERROR: Failed to set breakpoint at 0x6000AB20
pio_reset_run_target

In Keil, it seems to use evkbimxrt1050_flexspi_nor.ini as initialization file for debuging:
image
Does it also need here? And if so, how would I add it?

@valeros
Copy link
Member

valeros commented Sep 18, 2020

There might be a plenty of reasons. What project are you trying to debug? Does it work if you only upload it to your board? I see that JLink still uses MIMXRT1052DVL6B as the device. Is there any chance that active hardware watchdog is resetting the target before finishing programming?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants