understanding reset_modes in ports/stm32/main.c

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
lnsri22
Posts: 75
Joined: Fri Aug 17, 2018 12:16 pm
Location: India

understanding reset_modes in ports/stm32/main.c

Post by lnsri22 » Fri Feb 01, 2019 9:47 am

Hello Everyone!!

I am just trying to understand what "reset_mode" is and what are the impacts of this on boot (flow of main.c) specifically for stm32 port.

It would be of a great help, if someone could point me out the right direction in understanding the flow of main.c



Many thanks!!
lnsri22 :)

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: understanding reset_modes in ports/stm32/main.c

Post by dhylands » Fri Feb 01, 2019 5:29 pm

The reset_modes essentially parallel the modes documented here:
https://docs.micropython.org/en/latest/ ... boot-modes
https://docs.micropython.org/en/latest/ ... boot-modes

reset_mode = 0 not used
reset_mode = 1 means boot normally (i.e. execute boot.py and main.py)
reset_mode = 2 means safe boot - don't run boot.py or main.py
reset_mode = 3 means reset the filesystem back to factory default

So the flow is pretty much exactly the flow of the stm32_main function.

* Do one-time initialization
* soft_reset label
* Do other initialization (i.e. first time and on every soft reset)
* Execute boot.py
* Execute main.py
* Enter the REPL
* Deinitialize peripherals
* goto soft reset label

Post Reply