[SOLVED] j-link do not erase or program device STM32F103 in long JTAG chain

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

  • [SOLVED] j-link do not erase or program device STM32F103 in long JTAG chain

    Greetings!

    I have a device with long JTAG chain (one STM32f103, then two different PLD`s, then other STM32F103).
    I need to program a last one STM32. I used a ULINK2 for this and are trying to move forward to J-Link (Base version).
    You can have a look at the chain in attachments.

    I`m trying to program the controller with KEIL mVision 5.24 + J-Link HW 10.10 and dll 6.30b.

    mVision prints Build Output like this:
    ------------
    DLL: V6.30b, compiled Feb 2 2018 18:36:54
    Firmware: J-Link V10 compiled Feb 2 2018 18:12:40
    Hardware: V10.10
    S/N : 50110147
    Feature(s) : GDB

    * JLink Info: TotalIRLen = 34, IRPrint = 0x00233B3A11
    * JLink Info: JTAG chain detection found 6 devices:
    * JLink Info: #0 Id: 0x3BA00477, IRLen: 04, CoreSight JTAG-DP
    * JLink Info: #1 Id: 0x16410041, IRLen: 05, STM32 Boundary Scan
    * JLink Info: #2 Id: 0x1E9041CF, IRLen: ?, Unknown device
    * JLink Info: #3 Id: 0x1BA541CF, IRLen: ?, Unknown device
    * JLink Info: #4 Id: 0x3BA00477, IRLen: 04, CoreSight JTAG-DP
    * JLink Info: #5 Id: 0x06414041, IRLen: 05, STM32 Boundary Scan
    * JLink Info: Active read protected STM32 device detected.
    This could cause problems during flash download.
    Note: Unsecuring will trigger a mass erase of the internal flash.
    * JLink Info: Executing default behavior previously saved in the registry.
    * JLink Info: Device will be unsecured now.
    * JLink Info: TotalIRLen = 34, IRPrint = 0x00233B3A11
    * JLink Info: JTAG chain detection found 6 devices:
    * JLink Info: #0 Id: 0x3BA00477, IRLen: 04, CoreSight JTAG-DP
    * JLink Info: #1 Id: 0x16410041, IRLen: 05, STM32 Boundary Scan
    * JLink Info: #2 Id: 0x1E9041CF, IRLen: ?, Unknown device
    * JLink Info: #3 Id: 0x1BA541CF, IRLen: ?, Unknown device
    * JLink Info: #4 Id: 0x3BA00477, IRLen: 04, CoreSight JTAG-DP
    * JLink Info: #5 Id: 0x06414041, IRLen: 05, STM32 Boundary Scan
    * 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: 0x14770011)
    * 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: 0x411FC231. Implementer code: 0x41 (ARM)
    * JLink Info: Found Cortex-M3 r1p1, Little endian.
    * JLink Info: FPUnit: 6 code (BP) slots and 2 literal slots
    * JLink Info: CoreSight components:
    * JLink Info: ROMTbl[0] @ E00FF000
    * JLink Info: ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 001BB000 SCS
    * JLink Info: ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 001BB002 DWT
    * JLink Info: ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 000BB003 FPB
    * JLink Info: ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 001BB001 ITM
    * JLink Info: ROMTbl[0][4]: E0040000, CID: B105900D, PID: 001BB923 TPIU-Lite
    ROMTableAddr = 0xE00FF000
    * JLink Info: Reset: Halt core after reset via DEMCR.VC_CORERESET.
    * JLink Info: Reset: Reset device via AIRCR.SYSRESETREQ.
    * JLink Info: Reset: S_RESET_ST never gets cleared. CPU seems to be kept in reset forever.
    * JLink Info: Reset: Using fallback: Reset pin.
    * JLink Info: Reset: Halt core after reset via DEMCR.VC_CORERESET.
    * JLink Info: Reset: Reset device via reset pin
    * JLink Info: Reset: VC_CORERESET did not halt CPU. (Debug logic also reset by reset pin?).
    * JLink Info: Reset: Reconnecting and manually halting CPU.
    * JLink Info: AP map detection skipped. Manually configured AP map found.
    * JLink Info: AP[0]: AHB-AP (IDR: Not set)
    * JLink Info: AP[0]: Core found
    * JLink Info: AP[0]: AHB-AP ROM base: 0xE00FF000
    * JLink Info: CPUID register: 0x411FC231. Implementer code: 0x41 (ARM)
    * JLink Info: Found Cortex-M3 r1p1, Little endian.
    **JLink Warning: CPU could not be halted
    * JLink Info: Reset: Core did not halt after reset, trying to disable WDT.
    * JLink Info: Reset: Halt core after reset via DEMCR.VC_CORERESET.
    * JLink Info: Reset: Reset device via reset pin
    * JLink Info: Reset: VC_CORERESET did not halt CPU. (Debug logic also reset by reset pin?).
    * JLink Info: Reset: Reconnecting and manually halting CPU.
    * JLink Info: AP map detection skipped. Manually configured AP map found.
    * JLink Info: AP[0]: AHB-AP (IDR: Not set)
    * JLink Info: AP[0]: Core found
    * JLink Info: AP[0]: AHB-AP ROM base: 0xE00FF000
    * JLink Info: CPUID register: 0x411FC231. Implementer code: 0x41 (ARM)
    * JLink Info: Found Cortex-M3 r1p1, Little endian.
    **JLink Warning: CPU could not be halted

    Target info:
    ------------
    Device: STM32F103VE
    VTarget = 3.349V
    State of Pins:
    TCK: 1, TDI: 0, TDO: 1, TMS: 0, TRES: 1, TRST: 1
    Hardware-Breakpoints: 6
    Software-Breakpoints: 8192
    Watchpoints: 4
    JTAG speed: 1000 kHz

    Erase Done.
    Programming Failed!
    Error: Flash Download failed - "Cortex-M3"

    But actually it didn`t erase flash. Algorithm inside still working properly.

    A few more information about JTAG chain - yes, i have pull-ups and pull-downs connected. This device previously worked fine with ULINK2. Yes, RESET pin is connected to RESET chain of the device.

    Do you have any advice for me? Could it be connected with "JLink Warning: CPU could not be halted"?


    Best regards,
    Vsevolod
    Images
    • JTAG connect log.jpg

      209.09 kB, 674×764, viewed 1,286 times
  • Hello Vsevolod,

    Thank you for your inquiry.
    Such an issue is not known to us.
    The J-Link Commander screen shot you provided shows only the connection to the first STM32 device.
    Could you make a screen shot of the connection to the second STM32 device?
    For this you need to specify the Device position in the JTAG chain.
    In this case IRPre would be 25 and DRPre would be 4.

    When using uVision to flash the second STM32 device could you provide a J-Link log file of that session?
    wiki.segger.com/Enable_J-Link_log_file

    Best regards,
    Nino
    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.
  • Hello Nino,

    thanks for answering.
    Here in the attachments are screen shot for connecting to second STM32 device and a log file you`ve asked.
    Images
    • JTAG connect log2.jpg

      219.4 kB, 677×823, viewed 940 times
    Files
    • JLinkLog.txt

      (19.66 kB, downloaded 378 times, last: )
  • Hello,

    Thank you for providing the information.
    A general connect to the device works with J-Link Commander.
    If you are looking into only programming your devices you can keep using J-Link Commander and use command loadfile and your build output from uVision.
    More information can be found in the J-Link user manual.

    uVision itself does not know exactly which device you want to connect to and randomly selects one of the available JTAG devices which leads to the reported error.
    To counter this you need to tell J-Link exactly which JTAG device you want to connect to.
    First you need to specify a JlinkScript: wiki.segger.com/Manual_setup_of_JTAG_chain
    To use the script with uVision follow the following guide: wiki.segger.com/Keil_MDK#Using_J-Link_Script_Files

    After that you should be able to flash the other STM32 device as well.

    Best regards,
    Nino
    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.
  • Ok, i`ve done all you wrote.
    Let`s have a little check, my JLinkSettings script is in attachments.
    But there is still a mistake (actually another one). I attached a log file with my programming.

    UPDATE

    Sorry, seems to be a mistake in previous JLinkSettings. The actual one is here:

    JLINK_SYS_Report("J-Link script file: Manually configuring JTAG chain");
    JLINK_JTAG_SetDeviceId(0, 0x3BA00477); // IRLen: 4
    JLINK_JTAG_SetDeviceId(1, 0x16410041); // IRLen: 5
    JLINK_JTAG_SetDeviceId(2, 0x1E9041CF); // IRLen: 8
    JLINK_JTAG_SetDeviceId(3, 0x1BA541CF); // IRLen: 8
    JLINK_JTAG_SetDeviceId(4, 0x3BA00477); // IRLen: 4 => CoreSight DAP (This is the one we want to communicate with)
    JLINK_JTAG_SetDeviceId(5, 0x06414041); // IRLen: 5
    //
    // Pre-select CoreSight DAP to be the one J-Link shall communicate with, for this session
    //
    JLINK_JTAG_IRPre = 25; // Sum of IRLen of all JTAG TAPs preceding the one we want to communicate with
    JLINK_JTAG_DRPre = 1; // Number of JTAG TAPs preceding the one we want to communicate with
    JLINK_JTAG_IRPost = 5; // Sum of IRLen of all JTAG TAPs following the one we want to communicate with
    JLINK_JTAG_DRPost = 5; // Number of JTAG TAPs following the one we want to communicate with
    JLINK_JTAG_IRLen = 4; // IRLen of device we want to communicate with

    But it changed nothing, i have a error in uVision:
    ***JLink Error: STM32: Connecting to CPU via connect under reset failed.via connect under reset failed
    Files

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

  • Hello,

    Your initial JLinkScript had JLINK_CPU = CORTEX_A5;. That is incorrect, make sure to remove that line.

    If you want to connect to the second STM32 then the attached script should be correct except the Cortex-A5 part:

    JLINK_JTAG_IRPre = 25; // Sum of IRLen of all JTAG TAPs preceding the one we want to communicate with
    JLINK_JTAG_DRPre = 4; // Number of JTAG TAPs preceding the one we want to communicate with
    JLINK_JTAG_IRPost = 5; // Sum of IRLen of all JTAG TAPs following the one we want to communicate with
    JLINK_JTAG_DRPost = 1; // Number of JTAG TAPs following the one we want to communicate with
    JLINK_JTAG_IRLen = 4; // IRLen of device we want to communicate with

    In your post update you seem to mix up information from the first STM32 and second one. That will not work.

    Please understand that we can't put more time into this as the J-Link communication is generally working with J-Link Commander and only uVision is trying to connect to the wrong device.
    For simple programming of devices J-Link Commander or J-Flash can be used as well.


    Best regards,
    Nino
    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 Vsevolod,

    Great to hear that you are up and running again.
    We will consider this case as closed now.

    Best regards,
    Nino
    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.