cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F042 boots in debugger only

Kazimierz Król
Associate III

Hi, I have designed a small project on the STM32F042F6Px MCU, and wrote a piece of software for it. Then I tried to run it outside of the debugger, and realized it won't boot. I've spent many hours on it already, and now I run out of ideas. It looks like no code is executed at all if the MCU is just powered (does not matter if STlink cable is connected or not). Everything runs fine if I power it on, and then choose "Debug" in Atollic.

I have stripped down the program of everything. No, really. I have even disabled everything in the startup file, so that only this remained:

Reset_Handler:
bl main

My main function is just this:

int main(void)
{
  __HAL_RCC_GPIOB_CLK_ENABLE();
  GPIOB->MODER |= 0b01 << (8*2);
  GPIOB->BSRR = GPIO_PIN_8;
  while (1) { };
}

The result is that the PB8 line goes high when the app is run from the debugger, and is floating when run outside of debugger.

I have even soldered another chip in case that one was faulty. No change.

I have over 5 years of experience with various STM32 MCUs, but have never seen anything like this.

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

The other likely option is that BOOT0 is not pulled down. Custom board?

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

4 REPLIES 4
Pavel A.
Evangelist III

Can it be that the program is built to execute in RAM?

(no offence... it happens sometimes)

-- pa

TDK
Guru

The other likely option is that BOOT0 is not pulled down. Custom board?

If you feel a post has answered your question, please click "Accept as Solution".

BOOT pins or Option Byte settings.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Kazimierz Król
Associate III

You are all right 🙂

I have thought about the BOOT0 thing, but assumed that this MCU didn't have the pin (it's not marked in any way in CubeMX, and I haven't thought to cross-check the docs).

And the pin is pulled up on the board of course, so unchecking nBoot0_SW_Cfg did the trick.

THANK YOU!