2
\$\begingroup\$

I am using an STM32F4 with the Rowley CrossStudio for ARM. It is not clear to me how to have the MCU start from int main() on reset (i.e. power up the device). I thought building it in release mode would have done this, but that seems not to be the case.

Looking online, I see some people saying that you somehow change the startup vector but this may prevent future debugging?

Is there a good way to accomplish this so that I can debug if I need to and run my program without the debugger on startup?

Thank you!

\$\endgroup\$
  • \$\begingroup\$ What is the state of the BOOT0 pin? This controls the startup mode of most members of the STM32 family. \$\endgroup\$ – Chris Stratton Mar 2 '18 at 19:49
  • \$\begingroup\$ Aha! By grounding the BOOT0 pin I was able to make this work. This is a good hardware solution, but shouldn't I still be able to programmatically make this work? \$\endgroup\$ – Biff Mar 4 '18 at 0:32
  • \$\begingroup\$ No, you have to use the pin, or else have something else command it to jump to flash. \$\endgroup\$ – Chris Stratton Mar 4 '18 at 1:14
1
\$\begingroup\$

On most (but perhaps not all) members of the STM32 family, to automatically boot an application from flash you must ground the BOOT0 pin.

This is essentially so that if you have a bad application in flash, or one that does not provide a means of entering the bootloader, you can force entry to the bootloader by cycling reset with BOOT0 high (with appropriate setting of boot1 or other mode controls to select the bootloader rather than RAM).

\$\endgroup\$
2
\$\begingroup\$

If you define the macro STARTUP_FROM_RESET it should jump to the proper reset vector on startup.

The JTAG interface should still be able to gain control if you've built for debug.

\$\endgroup\$
  • \$\begingroup\$ So I tried #define STARTUP_FROM RESET 1 in my main.c file but it didn't seem to work? \$\endgroup\$ – Biff Mar 2 '18 at 18:59
  • \$\begingroup\$ Try in Startup.s \$\endgroup\$ – Spehro Pefhany Mar 2 '18 at 19:03
  • 1
    \$\begingroup\$ You could add this as a project setting. "Build Options"->"Project Macros" if I remember correctly \$\endgroup\$ – brhans Mar 2 '18 at 22:24
  • \$\begingroup\$ Defining it in Startup.s does not work, and adding STARTUP_FROM_RESET in global macros does not work either. \$\endgroup\$ – Biff Mar 4 '18 at 0:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.