Skip to content

mod: blinking nano while flashing FW #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion arduino_alvik/arduino_alvik.py
Original file line number Diff line number Diff line change
Expand Up @@ -2105,6 +2105,19 @@ def update_firmware(file_path: str):
STM32_eraseMEM,
STM32_writeMEM, )

def flash_toggle():
i = 0

while True:
if i == 0:
LEDR.value(1)
LEDG.value(0)
else:
LEDR.value(0)
LEDG.value(1)
i = (i + 1) % 2
yield

if CHECK_STM32.value() is not 1:
print("Turn on your Alvik to continue...")
while CHECK_STM32.value() is not 1:
Expand All @@ -2121,8 +2134,13 @@ def update_firmware(file_path: str):
STM32_eraseMEM(0xFFFF)

print("\nWRITING MEM")
STM32_writeMEM(file_path)
toggle = flash_toggle()
STM32_writeMEM(file_path, toggle)

print("\nDONE")
print("\nLower Boot0 and reset STM32")

LEDR.value(1)
LEDG.value(1)

STM32_endCommunication()
4 changes: 3 additions & 1 deletion arduino_alvik/stm32_flash.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def STM32_readMEM(pages: int):
_incrementAddress(readAddress)


def STM32_writeMEM(file_path: str):
def STM32_writeMEM(file_path: str, toggle: "Generator" = None):

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


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