Arm Mbed OS support forum

Mbed Studio Debug Erasing

Hi there,

When I try to load the compiled firmware into a STM32F746 target with a segger JTAG debugger. Mbed studio can recognize the debugger, but cannot flash the firmware. The studio always stays in the state of ‘Background Tasks: Erasing’.

Debug flags:

–target STM32F746NG --erase=chip --pack c:\ProgramData\Mbed Studio\mbed-studio-tools\cmsis-packs\Keil.STM32F7xx_DFP.2.12.0-small.pack

Mbed Studio version: 1.3.1.

I have log, but this forum forbids me to upload!


I also occasionally encounter this problem but with onboard ST-link. Usually it occurs, after few deploying of program, probably 5+ attempts.
At first I thought it cannot connect to the debugger because of some port issue. But if I let the process go on for a long time (about 3 minutes), then the errasing process was completed.
This “delay” was always solved with restart of PC.

BR, Jan

Hi @shoujie2021,

Mbed Studio does not officially support external probes other than STLink. That being said Studio is also not preventing form trying other probes. We are aware of an issue in pyOCD (tool used in Studio for flashing and debugging a program on the board) with JLink support. Mbed Studio 1.4.0 that will be released soon is updating pyOCD to latest version (0.30.2). It contains a fix for JLink and other probes. It may be worth rechecking this problem then.

Kind Regards,
Arek - Studio team

Thanks a lot. But it is not working for me.

I changed to a STLink. It is not working either. But when I tried to use pyocd from terminal, I can erase and program my board, whatever Segger or STLink debugger is connected.

I am pretty sure this is a bug in the ‘Manage custom target’ page.

Just a little background. This happens when I upgrade to 1.3.1 yesterday.

Hi @arekzaluski , This is an issue which the python thread is not launched for some reason.

The command line is fine:
pyocd erase -v -t stm32f746ng --chip

0002804 - INFO - pyocd.coresight.dwt - 4 hardware watchpoints
0002812 - INFO - pyocd.coresight.fpb - 8 hardware breakpoints, 1 literal comparators
0002846 - INFO - pyocd.flash.eraser - Erasing chip…
0049995 - INFO - pyocd.flash.eraser - Done

pyocd flash -t stm32f746ng --base-address 0x8000000 application.bin

is also fine.

Please check the part of ‘Manage Custom Targets’. It seems this is an issue between pyocd and Mbed.


Hi @ysfand,

Thank you for providing more details. Unfortunately, I do not have access to that target at the moment to quickly confirm it.

Can I have few additional questions?

  • Does pyocd flash work for you when --base-address 0x8000000 is not set?
  • Does pyocd flash work for you when --pack c:\ProgramData\Mbed Studio\mbed-studio-tools\cmsis-packs\Keil.STM32F7xx_DFP.2.12.0-small.pack is set?

It will give us an answer if the problem is in:

  • missing base-address argument
  • incorrect cmsis-pack for stm32f746ng target.

Arek - Studio team

  • Does pyocd flash work for you when --base-address 0x8000000 is not set?

pyocd flash xxx.bin

0007798 - CRITICAL - pyocd.tool - No boot memory is defined for this device
Traceback (most recent call last):

  • File “c:\programdata\mbed studio\mbed-studio-tools\python\lib\site-packages\”, line 402, in run*
  • self._COMMANDSself._args.cmd*
  • File “c:\programdata\mbed studio\mbed-studio-tools\python\lib\site-packages\”, line 579, in do_flash*
  • file_format=self._args.format)*
  • File “c:\programdata\mbed studio\mbed-studio-tools\python\lib\site-packages\pyocd\flash\”, line 156, in program*
  • self._format_handlers[file_format](file_obj, *kwargs)
  • File “c:\programdata\mbed studio\mbed-studio-tools\python\lib\site-packages\pyocd\flash\”, line 169, in _program_bin*
  • raise exceptions.TargetSupportError(“No boot memory is defined for this device”)*
    pyocd.core.exceptions.TargetSupportError: No boot memory is defined for this device

Working part:

pyocd flash --base-address 0x08000000 -t stm32f746nghx xxx.bin

0007696 - INFO - pyocd.coresight.cortex_m - CPU core #0 is Cortex-M7 r0p1
0007704 - INFO - pyocd.coresight.cortex_m - FPU present: FPv5-SP-D16-M
0007708 - INFO - pyocd.coresight.dwt - 4 hardware watchpoints
0007715 - INFO - pyocd.coresight.fpb - 8 hardware breakpoints, 1 literal comparators
[====================] 100%

Please pay attention to the string:

–pack “c:\ProgramData\Mbed Studio\mbed-studio-tools\cmsis-packs\Keil.STM32F7xx_DFP.2.12.0-small.pack”

Probably it need “” when to pass it as a parameter!

pyocd flash --base-address 0x08000000 -t stm32f746ng --pack “c:\ProgramData\Mbed Studio\mbed-studio-tools\cmsis-packs\Keil.STM32F7xx_DFP.2.12.0-small.pack” xxx.bin

0004575 - INFO - pyocd.coresight.fpb - 8 hardware breakpoints, 1 literal comparators
[====================] 100%
0205051 - INFO - pyocd.flash.loader - Erased 1048576 bytes (8 sectors), programmed 1048576 bytes (1024 pages), skipped 0 bytes (0 pages) at 5.11 kB/s

Hi @ysfand,

Studio is passing the pack string correctly. The only thing that Studio is not doing is it is not setting -base-address 0x08000000. Please try:

pyocd flash -t stm32f746ng --pack “c:\ProgramData\Mbed Studio\mbed-studio-tools\cmsis-packs\Keil.STM32F7xx_DFP.2.12.0-small.pack” xxx.bin

Arek - Studio team

It is working:

0009028 - INFO - pyocd.coresight.fpb - 8 hardware breakpoints, 1 literal comparators
[= ] 10%

Thank you. It is very helpful. Last request. This is the exact command that Studio is passing for that board. Can you please check it:

pyocd flash -t stm32f746ng --pack “c:\ProgramData\Mbed Studio\mbed-studio-tools\cmsis-packs\Keil.STM32F7xx_DFP.2.12.0-small.pack” --frequency 1800000 -O connect_mode=under-reset xxx.bin

I wonder if frequency or connect_mode are breaking support for that board.

What version of pyOCD do you use? Are you using pyOCD from Studio terminal (pyOCD 0.27.3).

Arek - Studio team

0006184 - INFO - pyocd.board.board - Target type is stm32f746ng
0006288 - INFO - pyocd.coresight.coresight_target - Asserting reset prior to connect
0006376 - CRITICAL - pyocd.tool - uncaught exception: ‘JLinkHardwareStatus’ object is not callable
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 208, in invoke
resultSequence = call()
File “c:\programdata\mbed studio\mbed-studio-tools\python\lib\site-packages\pyocd\coresight\”, line 105, in pre_connect
File “c:\programdata\mbed studio\mbed-studio-tools\python\lib\site-packages\pyocd\coresight\”, line 520, in assert_reset
is_asserted = self.is_reset_asserted()
File “c:\programdata\mbed studio\mbed-studio-tools\python\lib\site-packages\pyocd\coresight\”, line 537, in is_reset_asserted
return self.probe.is_reset_asserted()
File “c:\programdata\mbed studio\mbed-studio-tools\python\lib\site-packages\pyocd\probe\”, line 275, in is_reset_asserted
status = self._link.hardware_status()
TypeError: ‘JLinkHardwareStatus’ object is not callable

pyocd version: 0.32.0

That is because the old version is not working, so I tried a newer one.

Original version should be: 0.27.0

Thanks. Studio team has finished testing release 1.4.0. It will be released on Monday. It contains pyOCD 0.32.0.

It seems that we are getting somewhere. Can you please let me know which argument frequency or -O connect_mode=under-reset is causing the error you posted above?

Arek - Studio team

That is the trouble one:

-O connect_mode=under-reset

Thank you @ysfand . Your help investigating this issue is much appreciated. I’ll reach out to pyOCD team and ask about it. Mbed Studio is setting -O connect_mode=under-reset for all ST targets. Which explains why it doesn’t work.

Kind Regards,

Hi @ysfand,

In the meantime, I recommend looking at Custom targets - Supported and custom targets | Mbed Studio Documentation
Custom targets feature will allow you to override debug flags that are passed to pyOCD.
You should be also able to update pyOCD version used in Studio by opening a new terminal inside a Studio and running:
pip install pyocd==0.32.0

Arek - Studio team