JLink, GDB & STM32

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • JLink, GDB & STM32

    Hello,



    I am trying to debug an IAR Cortex STM32 eval board unsuccessfully using GDB and Eclipse. I can connect to the GDB server from Eclipse but I don't seem to be able to flash the device. I have a 30day license and so it should all be possible. My current thoughts are that my initialisation commands are wrong. Currently they are based off the initialisation commands for an ARM 7 device from (yagarto.de/howto/jlink/index.html).

    # Listening for commands on this PC's tcp port 2331
    target remote 127.0.0.1:2331


    # Enable flash download and flash breakpoints.
    # Select flash device
    monitor flash device = STM32F103RBT6


    # Enable FlashDL and FlashBPs
    monitor flash download = 1
    monitor flash breakpoints = 1


    # Set gdb server to little endian
    monitor endian little


    # Set JTAG speed in khz
    monitor speed 12000


    load
    break main
    continue


    So does anyone know what the correct intialisation and download commands for the STM32 device are???



    Any suggestions would be gratefully received...... ;)



    Thanks

    Richard
  • Hello Richard,

    the device ID for the STM32F103RBT6 is STM32F103RB,
    so the flash device command should look like as follows:
    monitor flash device = STM32F103RB

    Moreover, in the latest J-Link GDB Server manual you will find a section called
    "Debugging on Cortex-M3 devices" (3.4) in which sample init sequences for
    debugging on Cortex-M3 devices are given.

    Best regards,
    Alex
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi Richard,

    just a side note:
    J-Flash is one option to program the target, but the download into flash should also work.

    With the init file you describe, you should be able to download into flash.
    If it does not work, you should look at the Log-tap of the J-Link status window.

    Does flashing the device from GDB/Eclipse work ?

    Best regards,
    Rolf
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi Rolf

    Mixed success so far. Having built the target I then attempt to download and flash using the following commands:

    #*************************************************
    # #Connect to J-Link and debug application in flash on Cortex-M3
    # #Download to flash is performed.
    # #Connect to the J-Link gdb server
    target remote 127.0.0.1:2331
    monitor speed 1000
    monitor flash device = STM32F103RB
    monitor flash breakpoints = 1
    monitor flash download = 1
    load Debug/dev_board_test.out
    # Initializing PC and stack pointer
    monitor reg r13 = (0x00000000)
    monitor reg pc = (0x00000004)



    Having finally got all the licenses I need (FlashDL and FlashBP) it appears to load everything correctly - and I get the following in my console window in eclipse:

    target remote 127.0.0.1:2331

    0x00000000 in ?? ()

    monitor speed 1000

    JTAG speed set to 1000 kHz


    monitor flash device = STM32F103RB

    Select flash device: STM32F103RB


    monitor flash breakpoints = 1

    Flash breakpoints enabled


    monitor flash download = 1

    Flash download enabled


    load Debug/dev_board_test.out

    Loading section A1, size 0xec lma 0x8000000

    Loading section P2, size 0x2b82 lma 0x80000ec

    Start address 0x8002bc1, load size 11374

    Transfer rate: 90992 bits in <1 sec, 2843 bytes/write.

    monitor reg r13 = (0x00000000)

    Writing register (R13 = 0x00080020)


    monitor reg pc = (0x00000004)

    Writing register (R15 = 0xC12B000 :)


    However if I then try to run the code in Eclipse, the debug thread suspends and disassembly states No source available for "__iar_program_start()"

    The output of the JLink log window is as follows:

    SEGGER J-Link GDB Server V3.92

    JLinkARM.dll V3.92 (DLL compiled Sep 30 2008 11:59:07)

    Listening on TCP/IP port 2331

    J-Link connected
    Firmware: J-Link ARM V6 compiled Jul 30 2008 11:24:59
    Hardware: V6.00
    S/N: 16000136
    OEM: IARKS

    J-Link found 2 JTAG devices, Total IRLen = 9
    JTAG ID: 0x3BA00477 (Cortex-M3)
    WARNING: T-bit of XPSR is 0 but should be 1. Changed to 1.

    Connected to 127.0.0.1
    Reading all registers
    Read 4 bytes @ address 0x00000000 (Data = 0x00080020)
    JTAG speed set to 1000 kHz
    Select flash device: STM32F103RB
    Flash breakpoints enabled
    Flash download enabled
    Downloading 236 bytes @ address 0x08000000
    Downloading 4068 bytes @ address 0x080000EC
    Downloading 4096 bytes @ address 0x080010D0
    Downloading 2974 bytes @ address 0x080020D0
    Writing register (PC = 0xC12B0008)
    Writing register (CPSR = 0x200000D3)
    Writing register (R13 = 0x00080020)
    Writing register (R15 = 0xC12B0008)
    Read 4 bytes @ address 0x00000000 (Data = 0x00080020)
    Starting target CPU...
    WARNING: T-bit of XPSR is 0 but should be 1. Changed to 1.
    ...Target halted (PC = 0xC12B0008)
    Reading all registers
    Read 4 bytes @ address 0x08002BC0 (Data = 0x00F050F8)
    Read 2 bytes @ address 0x08002BC0 (Data = 0x00F0)
    Read 2 bytes @ address 0x08002BC2 (Data = 0x50F8)
    Read 2 bytes @ address 0x08002BC4 (Data = 0x0028)
    Read 2 bytes @ address 0x08002BC6 (Data = 0x01D0)
    Read 2 bytes @ address 0x08002BC8 (Data = 0xFFF7)
    Read 2 bytes @ address 0x08002BCA (Data = 0xDEFF)
    Read 2 bytes @ address 0x08002BCC (Data = 0x0020)
    Read 2 bytes @ address 0x08002BCE (Data = 0xFEF7)
    Read 2 bytes @ address 0x08002BD0 (Data = 0xCBFC)
    Read 2 bytes @ address 0x08002BD2 (Data = 0x00F0)
    Read 2 bytes @ address 0x08002BD4 (Data = 0x49F8)
    Read 2 bytes @ address 0x08002BD6 (Data = 0x0000)
    Read 2 bytes @ address 0x08002BD8 (Data = 0x0278)
    Read 2 bytes @ address 0x08002BDA (Data = 0xC9B2)
    Read 2 bytes @ address 0x08002BDC (Data = 0x012A)
    Read 2 bytes @ address 0x08002BDE (Data = 0x91EA)
    Read 2 bytes @ address 0x08002BE0 (Data = 0x020F)
    Read 2 bytes @ address 0x08002BE2 (Data = 0x84BF)
    Read 2 bytes @ address 0x08002BE4 (Data = 0x10F8)
    Read 2 bytes @ address 0x08002BE6 (Data = 0x012F)
    Read 2 bytes @ address 0x08002BE8 (Data = 0xF8E7)
    Read 2 bytes @ address 0x08002BEA (Data = 0x18BF)
    Read 2 bytes @ address 0x08002BEC (Data = 0x0020)
    Read 2 bytes @ address 0x08002BEE (Data = 0x7047)
    Read 2 bytes @ address 0x08002BF0 (Data = 0x38B5)
    Read 2 bytes @ address 0x08002BF2 (Data = 0x0500)
    Read 2 bytes @ address 0x08002BF4 (Data = 0x0C00)
    Read 2 bytes @ address 0x08002BF6 (Data = 0x2000)
    Read 2 bytes @ address 0x08002BF8 (Data = 0xFFF7)
    Read 2 bytes @ address 0x08002BFA (Data = 0x38FF)
    Read 2 bytes @ address 0x08002BFC (Data = 0xA042)
    Read 2 bytes @ address 0x08002BFE (Data = 0x18BF)
    Read 2 bytes @ address 0x08002C00 (Data = 0x0025)
    Read 2 bytes @ address 0x08002C02 (Data = 0x2800)
    Read 2 bytes @ address 0x08002C04 (Data = 0x32BD)
    Read 4 bytes @ address 0x08002C06 (Data = 0x000018B4)
    Read 2 bytes @ address 0x08002C0A (Data = 0x91FB)
    Read 2 bytes @ address 0x08002C0C (Data = 0xF2F3)
    Read 2 bytes @ address 0x08002C0E (Data = 0x1C00)
    Read 2 bytes @ address 0x08002C10 (Data = 0x02FB)
    Read 2 bytes @ address 0x08002C12 (Data = 0x1311)
    Read 2 bytes @ address 0x08002C14 (Data = 0xC0E9)
    Read 2 bytes @ address 0x08002C16 (Data = 0x0041)
    Read 2 bytes @ address 0x08002C18 (Data = 0x12BC)
    Read 2 bytes @ address 0x08002C1A (Data = 0x7047)
    Read 2 bytes @ address 0x08002C1C (Data = 0x80B5)
    Read 2 bytes @ address 0x08002C1E (Data = 0xFFF7)
    Read 2 bytes @ address 0x08002C20 (Data = 0x7BFE)
    Read 2 bytes @ address 0x08002C22 (Data = 0x0249)
    Starting target CPU...
    ...Target halted (PC = 0xC12B0008)
    Reading all registers
    Read 4 bytes @ address 0x08002BC0 (Data = 0x00F050F8)
    Starting target CPU...
    ...Target halted (PC = 0xC12B0008)
    Reading all registers
    Read 4 bytes @ address 0x08002BC0 (Data = 0x00F050F8)
    Starting target CPU...
    ...Target halted (PC = 0xC12B0008)
    Reading all registers
    Read 4 bytes @ address 0x08002BC0 (Data = 0x00F050F8)
    Starting target CPU...
    ...Target halted (PC = 0xC12B0008)
    Reading all registers
    Read 4 bytes @ address 0x08002BC0 (Data = 0x00F050F8)


    SO in conclusion it almost works but doesn't quite - any ideas would be gratefully received!!!


    Thanks


    Richard
    PS - apologies for the long post but I thought it would be useful to have all the information!
  • A quick update:

    I can flash the device with the Jlink and GDB server. Then when I disconnect the Jlink and hit reset on the dev board, the program starts to run. Therefore I can now successfully flash the device from Eclipse.

    However I am still having problems debugging from Eclipse.



    My quest continues.....



    Richard
  • Hello,

    I have the same problem with Eclipse an GDB. I use the GDB debugger from Codesourcery V6.7.50 / J-Link GDB Server V3.92.

    My Script:
    set complaints 1
    set output-radix 16
    set input-radix 16
    set prompt (arm-gdb)
    target remote localhost:2331
    monitor speed Auto
    monitor flash device = STM32F103CB
    monitor flash breakpoints = 1
    monitor flash download = 1
    load main.elf
    monitor reset 1

    After start the debug session, the flash have the new programm. On start the debugging, always jump the microcontroller into
    void HardFaultException(void)

    The other additional commands /combinations have no better result:
    monitor reset 0
    monitor reg sp = (0x00000000)
    monitor reg r13 = (0x00000000)
    monitor reg pc = (0x00000004)
    break main
    continue

    Result from Speed Auto is 200KHz, this make the GDB-Server self, and it use little endian.

    PS: With Olimex ARM-USB-OCD work all right.

    Til, can you help me, please? (I have write the same into mikrocontroller.net forum)

    Regards, Markus.
  • Hi Markus,



    I've had to give up on this as my temporary license for GDB server has expired. For the moment I don't think that debug in eclipse is possible. Even if I did get some debug going I would never get the opportunity to write plugins that would exploit the full debug potential - live variable update, trace functionality, function profiling etc

    Therefore for the moment I think that it is develop in Eclipse and then debug in another environment.....

    Ultimately what I would like is something like code red technologies red-suite - www.code-red-tech.com/products.html but unfortunately they don't support the STM32.


    Richard