0

My cortex m4 always boots to hard fault, so I want to start debugging it before main. I tried to set breakpoint in startup file, but it did not work.

IDE - STM32Cube
board - stm32f407 discovery(with cortex m4 processor)
OS - ubuntu 20.04

glts
  • 21,808
  • 12
  • 73
  • 94
Abhinav Singh
  • 302
  • 3
  • 15
  • 1
    You can try setting a breakpoint at address 0x0 and reset. Then you can debug from the start. – jf_ Jan 02 '21 at 11:49
  • 2
    At address 0 is initial stack pointer and no code. Setting the breakpoint there is pointless. – 0___________ Jan 02 '21 at 13:06
  • it worked when I put breakpoint to reset handler (by double clicking on the line in editor window) – Abhinav Singh Jan 02 '21 at 13:08
  • 2
    Reset handler is just the function and you can break there. Y – 0___________ Jan 02 '21 at 13:09
  • _"I tried to set breakpoint in startup file, but it did not work."_ what file, and where did you set the breakpoint? Show the code and indicate where you set the breakpoint. – Clifford Jan 02 '21 at 17:50
  • 2
    It seems you have solved the problem from hints in comments and the problem is not as you have stated in you question. Since you seem reluctant to fix the question by clarifying what "did not work", I vote to close this question as "not reproducible" since clearly when you set the breakpoint in the correct place it _does_ work, as it stands the question is not instructive to the community. – Clifford Jan 03 '21 at 12:06
  • Usually the IDE has an option to start running until it hits main(), or to not start running (from power-on reset ISR). Essentially it sets a breakpoint in main() by default. How this is done specifically in various Eclipse spawns may vary. In general, it should be sufficient to do a MCU reset from the debugger and it will take you to the reset ISR. – Lundin Jan 04 '21 at 09:20
  • Though usually, the default CRT for various Cortex M comes with a brain-damaged setup where they run all initialization on the default internal RC oscillator before setting clock/PLL, so it is very common that you have to unf*** the CRT manually to make your MCU start up in a timely manner, see [this](https://stackoverflow.com/a/47940277/584518). – Lundin Jan 04 '21 at 09:21

0 Answers0