debugging (by hand) MIMXRT1170-EVK using JLink

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

debugging (by hand) MIMXRT1170-EVK using JLink

426 Views
mastupristi
Senior Contributor I

Hello,

I have the MIMXRT1170-EVK on which I want to develop using JLink (I have a JLink Ultra+ V4.4 and JLink software version 7.84f)

I have my own executable with which I can't get into debug. Note that such an executable works fine on its own.

For comparison I took the SDK freertos_hello_cm7 example and everything always works with it.

After much investigation I was able to relate the problem back to the fact that after a reset the PC is changed incorrectly.

I launch

JLinkGDBServer -singlerun -if swd -port 50000 -swoport 50001 -telnetport 50002 -device MIMXRT1176xxxA_M7 -gui

in both case

While in a different terminal I launch the gdb:

/opt/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb  --interpreter=mi2

On this terminal I write some commands:

-gdb-set mi-async on
-interpreter-exec console "set print demangle on"
-interpreter-exec console "set print asm-demangle on"
-enable-pretty-printing
-file-exec-and-symbols "/home/max/Lavori/ama/wkps_startup_on_rt117x/evkmimxrt1170_freertos_hello_cm7__newlib/Debug/evkmimxrt1170_freertos_hello_cm7__newlib.axf"
-target-select extended-remote localhost:50000
-interpreter-exec console "directory /home/max/Lavori/ama/wkps_startup_on_rt117x/evkmimxrt1170_freertos_hello_cm7__newlib"
-interpreter-exec console "monitor halt"
-interpreter-exec console "monitor reset"
-target-download

 

We are now ready to demonstrate that with this executable the reset works:

-interpreter-exec console "monitor reg pc"
"@"Reading register (PC = 0x300024E8)\r\n"
^done
(gdb) 
-interpreter-exec console "monitor reset"
@"Resetting target\r\n"
-interpreter-exec console "monitor reg pc"
^done
(gdb) 
@"Reading register (PC = 0x300024E8)\r\n"
^done
(gdb) 
-interpreter-exec console "monitor reg pc 0x12345"
@"Writing register (PC = 0x00012345)\r\n"
^done
(gdb) 
-interpreter-exec console "monitor reg pc"
@"Reading register (PC = 0x00012344)\r\n"
^done
(gdb) 
-interpreter-exec console "monitor reset"
@"Resetting target\r\n"
^done
(gdb) 
-interpreter-exec console "monitor reg pc"
@"Reading register (PC = 0x300024E8)\r\n"
^done
(gdb) 
-interpreter-exec console "monitor reg pc 0x12345"
@"Writing register (PC = 0x00012345)\r\n"
^done
(gdb) 
-interpreter-exec console "monitor reset 2"
@"Resets core & peripherals using RESET pin.\r\n"
^done
(gdb) 
-interpreter-exec console "monitor reg pc
@"Reading register (PC = 0x300024E8)\r\n"
^done
(gdb) 

 

As you can see after the resets the PC is always 0x300024E8 which is the entry point of the executable"

max@Cialdi-OptiPlex-7070:~/Lavori/ama/wkps_startup_on_rt117x/evkmimxrt1170_freertos_hello_cm7__newlib$ /opt/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-readelf -h Debug/evkmimxrt1170_freertos_hello_cm7__newlib.axf 
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x300024e9
  Start of program headers:          52 (bytes into file)
  Start of section headers:          3693108 (bytes into file)
  Flags:                             0x5000400, Version5 EABI, hard-float ABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         4
  Size of section headers:           40 (bytes)
  Number of section headers:         38
  Section header string table index: 37

 

 

If I try to do similar things with my executable instead:

(gdb) 
-interpreter-exec console "monitor reg pc"
@"Reading register (PC = 0x30002278)\r\n"
^done
(gdb) 
-interpreter-exec console "monitor reset"
@"Resetting target\r\n"
^done
(gdb) 
-interpreter-exec console "monitor reg pc"
@"Reading register (PC = 0x00223104)\r\n"
^done
(gdb) 
-interpreter-exec console "monitor reg pc 0x12345"
@"Writing register (PC = 0x00012345)\r\n"
^done
(gdb) 
-interpreter-exec console "monitor reg pc"
@"Reading register (PC = 0x00012344)\r\n"
^done
(gdb) 
-interpreter-exec console "monitor reset"
@"Resetting target\r\n"
^done
(gdb) 
-interpreter-exec console "monitor reg pc"
@"Reading register (PC = 0x00223104)\r\n"
^done
(gdb) 

 

In this case, the PC after resets does not go into the entrypoint

max@Cialdi-OptiPlex-7070:~/Lavori/ama/srcs/repos/Ama-on-EVK$ (torm) /opt/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-readelf -h FW/image/AmaOnEVK.elf
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x30002279
  Start of program headers:          52 (bytes into file)
  Start of section headers:          3868256 (bytes into file)
  Flags:                             0x5000400, Version5 EABI, hard-float ABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         7
  Size of section headers:           40 (bytes)
  Number of section headers:         31
  Section header string table index: 30

 

What is different about the two executables? What is missing from mine? I am attaching them.

 

best regards

Max

Tags (2)
0 Kudos
Reply
0 Replies