Menu

#70 Jtag debug displays wrong disassembly.

Version 1.x
closed
None
5
2014-10-12
2014-09-08
No

Hello, since few days I'm trying to setup a debug environnement but the .elf downloaded to the target is wrong when using JTAG debugger. I'll explain myself below.

I have the following material and software:

-A Spark core with Stm32F103CB (http://docs.spark.io/hardware/).
-SEGGER j-link GDB edu.
-Linux debian, eclipse, SEGGER-gnu-arm-eclipse plugin.
-Gdb-arm-none-eabi.

The Spark core comes with a firmware (which I dont use) and the BSP/USB drivers for the target (which I use).

The program that I want to executed is a mass storage demo (http://www.keil.com/download/docs/362.asp)

To test the debug environnement I simplified the main to make one call, to USB_Init function. Also tried with other simple codes.

I've changed the stratup file by removing a call to SparkFirmware specific configuration.

When the code is finished downloading, it stop in main but does not contain any instruction.

On the disassembly it stop on a branch instruction (bcc.w lr) and there is nothing else in the disassembled main function.

Some interresting observations:

I used gdb-arm-none-eabi-objdump on the same .elf file and the result does not correspond to the one in eclispe and seams much closer to the reality, with a correct function memory location.

I've tried with a stm32f1xx demo project from the plugin and the result was the same: Two instructions a cmp r2, r3 followed by a bbc.w lr.

Do you have any idea where I'm wrong here ? I can give some code if someone would like to help me. The time to me to learn how to post code correctly :)

Thank you in advance.
Geoffrey.

Discussion

  • Liviu Ionescu (ilg)

    It looks like you misconfigured either the mcu for build or the device name for jlink.

    I suggest you create a new project with the Hello ARM Cortex-M template, using the Freestanding and Semihosting OUTPUT selections, and run it on your board. It should write messages on the semihosting console.

    If this works properly, check differences between this project and your project.

     
  • geoffrey franciulla

    Thank you for your response.

    I use STM32F103CB as Jlink target device and STM32F1xx_md as build device which seems correct for me after cheking datasheet and ST devices description.

    As you suggested I tried to create a project with the Hello cortex-M template and the Freestanding and Semihosting STDOUT but it does not work.

    The GDBserver console output this JLinkARM.dll V4.86a (DLL compiled Jun 11 2014 17:45:07)

    -----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: yes
    Generate logfile: off
    Verify download: off
    Init regs on start: on
    Silent mode: off
    Single run mode: off
    Target connection timeout: 5 sec.
    ------J-Link related settings------
    J-Link Host interface: USB
    J-Link script: none
    J-Link settings file: none
    ------Target related settings------
    Target device: STM32F103CB
    Target interface: JTAG
    Target interface speed: 1000kHz
    Target endian: little

    Connecting to J-Link...
    J-Link is connected.
    Firmware: J-Link V9 compiled May 23 2014 19:21:14
    Hardware: V9.00
    S/N: 269200467
    OEM: SEGGER-EDU
    Feature(s): FlashBP, GDB
    Checking target voltage...
    Target voltage: 3.32 V
    Listening on TCP/IP port 2331
    Connecting to target...
    J-Link found 2 JTAG devices, Total IRLen = 9
    JTAG ID: 0x3BA00477 (Cortex-M3)
    Connected to target
    Waiting for GDB connection...Connected to 127.0.0.1
    Reading all registers
    Read 4 bytes @ address 0x00000000 (Data = 0x20005000)
    Target interface speed set to 1000 kHz
    Resetting target
    Halting target CPU...
    ...Target halted (PC = 0x0800010C)
    R0 = 00012C80, R1 = 20001A2C, R2 = 0000AAAA, R3 = 00000061
    R4 = 20004F70, R5 = 00000000, R6 = 00000000, R7 = 20004FA4
    R8 = 00000000, R9 = 00000000, R10= 48FF5C64, R11= 866CE7C5
    R12= 20004F38, R13= 20005000, MSP= 20005000, PSP= 04521C1C
    R14(LR) = FFFFFFFF, R15(PC) = 0800010C
    XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
    CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
    Reading all registers
    Select auto target interface speed (4000 kHz)
    Flash breakpoints enabled
    Semi-hosting enabled (VectorAddr = 0x08)
    Semihosting I/O set to TELNET and GDB Client
    Downloading 384 bytes @ address 0x08000000
    Downloading 2757 bytes @ address 0x08000180
    Downloading 120 bytes @ address 0x08000C48
    WARNING: CPU is running at low speed (8002 kHz).
    ERROR: Failed to erase sectors 0 @ address 0x08000000 (erase error)
    Writing register (PC = 0x08000044)
    Read 4 bytes @ address 0x08000044 (Data = 0x08000159)
    Read 2 bytes @ address 0x080002FA (Data = 0x4B74)
    Read 2 bytes @ address 0x080002FC (Data = 0xD002)
    Read 2 bytes @ address 0x080002F8 (Data = 0x4290)
    Read 2 bytes @ address 0x080002FA (Data = 0x4B74)
    Read 2 bytes @ address 0x080002FC (Data = 0xD002)
    Read 2 bytes @ address 0x080002FA (Data = 0x4B74)
    Read 2 bytes @ address 0x080002FC (Data = 0xD002)
    Read 2 bytes @ address 0x080002F8 (Data = 0x4290)
    Resetting target
    Halting target CPU...
    ...Target halted (PC = 0x0800010C)
    R0 = 200006B4, R1 = 0000AAAA, R2 = 2000070C, R3 = 00000002
    R4 = 200006B4, R5 = 200006D4, R6 = 200006D4, R7 = 20004FA4
    R8 = 00000000, R9 = 00000000, R10= 48FF5C64, R11= 866CE7C5
    R12= 20000628, R13= 20005000, MSP= 20005000, PSP= 04521C1C
    R14(LR) = FFFFFFFF, R15(PC) = 0800010C
    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 0x0800010C (Data = 0xF0002100)
    Reading 64 bytes @ address 0x20005000
    WARNING: Failed to read memory @ address 0x20005000
    Setting breakpoint @ address 0x080002F8, Size = 2, BPHandle = 0x0002
    Starting target CPU...

    Everthing seems good about the Jlink connection, so my guess would be to look into memory mapping, linkerscript ?...
    There is a preloaded firmware on the target that constently reboot with backup software. I'm looking in that direction for now. If you have any advice or want me to try something I'll be happy to do it.

    Thanks again for your time.
    Geoffrey.

     
  • Liviu Ionescu (ilg)

    ERROR: Failed to erase sectors 0 @ address 0x08000000 (erase error)

    it looks like your preloaded firmware is very stubborn and does not allow you to reprogram the flash.

    there should be a jumper or some method to disable this behaviour.

    or try to completely erase the flash with the SEGGER tools, outside Eclipse.

     
  • geoffrey franciulla

    You were right, I unlocked the internal flash and now the Cortex-M hello world template is working and I can debug in it.

    Thank you.

     
  • Liviu Ionescu (ilg)

    • status: open --> closed
    • assigned_to: Liviu Ionescu (ilg)
     
MongoDB Logo MongoDB