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\pyocd_main_.py”, line 402, in run
self.COMMANDSself._args.cmd
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\session.py”, line 339, in enter
self.open()
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\core\session.py”, line 457, in open
self._board.init()
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\board\board.py”, line 85, in init
self.target.init()
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\core\soc_target.py”, line 117, in init
seq.invoke()
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\utility\sequencer.py”, line 213, in invoke
resultSequence.invoke()
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\utility\sequencer.py”, line 208, in invoke
resultSequence = call()
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\coresight\dap.py”, line 376, in _connect
connector.connect(self._protocol)
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\coresight\dap.py”, line 163, in connect
self._connect_probe(protocol)
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\coresight\dap.py”, line 183, in _connect_probe
self._probe.connect(protocol)
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\probe\stlink_probe.py”, line 136, in connect
self._link.enter_debug(STLink.Protocol.SWD)
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\probe\stlink\stlink.py”, line 267, in enter_debug
self._check_status(response)
File “c:\ProgramData\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\probe\stlink\stlink.py”, 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.

Thanks,
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.

2 Likes

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/board_ids.py 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.

Thanks,
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.