Skip to main content
Mysterious Wolf
Associate II
August 31, 2022
Solved

Why are there random breakpoints in the assembly code and how to get rid of them?

  • August 31, 2022
  • 3 replies
  • 1954 views

I'm migrating a project from STM32G431KB to STM32G431CBT6. Both projects were generated using STM32CubeMX and are developed in Keil (MDK ARM), so I only transferred the user code. However when debugging code on the new chip, random breakpoint commands in the disassembly window appear (not the user-defined red dots, but the BKPT mnemonic specifically).

It's always first 3 times between _sys_open and _sys_close, then one time between _sys_istty and_sys_seek and another one between _sys_write, _sys_read, then my program runs normally. I tried a full chip wipe, code regeneration, code rebuilds all without any luck. I'm guessing there might be a setting I forgot somewhere that could cause this or a library from CubeMX, but so far I haven't been able to figure out what it could be.

The CubeMX software packs I use:0693W00000SuBfxQAF.pngSelected features:

0693W00000SuBg2QAF.png

Best answer by Tesla DeLorean

Semi-hosting?

T​here type of file IO functions are not supported on the device, the breakpoints allow the debugger to interact with resources on the host PC

3 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
August 31, 2022

Semi-hosting?

T​here type of file IO functions are not supported on the device, the breakpoints allow the debugger to interact with resources on the host PC

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Mysterious Wolf
Associate II
September 1, 2022

Thank you very much. I thought it was something like that, but couldn't find what it's called. I managed to redirect the calls to ITM, but there is nothing in the debug window. Nevertheless, this solved the core issue!

Associate
March 3, 2025

I'm running into a similar issue. Could someone give an example or more details on how they defined these missing functions?

Tesla DeLorean
Guru
March 3, 2025

It's been several years.

Things like STDIO (file and output), clock() functionality don't have an OS to fall back on. Absent some plumbing to YOUR hardware there will be functions with BKPT that the C library calls in hopes that the debugger will facilitate functionality on the HOST PC

https://github.com/timmy00274672/STM32-Learning/blob/master/CMSIS_V1P10/UartDev/Example/Retarget.c

 

See Semi-Hosting, Retargeting 

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..