cancel
Showing results for 
Search instead for 
Did you mean: 

Indicating whether system bootloader runs on STM32 on an output pin?

sdbbs
Associate II

I've taken a look at some datasheets, and I couldn't really find confrmation of this -- but just in case I missed the right terminology: is it possible to set up an STM32 MCU (I guess, via option bytes), so that an output pin might indicate whether the MCU runs system bootloader code (for instance, outputting HIGH level if the MCU runs system bootloader code, and LOW if it doesn't)?

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

I would use an external pullup and set a pin to output low in your code to verify if your code is running. There's nothing you can do to set particular GPIO outputs when in bootloader mode.

If something needs control over getting into or out of the bootloader, it should have control over BOOT0 and NRST to force the issue. Then you don't need to guess.

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

View solution in original post

4 REPLIES 4

Which STM32?

I'd expect it might configure some expectant inputs with pull-ups, perhaps look at AN2606 for potential candidates.

Then you'd need to do the converse thing which your app/code starts..

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

Many thanks, @Community member​ ,

> Which STM32?

I didn't have anything specific in mind, just in general - as I perceive the system bootloader as a feature of STM32 family, my initial guess was, if there was such a feature, it is probably present everywhere the system bootloader is.

> I'd expect it might configure some expectant inputs with pull-ups, perhaps look at AN2606 for potential candidates.

> Then you'd need to do the converse thing which your app/code starts..

Great suggestion, thanks - will consult AN2606!

Btw, since I'm still wrapping my head around the STM32 memory map, and what is/isn't possible, I'd like to ask this: I'm aware I can use Write Memory command in system to write pretty much anywhere in Flash; can I also use Write Memory command to write registers, so as to configure a GPIO pin as output *from the system bootloader*, and then set its value to either low or high?

EDIT: As far as I have seen from AN2606: if you configure to use say USART1, then USART1_TX is configured as out, but then it is used by the bootloader to send ACK/NACK back; other than that, I cannot see any setting what would indicate bootloader run on output pin. AN3155 says "The Write Memory command is used to write data to any valid memory address (see note below) i.e. RAM, Flash memory, or option byte area." - so, no GPIO registers writing from system bootloader (in e.g. stm32f401re, GPIO registers are at 0x4002 0000, that is, "Peripherals" section)

TDK
Guru

I would use an external pullup and set a pin to output low in your code to verify if your code is running. There's nothing you can do to set particular GPIO outputs when in bootloader mode.

If something needs control over getting into or out of the bootloader, it should have control over BOOT0 and NRST to force the issue. Then you don't need to guess.

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

The USART it might use as input are initially configured as TIM inputs where it measures then 0x7F (8E1) pattern so as to auto-baud, and then configures the USART in/out pins to respond with the 0x79

As @TDK​ suggests use a pin you want, and which the loader normally doesn't touch, it should then leave the pin in a floating state as the registers are all in a reset state, and the loader wants to tread as lightly as possible. You can have code very early in your Reset_Handler to set a GPIO flagging it's in your domain, rather than the loaders.

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