Arm Mbed OS support forum

ST-LINK/V2 Error

ST-LINK/V2 works unreliably. It flashes device and runs the program once in 10 trials. the error message is as follows:
0002202:WARNING:cmsis_pack:Page size (1024) is larger than sector size (128) for flash region IROM1; reducing page size to 128
0002435:CRITICAL:main:STLink error (9): Get IDCODE error
Traceback (most recent call last):
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\”, line 402, in run
File "c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd_main
.py", line 572, in do_flash
with session:
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\core\”, line 339, in enter
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\core\”, line 457, in open
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\board\”, line 85, in init
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\core\”, line 117, in init
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\utility\”, line 213, in invoke
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\utility\”, line 208, in invoke
resultSequence = call()
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\coresight\”, line 376, in _connect
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\coresight\”, line 163, in connect
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\coresight\”, line 183, in _connect_probe
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\probe\”, line 136, in connect
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\probe\stlink\”, line 267, in enter_debug
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\probe\stlink\”, line 305, in _check_status
raise exceptions.ProbeError(error_message)
pyocd.core.exceptions.ProbeError: STLink error (9): Get IDCODE error

Hi John,

Can you please let us know what target are you using? I do not see it being listed in the logs above.

Arek - Studio team

Wow! I didn’t expect so prompt response. Before I answer, let me congratulate you on introducing such a nice tool! The UI is very simple and straightforward.

I am using DISCO-L053C8.


Hi John,

Thank you so much for the feedback.

About the issue:
I think that the problem is either in pyOCD or CMSIS-Pack for that target. pyOCD is a python tool that Studio uses for deployment and debug. It supports natively a limited number of targets. Unfortunately, DISCO-L053C8 is not natively supported by pyOCD: pyOCD/ at 5a835e1017182975a11a4caddd83332f74b75fa4 · pyocd/pyOCD · GitHub.

That’s why Studio extends the list of supported boards by providing CMSIS-Packs. Packs are used by pyOCD to try to debug the target even when it is not natively supported. It works correctly for many targets. Unfortunately not for all of them.

Unfortunately, we do not have an access to that particular target at the moment. So I can’t check it myself. Would you mind running one test and attaching logs to this thread? It will allow us to create an issue on pyOCD project page: Issues · pyocd/pyOCD · GitHub . It should speed up the full support for that target in pyOCD and Mbed Studio.

Studio is shipped with many tools and they can be used directly from a terminal: Using tools in the terminal - Using tools in the terminal | Mbed Studio Documentation

From logs above, I see that you are on Windows and you have installed Studio for all users on your system.
What to try:

  1. Open terminal inside Studio: Menu->Terminal->New Terminal
  2. Run pyocd flash directly from terminal: pyocd flash --target stm32l053x8 --pack "C:\ProgramData\Mbed Studio\mbed-studio-tools\cmsis-packs\Keil.STM32L0xx_DFP.2.1.0-small.pack" --erase=chip -O connect_mode=under-reset mbed-os-example-blinky\BUILD\DISCO_L053C8\ARMC6\mbed-os-example-blinky.bin

Please try this command with and without -O connect_mode=under-reset argument. Do not forget to replace the path to the binary to match your program path.
Please attach logs if possible.

Arek - Studio team

It seems as though the system is corrupting the target chip although I ensured the configuration of the probe. I have damaged three chips whilst trying. Please allow me some time. I shall now build up the inventory of the target devices and try as you suggested.