Skip to content

Commit 6586fc7

Browse files
authored
Merge pull request #38 from arduino/blink_while_flashing_fw
mod: blinking nano while flashing FW
2 parents 0c0bdfb + d149648 commit 6586fc7

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

arduino_alvik/arduino_alvik.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -2105,6 +2105,19 @@ def update_firmware(file_path: str):
21052105
STM32_eraseMEM,
21062106
STM32_writeMEM, )
21072107

2108+
def flash_toggle():
2109+
i = 0
2110+
2111+
while True:
2112+
if i == 0:
2113+
LEDR.value(1)
2114+
LEDG.value(0)
2115+
else:
2116+
LEDR.value(0)
2117+
LEDG.value(1)
2118+
i = (i + 1) % 2
2119+
yield
2120+
21082121
if CHECK_STM32.value() is not 1:
21092122
print("Turn on your Alvik to continue...")
21102123
while CHECK_STM32.value() is not 1:
@@ -2121,8 +2134,13 @@ def update_firmware(file_path: str):
21212134
STM32_eraseMEM(0xFFFF)
21222135

21232136
print("\nWRITING MEM")
2124-
STM32_writeMEM(file_path)
2137+
toggle = flash_toggle()
2138+
STM32_writeMEM(file_path, toggle)
2139+
21252140
print("\nDONE")
21262141
print("\nLower Boot0 and reset STM32")
21272142

2143+
LEDR.value(1)
2144+
LEDG.value(1)
2145+
21282146
STM32_endCommunication()

arduino_alvik/stm32_flash.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def STM32_readMEM(pages: int):
296296
_incrementAddress(readAddress)
297297

298298

299-
def STM32_writeMEM(file_path: str):
299+
def STM32_writeMEM(file_path: str, toggle: "Generator" = None):
300300

301301
with open(file_path, 'rb') as f:
302302
print(f"Flashing {file_path}\n")
@@ -326,6 +326,8 @@ def STM32_writeMEM(file_path: str):
326326
sys.stdout.write(f"{int((i/file_pages)*100)}%")
327327
i = i + 1
328328
_incrementAddress(writeAddress)
329+
if toggle is not None:
330+
next(toggle)
329331

330332

331333
def _STM32_standardEraseMEM(pages: int, page_list: bytearray = None):

0 commit comments

Comments
 (0)