Debug Nucleo-F303K8 blinky-baremetal

My equipment: Mbed Studio 1.4.1 + Nucleo-F303K8 + mbed-os-examble-blinky-baremetal

Debugging this baremetal-blinky program fails with this:

“0034451:ERROR:gdbserver:Unhandled exception in handle_message: Memory transfer fault (read) @ 0xe000ed30-0xe000ed37”
Remote failure reply: E01

Any subsequent attempts to start over with a fresh debugging session also fails with:
0002839:ERROR:gdbserver:Unexpected exception: STLink error (20): DP wait

Reset/power cycle of the device, restart of the Mbed Studio doesn’t help. Getting the same error.

The way for me to get it going again is to do a full chip erase (I’m using STM32CubeProgrammer for this). I’ve not drilled down to what bit or sector needs to be deleted.

After clearing the device the debug session can be started once again, and fails with:
“0034451:ERROR:gdbserver:Unhandled exception in handle_message: Memory transfer fault (read) @ 0xe000ed30-0xe000ed37”
Remote failure reply: E01

Any suggestion? The equipment and Mbed installation are just out of the box. Right now this doesn’t fill me with confidence to use it for anything bigger.

Additional info to my initial message.

When executing this line:
thread_sleep_for(WAIT_TIME_MS);

I get this error message:
"0165089:ERROR:gdbserver:Unhandled exception in handle_message: Memory transfer fault (read) @ 0xe000ed30-0xe000ed37"
After this the a new debug session can’t be established and the device needs to be erased.

Does the device go to (deep-) sleep and the debugger can’t access it any more?

Hello,

that is not related to the MbedOS section but with MbedStudio section.
F303k8 is not officially supported for debugging - Development boards - debug | Mbed.

However similar issue was mentioned here.

You can try to replace thread_sleep_for(WAIT_TIME_MS) use with HAL_delay(WAIT_TIME_MS).

BR, Jan