Problem: I cannot upload/debug my STM32 application.

I'm using

  • STM32F103C8T6 (BluePill development board)
  • ST-Link V2.1
  • STM32CubeIDE.

I tried another elf which works ok, but I don't see any obvious debug configuration changes between the application I want to upload/debug. Output console:

STMicroelectronics ST-LINK GDB server. Version 5.3.2
Copyright (c) 2019, STMicroelectronics. All rights reserved.
Starting server with the following options:
        Persistent Mode            : Disabled
        LogFile Name               : E:\User\git\FuzzTester\FuzzTester\Debug\st-link_gdbserver_log.txt
        Logging Level              : 31
        Listen Port Number         : 61234
        Status Refresh Delay       : 15s
        Verbose Mode               : Enabled
        SWD Debug                  : Enabled
        InitWhile                  : Enabled

Target connection mode: Under reset
Hardware watchpoint supported by the target 
COM frequency = 4000 kHz
ST-LINK Firmware version : V2J34S7
Device ID: 0x410
PC: 0x8002108
ST-LINK device status: HALT_MODE
ST-LINK detects target voltage = 3.26 V
ST-LINK device status: HALT_MODE
Run external memory initializer
ST-LINK device status: RUN_MODE
Failed to initialize external memory!

Error in initializing ST-LINK device.
Reason: Unknown. Please check power and cabling to target.

I added EEPROM simulation, but I assume the application has not even started, so I doubt this can be an issue.

Also, power/cabling is not an issue, as I can debug another application (without changing cabling).

Furthermore, I upgraded my ST-Link which was successfully (option within the last menu option, earlier inside the ST-Link Utility).

Most obvious debug configuration settings: (not I use connection under reset, which always worked so far).

enter image description here

What did I do wrong?

I had many problems with connecting, but since I don't use PA11/12 for USB I did not had problems for the last months until now. What can I do to upload my application?

Below the complete log file.

[0.000] initConfigParams():  Configuration flags start
[0.000] initConfigParams():   halt                           false
[0.000] initConfigParams():   config-file                    ""
[0.000] initConfigParams():   persistent                     false
[0.000] initConfigParams():  +log-file                       "E:\User\git\FuzzTester\FuzzTester\Debug\st-link_gdbserver_log.txt"
[0.000] initConfigParams():  +log-level                      31
[0.000] initConfigParams():  +port-number                    61234
[0.000] initConfigParams():  +verbose                        true
[0.000] initConfigParams():   refresh-delay                  15
[0.000] initConfigParams():  +verify                         true
[0.001] initConfigParams():  +swd                            true
[0.001] initConfigParams():   swo-port                       61234
[0.001] initConfigParams():   cpu-clock                      8000000
[0.001] initConfigParams():   swo-clock-div                  128
[0.001] initConfigParams():  +initialize-reset               true
[0.001] initConfigParams():   debuggers                      false
[0.001] initConfigParams():  +serial-number                  "50FF6B065180485548242287"
[0.001] initConfigParams():  +apid                           0
[0.001] initConfigParams():   attach                         false
[0.001] initConfigParams():   shared                         false
[0.001] initConfigParams():   erase-all                      false
[0.001] initConfigParams():   memory-map                     ""
[0.001] initConfigParams():   ext-memory-loaders             false
[0.001] initConfigParams():  +extload                        "512W3A_STM3210E-EVAL.stldr"
[0.001] initConfigParams():  +stm32cubeprogrammer-path       "C:\ST\STM32CubeIDE_1.1.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_1.1.0.201910081157\tools\bin"
[0.001] initConfigParams():   temp-path                      ""
[0.001] initConfigParams():   preserve-temps                 false
[0.001] initConfigParams():   frequency                      -1
[0.001] initConfigParams():   licenses                       false
[0.001] initConfigParams():   ignore-rest                    false
[0.001] initConfigParams():   version                        false
[0.001] initConfigParams():   help                           false
[0.001] initConfigParams():  Configuration flags end
[0.002] init():  STMicroelectronics ST-LINK GDB server. Version 5.3.2
Copyright (c) 2019, STMicroelectronics. All rights reserved.
[0.012] Device_Initialise():  Target connection mode: Under reset
[0.022] reset_hw_wtchpt_module():  Hardware watchpoint supported by the target 
[0.030] Device_Initialise():  COM frequency = 4000 kHz
[0.030] Device_Initialise():  ST-LINK Firmware version : V2J34S7
[0.030] Device_Initialise():  Device ID: 0x410
[0.030] Device_Initialise():  PC: 0x8002108
[0.031] Device_GetStatus():  ST-LINK device status: HALT_MODE
[0.032] Device_Initialise():  ST-LINK detects target voltage = 3.26 V
[0.034] Device_Initialise():  ST-LINK device status: HALT_MODE
[0.034] initExternalMemory():  Found external memory initializer at 0x2000162d
[0.034] initExternalMemory():  Writing external memory initializer seg at 0x20000004 (0 byte)
[0.097] initExternalMemory():  Writing external memory initializer seg at 0x20002424 (0 byte)
[0.104] initExternalMemory():  MSP: 0x20002678
[0.104] initExternalMemory():  LR: 0x200024ec
[0.104] initExternalMemory():  Run external memory initializer
[0.105] Device_GetStatus():  ST-LINK device status: RUN_MODE
[0.105] initExternalMemory():  pc: 0x200024ed; ret: 0
[0.206] initExternalMemory():  Restore after external memory initializer
[0.207] initExternalMemory():  Init() failed returned 0x200024ed @ 0x200024ed
[0.209] initExternalMemory():  r0           0x200024ed
[0.209] initExternalMemory():  r1           0x200024ed
[0.209] initExternalMemory():  r2           0x200024ed
[0.209] initExternalMemory():  r3           0x200024ed
[0.209] initExternalMemory():  r4           0x200024ed
[0.210] initExternalMemory():  r5           0x200024ed
[0.210] initExternalMemory():  r6           0x200024ed
[0.210] initExternalMemory():  r7           0x200024ed
[0.210] initExternalMemory():  r8           0x200024ed
[0.210] initExternalMemory():  r9           0x200024ed
[0.210] initExternalMemory():  r10          0x200024ed
[0.210] initExternalMemory():  r11          0x200024ed
[0.210] initExternalMemory():  r12          0x200024ed
[0.210] initExternalMemory():  sp           0x200024ed
[0.210] initExternalMemory():  lr           0x200024ed
[0.210] initExternalMemory():  pc           0x200024ed
[0.210] initExternalMemory():  xpsr         0x200024ed
[0.210] initExternalMemory():  PRIMASK      0x0
[0.210] initExternalMemory():  BASEPRI      0x0
[0.210] initExternalMemory():  FAULTMASK    0x0
[0.210] initExternalMemory():  CONTROL      0x200024ed
[0.210] initExternalMemory():  MSP          0x200024ed
[0.210] initExternalMemory():  PSP          0x200024ed
[0.212] initExternalMemory():  Stack 0x200024ed <sp+0>:  0x7b1151be
[0.213] initExternalMemory():  Stack 0x200024f1 <sp+4>:  0x9244d51d
[0.214] initExternalMemory():  Stack 0x200024f5 <sp+8>:  0x8b15208b
[0.216] initExternalMemory():  Stack 0x200024f9 <sp+12>: 0x8aeafcae
[0.217] initExternalMemory():  Stack 0x200024fd <sp+16>: 0xbe0170b1
[0.218] initExternalMemory():  Stack 0x20002501 <sp+20>: 0xb62a8a35
[0.220] initExternalMemory():  Stack 0x20002505 <sp+24>: 0x545a4d04
[0.221] initExternalMemory():  Stack 0x20002509 <sp+28>: 0x78424413
[0.222] initExternalMemory():  Stack 0x2000250d <sp+32>: 0xb722fa2c
[0.224] initExternalMemory():  Stack 0x20002511 <sp+36>: 0xd3fa888a
[0.225] initExternalMemory():  Stack 0x20002515 <sp+40>: 0x54c3a096
[0.227] initExternalMemory():  Stack 0x20002519 <sp+44>: 0x1a755d67
[0.229] Device_Initialise():  Failed to initialize external memory!
[0.229] initServerContext():  
Error in initializing ST-LINK device.
Reason: [0.229] initServerContext():  Unknown. Please check power and cabling to target.
  • 1
    \$\begingroup\$ So are you using an external NAND flash, or is the checkbox accidentally on? \$\endgroup\$
    – Justme
    Apr 23, 2020 at 17:56
  • \$\begingroup\$ @Justme it was initially off, but I scanned it, and that was what comes out. However, I tried another sketch and this application, and switching it on or off does not matter. But since it works with another application, it's somewhere in the application, and (high likely) not related to the settings. \$\endgroup\$ Apr 23, 2020 at 20:04

1 Answer 1


Somehow it works again, but I'm not sure exactly what, since I tried a lot of things and one of them must have made debugging possible again (but it worked after restarting CubeIDE, although I did several times before without luck).

What I did was:

  • Changed a few settings in the IOC file (just to regenerate it)
  • Moved the folder out of git, renamed and imported it again
  • Changed USB cable
  • Restarted CubeIDE

One of those must have 'fixed' the problem. Hope it doens't come back by itself again.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.