[SOLVED] Unable to flash / erase STM32F401CC

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

  • [SOLVED] Unable to flash / erase STM32F401CC

    Hi everyone,

    I am trying to work with JLink on an STM32F401CC. It is on an ST Eval Bord STEVAL-FCU001V1.

    It looks as if the STM32 cannot be flashed. You will find the JLinkExe Log below.

    Any hint you can give me is much appreciated!

    thanks & best regards
    Christopher Lang

    acurana GmbH, Grassingerstraße 8,
    83043 Bad Aibling, Germany

    Tel.: +49 8061 / 93 98 386
    Fax: +49 8061 / 93 98 385

    acurana.de/




    chris@linux-84pj:/opt/SEGGER/JLink_Linux_V630a_x86_64> ./JLinkExe
    SEGGER J-Link Commander V6.30a (Compiled Jan 31 2018 18:14:21)
    DLL version V6.30a, compiled Jan 31 2018 18:14:14

    Connecting to J-Link via USB...O.K.
    Firmware: J-Link V9 compiled Jan 29 2018 15:41:50
    Hardware version: V9.30
    S/N: 59302773
    License(s): GDB
    VTref = 3.087V


    Type "connect" to establish a target connection, '?' for help
    J-Link>device stm32f401cc
    J-Link>r
    Target connection not established yet but required for command.
    Please specify target interface:
    J) JTAG (Default)
    S) SWD
    TIF>s
    Specify target interface speed [kHz]. <Default>: 4000 kHz
    Speed>
    Device "STM32F401CC" selected.


    Connecting to target via SWD
    Found SW-DP with ID 0x2BA01477
    Found SW-DP with ID 0x2BA01477
    Scanning AP map to find all available APs
    AP[1]: Stopped AP scan as end of AP map has been reached
    AP[0]: AHB-AP (IDR: 0x24770011)
    Iterating through AP map to find AHB-AP to use
    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
    ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7
    ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
    ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
    ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
    ROMTbl[0][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU
    ROMTbl[0][5]: E0041000, CID: B105900D, PID: 000BB925 ETM
    Cortex-M4 identified.
    Reset delay: 0 ms
    Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.

    **************************
    WARNING: T-bit of XPSR is 0 but should be 1. Changed to 1.
    **************************

    J-Link>erase
    Erasing device (STM32F401CC)...
    Comparing flash [100%] Done.
    Erasing flash [100%] Done.
    Verifying flash [100%] Done.
    J-Link: Flash download: Total time needed: 0.029s (Prepare: 0.020s, Compare: 0.000s, Erase: 0.007s, Program: 0.000s, Verify: 0.000s, Restore: 0.000s)

    **************************
    WARNING: Core did not halt after single step
    **************************


    ****** Error: Failed to restore target. RAMCode never stops
    ERROR: Erase returned with error code -5.
    J-Link>erase
    Erasing device (STM32F401CC)...

    **************************
    WARNING: CPU could not be halted
    **************************

    Erasing flash [100%] Done.
    Verifying flash [100%] Done.
    J-Link: Flash download: Total time needed: 0.001s (Prepare: 0.000s, Compare: 0.000s, Erase: 0.000s, Program: 0.000s, Verify: 0.000s, Restore: 0.000s)

    **************************
    WARNING: Core did not halt after single step
    **************************


    ****** Error: Failed to restore target. RAMCode never stops
    ERROR: Erase returned with error code -5.
    J-Link>loadbin /home/chris/workspace-test-delete/test-401/Debug/test-401.bin , 0x08000000
    Downloading file [/home/chris/workspace-test-delete/test-401/Debug/test-401.bin]...

    **************************
    WARNING: CPU could not be halted
    **************************

    Comparing flash [100%] Done.
    Erasing flash [100%] Done.
    Verifying flash [100%] Done.
    J-Link: Flash download: Restarting flash programming due to program error (possibly skipped erasure of half-way erased sector).
    J-Link: Flash download: Skip optimizations disabled for second try.

    **************************
    WARNING: Core did not halt after single step
    **************************

    Error while programming flash: Programming failed.
    J-Link>mem32 08000000, 16
    Could not read memory.
    J-Link>mem32 0x08000000, 16
    Could not read memory.
    J-Link>r
    Reset delay: 0 ms
    Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.

    **************************
    WARNING: T-bit of XPSR is 0 but should be 1. Changed to 1.
    **************************

    J-Link>h
    PC = 00000000, CycleCnt = 00000000
    R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
    R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
    R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
    R12= 00000000
    SP(R13)= 00000000, MSP= 00000000, PSP= 00000000, R14(LR) = FFFFFFFF
    XPSR = 01000000: APSR = nzcvq, EPSR = 01000000, IPSR = 000 (NoException)
    CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00

    FPS0 = 00000000, FPS1 = 00000000, FPS2 = 00000000, FPS3 = 00000000
    FPS4 = 00000000, FPS5 = 00000000, FPS6 = 00000000, FPS7 = 00000000
    FPS8 = 00000000, FPS9 = 00000000, FPS10= 00000000, FPS11= 00000000
    FPS12= 00000000, FPS13= 00000000, FPS14= 00000000, FPS15= 00000000
    FPS16= 00000000, FPS17= 00000000, FPS18= 00000000, FPS19= 00000000
    FPS20= 00000000, FPS21= 00000000, FPS22= 00000000, FPS23= 00000000
    FPS24= 00000000, FPS25= 00000000, FPS26= 00000000, FPS27= 00000000
    FPS28= 00000000, FPS29= 00000000, FPS30= 00000000, FPS31= 00000000
    FPSCR= 00000000
    J-Link>erase
    Erasing device (STM32F401CC)...
    Erasing flash [000%]
    ****** Error: Timeout while erasing sectors, RAMCode did not respond in time. (PC = 0x00000000, CPSR = 0x00000000, LR = 0x01000000)!
    100%] Done.
    Verifying flash [100%] Done.
    J-Link: Flash download: Total time needed: 10.007s (Prepare: 0.000s, Compare: 0.000s, Erase: 10.001s, Program: 0.000s, Verify: 0.000s, Restore: 0.006s)
    ERROR: Erase returned with error code -5.
    J-Link>
  • Hello Christopher,

    Thank you for your inquiry.
    Such an issue is not known to us.
    On the eval boards we have available here (STM32F401C-DISCO and NUCLEO-F401RE) the issue was not reproducible.
    Did you make sure to connect the reset pin to your J-Link probe?

    Could you provide a log file from the failed 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.
  • Hi Nino,

    I tried a few more things on this issue:

    1st I checked the NRST Pin of the processor with a scope, and yes, the RESET pin goes low and high again when a debug session is started, rise time is approx. 10ms, that looks ok to me.

    Then I connected the board with an St-Link/V2 using openocd in Eclipse. Well, that works! The Debug session runs to main() and stops there, stepping through the code is possible.

    Now the strange thing: When I then just switch to JLink and start a JLink Debug session under Eclipse, the 1st debug session after changing from St-Link to JLink works as well. Any further JLink sessions fail.

    Please find some files attached:

    jlink-log-stm32f401cc.txt
    JLink session failure

    jlink-log-stm32f401cc-1st-sess-after-openocd.txt
    working JLink session right after openocd session

    Two pictures of the ST Eval Bord and the JLink and St-Link connections.

    I hope the logs will help you to diagnose the issue.

    many thanks
    Chris
    Images
    • jlink-20180205_163009_001-small.jpg

      387.99 kB, 1,280×960, viewed 807 times
    • openocd-20180205_170704-small.jpg

      642.22 kB, 1,280×960, viewed 765 times
    Files
  • Hello Chris,

    For reference, could you follow the instructions on our wiki for connecting to target devices step by step and provide a screenshot of the full Commander output?
    wiki.segger.com/J-Link_cannot_…ty_using_J-Link_Commander

    You initial connect sequence in your first post seems to be off.

    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.
  • CORRECTION:

    The issue can be resolved by connectiong a licpo battery to connector BT1. Then power delivery is sufficient for this eval board even with the optimized algorithm.
    So make sure to have a battery connected as the ST board manual suggests.
    More information can be found here: wiki.segger.com/STEVAL-FCU001V1

    This thread will be closed now.

    Original message:
    Hello Chris,

    we received a STEVAL-FCU001V1 board and were able to reproduce the issue.
    It is related to bad board power delivery design. Once our optimized flash loader started the target voltage dropped from 3 V to 1.5 V and reset the target device...
    We have now created a low power flash loader for this particular device which will be released with the next J-Link software release planned for today. With that everything should be working as expected again.

    We will get in touch with ST and inform them about this power delivery issue with that particular board so that future revisions don't have that problems anymore

    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.