[ABANDONED] J-link EDU SWD debug fails in GD32F350

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

  • [ABANDONED] J-link EDU SWD debug fails in GD32F350

    My setup:
    GD32F350-based board that I have to use as a temporary devkit.
    J-link edu with firmware recently updated
    J-Link Commander v7.70e
    Keil-MDK 5.34
    debug lines used: 3.3V, SWDIO, SWCLK, Reset, GND

    I have a GD32-based board that i'm using as a temporary devkit. I am using Keil 5.34 for SW development and J-Link Edu to connect the board into the host for debugging. I already configured in the Debug tab of keil Target Options to use J-Link/J-trace as the debugger and even set SWD as the interface in the Settings. Whenever I try to start a debug session, it fails and keil says Error: flash download failed - "Cortex-M4". Why is this failing? It is my first time to debug a J-Link/SWD connection. In my previous project before, the SWD connections works right away with no need to debug it.

    Here are other observations of mine:
    The J-Link EDU can connect to the PC as attested by the J-Link Commander.

    The J-Link can connect to the MCU core. the following is the message from the J-Link commander:
    Connecting to target via SWD
    Found SW-DP with ID 0x2BA01477
    DPIDR: 0x2BA01477
    CoreSight SoC-400 or earlier
    AP map detection skipped. Manually configured AP map found.
    AP[0]: AHB-AP (IDR: Not set)
    AP[0]: Core found
    AP[0]: AHB-AP ROM base: 0xE00FF000
    CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
    Found Cortex-M4 r0p1, Little endian.
    FPUnit: 6 code (BP) slots and 2 literal slots
    CoreSight components:
    ROMTbl[0] @ E00FF000
    [0][0]: E000E000 CID B105E00D PID 000BB00C SCS-M7
    [0][1]: E0001000 CID B105E00D PID 003BB002 DWT
    [0][2]: E0002000 CID B105E00D PID 002BB003 FPB
    [0][3]: E0000000 CID B105E00D PID 003BB001 ITM
    [0][4]: E0040000 CID B105900D PID 000BB9A1 TPIU
    Cortex-M4 identified.

    It seems the MCU freezes whenever I connect to it via J-Link Commander, because a blinking LED under normal circumstance halts blinking after connecting. Although once connected and the MCU has "frozen", I can still scan the MCU Cortex registers via regs command. Here's the log:
    Load "XXXXXXXXXXX\GD32F350_sampler.axf"
    Set JLink Project File to "XXXXXXXXXXXXXX\JLinkSettings.ini"
    * JLink Info: Device "GD32F350CB" selected.
    JLink info:
    ------------
    DLL: V7.70e, compiled Aug 31 2022 17:06:50
    Firmware: J-Link V10 compiled Jul 22 2022 11:40:29
    Hardware: V10.10
    S/N : 260107884
    OEM : SEGGER-EDU
    Feature(s) : FlashBP, GDB
    * JLink Info: Found SW-DP with ID 0x2BA01477
    * JLink Info: DPIDR: 0x2BA01477
    * JLink Info: CoreSight SoC-400 or earlier
    * JLink Info: Scanning AP map to find all available APs
    * JLink Info: AP[1]: Stopped AP scan as end of AP map has been reached
    * JLink Info: AP[0]: AHB-AP (IDR: 0x24770011)
    * JLink Info: Iterating through AP map to find AHB-AP to use
    * JLink Info: AP[0]: Core found
    * JLink Info: AP[0]: AHB-AP ROM base: 0xE00FF000
    * JLink Info: CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
    * JLink Info: Found Cortex-M4 r0p1, Little endian.
    * JLink Info: FPUnit: 6 code (BP) slots and 2 literal slots
    * JLink Info: CoreSight components:
    * JLink Info: ROMTbl[0] @ E00FF000
    * JLink Info: [0][0]: E000E000 CID B105E00D PID 000BB00C SCS-M7
    * JLink Info: [0][1]: E0001000 CID B105E00D PID 003BB002 DWT
    * JLink Info: [0][2]: E0002000 CID B105E00D PID 002BB003 FPB
    * JLink Info: [0][3]: E0000000 CID B105E00D PID 003BB001 ITM
    * JLink Info: [0][4]: E0040000 CID B105900D PID 000BB9A1 TPIU
    ROMTableAddr = 0xE00FF000
    * JLink Info: Reset: Halt core after reset via DEMCR.VC_CORERESET.
    * JLink Info: Reset: Reset device via AIRCR.SYSRESETREQ.
    Target info:
    ------------
    Device: GD32F350CB
    VTarget = 3.335V
    State of Pins:
    TCK: 0, TDI: 0, TDO: 0, TMS: 1, TRES: 1, TRST: 0
    Hardware-Breakpoints: 6
    Software-Breakpoints: 8192
    Watchpoints: 4
    JTAG speed: 100 kHz
    Erase Failed!
    Error: Flash Download failed - "Cortex-M4"
    Flash Load finished at 21:01:32
    I can attach the log.

    The MCU also freezes when I start a debug session in Keil and fails. It also fails when I press the "Settings" button in the Debug tab of Keil Target Options under "J-LINK/J-TRACE". Pressing "Setting" seems to detect connected MCUs and populate fields in the dialog box, very similar to the effect of "connect" command in the J-Link commander that detects MCUs and displays its properties like SW-DP number.

    I can get the board to reset whenever I change the port to JTAG inKeil Target Options Debug tab Settings button OR in J-Link Commander via selectinterface jtag command. Of course this is incorrect since there are no JTAG lines connected, only SWD is used. But that's what happening.

    It seems the MCU hangs whenever it is scanned/detected and its serial numbers are read like that of SW-DP.
    Files
    • JLinkLog.txt

      (3.85 kB, downloaded 269 times, last: )

    The post was edited 1 time, last by ubermensch ().

  • If you follow this
    wiki.segger.com/J-Link_cannot_…ty_using_J-Link_Commander
    and use SWD as interface, does connecting to the core succeed?

    If yes, when you execute these lines:
    erase 0x08000000 0x0801FFFF
    loadfile XXXXXXXXXXX\GD32F350_sampler.axf
    Do they suceed?

    Note that the "erase ..." command is not necessary here as "loadfile" automatically takes care of erasing. It is more a test step to break down what goes wrong in your uVision session.
    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.