Skip to content

Commit d20e2c4

Browse files
authored
Merge pull request #1 from gbr1/cleanup
WIP: cleanup
2 parents d6d62e2 + 8d90d47 commit d20e2c4

File tree

6 files changed

+459
-127
lines changed

6 files changed

+459
-127
lines changed

Blink_fast.bin

100755100644
-5.75 KB
Binary file not shown.

FLASH.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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

examples/check_stm32.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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('\nSTM32 FOUND')
10+
11+
print('\nSTM32 GET ID')
12+
id_ = STM32_getID()
13+
print(id_.hex())
14+
15+
print('\nSTM32 GET VERSION')
16+
ver = STM32_getVER()
17+
print(ver.hex())
18+
19+
print('\nSTM32 GET')
20+
get_all = STM32_get()
21+
print(get_all.hex())

examples/read_mem.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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('\nSTM32 FOUND')
10+
11+
print("\nREADING 10 MEM PAGES")
12+
STM32_readMEM(10)

firmware_updater.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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('\nSTM32 FOUND')
10+
11+
print('\nERASING MEM')
12+
STM32_eraseMEM(0xFFFF)
13+
14+
print("\nWRITING MEM")
15+
STM32_writeMEM("Blink_fast.bin")
16+
print("\nDONE")
17+
print("\nLower Boot0 and reset STM32")
18+
19+
STM32_endCommunication()

0 commit comments

Comments
 (0)