cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F042F4P6 does not enter main()?

tdarlic
Associate II

Hi guys

I am bringing up a small test board containing a STM32F042 MCU with just several connections.

I have exported code from CubeMX5 and imported into Eclipse. I am trying to debug the board with j-link but according to debugger code loops infinitely somewhere from 0x1fff c6e0 to 0x1fff c9f0. The code never stops unless I suspend it and that is where the debugger always land with message: Break at address "0x1fffc6e0" with no debug information available, or outside of program code. Im not sure is this the startup code.

Below are the images showing how is the MCU connected and the clock setup. When I first connected the board it seemed to be working and entered the main() but but I had to reset the j-link on every start. Now I cannot get it to work even with completely freshly generated project from CubeMX. Debugger always lands in that part of code.

I pasted relevant part of my schematic and the clock configuration diagram below.

Does anyone has any idea how to debug this?

0690X000006D9ssQAC.png

0690X000006D9snQAC.png

1 ACCEPTED SOLUTION

Accepted Solutions

If there is no boot pin, you need to make sure the boot options are set to execute code in FLASH

Perhaps use the ST-LINK Utilites, or equivalent Segger tools to check.

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

View solution in original post

3 REPLIES 3

If there is no boot pin, you need to make sure the boot options are set to execute code in FLASH

Perhaps use the ST-LINK Utilites, or equivalent Segger tools to check.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
tdarlic
Associate II

Thanks for that idea. It seems to me that I boot from system memory. I did not see the boot pin in the CubeMX so I just thought that I don't have one.

I found this in the reference manual:

In the STM32F0xx, three different boot modes can be selected through the BOOT0 pin and

boot configuration bits nBOOT1, BOOT_SEL and nBOOT0 in the User option byte.

Boot from system memory: the system memory is aliased in the boot memory space

(0x0000 0000), but still accessible from its original memory space 0x1FFF C400 on STM32F04x devices. It seems that device boots from system memory.

There is this link on how to setup the fuses trough the StLink, i cannot find that in my IDE or j-link https://community.st.com/s/question/0D50X00009XkY9OSAV/where-are-option-bytes-defined

I cannot figure it out how to setup the option bytes trough the code or j-link.

tdarlic
Associate II

Just to update.

I struggled to change the option bytes on the jlink or directly from Eclipse. I failed so installed ST-LINK on a windows virtual machine bcause I develop on Linux. I do not have ST-LINK hardware here so I used Nucleo board ST-LINK part and ST-LINK utility in windows to change the option bytes from graphical user interface, saved it and the board booted normally into the main().

So it was finally because of the option bytes.

Is there any easy way to change the option bytes in the code so when it is uploaded to the MCU they are automatically set correctly? I googled but couldn't find anything.

There is a link on Segger site detailing some of the comands

https://wiki.segger.com/STM32