File tree Expand file tree Collapse file tree 6 files changed +459
-127
lines changed Expand file tree Collapse file tree 6 files changed +459
-127
lines changed Original file line number Diff line number Diff line change 1+ # Flashing firmware on STM32 via UART
2+
3+ ### How to
4+
5+ The steps to follow in order to flash a new firmware (.bin) file on STM32 are the following:
6+
7+ _ Uploading the files_
8+ Please install mpremote to upload files on nano-ESP32 especially for binaries
9+
10+ ``` shell
11+ (venv)$ pip install mpremote
12+ ```
13+ to upload a file:
14+ ``` shell
15+ (venv)$ mpremote connect " COM1" fs cp firmware.bin :firmware.bin
16+ ```
17+
18+ _ Hardware_
19+ * Connect STM32 _ Boot0_ pin to VDD 3V3 or connect _ Boot0_ to _ D2_ pin (nano)
20+ * Press _ Reset_ button on Nucleo board or connect STM32 Reset pin to _ D3_ (nano)
21+ * Connect nano _ TX_ pin to STM32 _ D2_ (UART1 RX) pin
22+ * Connect nano _ RX_ pin to STM32 _ D8_ (UART1 TX) pin
23+ * Connect nano _ GND_ to STM32 _ GND_
24+
25+ _ Software_
26+ * Use ` STM32_startCommunication ` to connect to STM32
27+ * Perform a memory erase (eg. mass extended erase ` STM32_eraseMEM(0xFFFF) ` )
28+ * Write your .bin file: ` STM32_writeMEM("Blink_fast.bin") `
29+
30+ If _ Boot0_ is wired to 3V3, disconnect it and press STM32 _ Reset_ pin
31+
32+ ### Tested on
33+
34+ * nano-ESP32 STM32-F401RE
Original file line number Diff line number Diff line change 1+ from sys import exit
2+ from stm32_flash import *
3+
4+ ans = STM32_startCommunication ()
5+ if ans == STM32_NACK :
6+ print ("Cannot etablish connection with STM32" )
7+ exit (- 1 )
8+
9+ print ('\n STM32 FOUND' )
10+
11+ print ('\n STM32 GET ID' )
12+ id_ = STM32_getID ()
13+ print (id_ .hex ())
14+
15+ print ('\n STM32 GET VERSION' )
16+ ver = STM32_getVER ()
17+ print (ver .hex ())
18+
19+ print ('\n STM32 GET' )
20+ get_all = STM32_get ()
21+ print (get_all .hex ())
Original file line number Diff line number Diff line change 1+ from sys import exit
2+ from stm32_flash import *
3+
4+ ans = STM32_startCommunication ()
5+ if ans == STM32_NACK :
6+ print ("Cannot etablish connection with STM32" )
7+ exit (- 1 )
8+
9+ print ('\n STM32 FOUND' )
10+
11+ print ("\n READING 10 MEM PAGES" )
12+ STM32_readMEM (10 )
Original file line number Diff line number Diff line change 1+ from sys import exit
2+ from stm32_flash import *
3+
4+ ans = STM32_startCommunication ()
5+ if ans == STM32_NACK :
6+ print ("Cannot etablish connection with STM32" )
7+ exit (- 1 )
8+
9+ print ('\n STM32 FOUND' )
10+
11+ print ('\n ERASING MEM' )
12+ STM32_eraseMEM (0xFFFF )
13+
14+ print ("\n WRITING MEM" )
15+ STM32_writeMEM ("Blink_fast.bin" )
16+ print ("\n DONE" )
17+ print ("\n Lower Boot0 and reset STM32" )
18+
19+ STM32_endCommunication ()
You can’t perform that action at this time.
0 commit comments