cancel
Showing results for 
Search instead for 
Did you mean: 

Black Pill: Debugging STM32F103RCT6 in Keil Fails to Enter main()

merose
Associate

Title edited to highlight that this is a "Black Pill" board


  • MCU: STM32F103RCT6

  • Toolchain: Keil MDK v5.31 + DAPLink debugger

  • Behavior:

    • Program flashes successfully via DAPLink.

    • Debug session starts but never enters main() – halts at address 0x200001E0 (check Disassembly/Register window).

    • All debug buttons (Step, Run) are grayed out except Reset/Stop.

  • Key Observations:

    • Same code runs correctly on another STM32F103 board.

    • Rebuild/Clean did not resolve the issue.

merose_0-1743582902994.png

The "Option for target" as below.

merose_1-1743583253545.png

merose_2-1743583272480.pngmerose_3-1743583294382.png

merose_4-1743583305233.png

merose_0-1743583956883.png

16 REPLIES 16
mƎALLEm
ST Employee

Hello @merose and welcome to the ST community,

Are you using Blue pill or Black pill board?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Welcome to the forum.

Please give details of your two boards - see: How to write your question to maximize your chances to find a solution.

 


@merose wrote:
  • MCU: STM32F103RCT6


Are you sure it's a genuine ST chip?

 


@merose wrote:
    • Debug session starts but never enters main() – halts at address 0x200001E0 


So somewhere in the startup code.

Look at the startup code to see what should be happening ?

Ozone
Lead III

As usual, try to locate the "Run to main" setting in your debugging environment, and disable it.
The code obviously fails in the init code, most probably during clock setup.
If the same code runs properly on "another board", memory size and lication issues are unlikely - unless these are not the same kind of board.
Differently placed jumpers that affect settings might be another reason.

It's Black Pill. What's the difference between them?

They at 99% contain a counterfeit STM32.

And this may confirm my saying:

  • Same code runs correctly on another STM32F103 board.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Thanks.I will try this.


@mƎALLEm wrote:

They at 99% contain a counterfeit STM32.


and that's being generous!

@merose read about it here: https://mecrisp-stellaris-folkdoc.sourceforge.io/bluepill-diags-v1.640.html

And here's an example of the grief they can cause:

https://community.st.com/t5/stm32-mcus-products/configuring-uart-on-stm32f103c8t6-bluepill-kills-connection-to/m-p/668641/highlight/true#M242690

searching the forum will find many more!

 


@mƎALLEm wrote:

And this may confirm my saying:

  • Same code runs correctly on another STM32F103 board.


Indeed.

@merose you still haven't said what the "other STM32F103 board" is.


@Andrew Neil wrote:

@merose you still haven't said what the "other STM32F103 board" is.


Even if the "other STM32 board" is a black/blue pill, still the same thing: on one board is working on another not because it's, simply, contain a counterfeit MCU (not tested in the factory) ;).

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

IMG_20250402_204531.jpgIMG_20250402_204519.jpg

This is what I use. Another board are the same as this one.