Skip to content

Commit

Permalink
dynamic sector erasing
Browse files Browse the repository at this point in the history
  • Loading branch information
Comma Device committed Jul 26, 2022
1 parent 8ff3ff2 commit fce1215
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import time
import traceback
import sys
import math
from functools import wraps
from typing import Optional
from .dfu import PandaDFU, MCU_TYPE_F2, MCU_TYPE_F4, MCU_TYPE_H7 # pylint: disable=import-error
Expand Down Expand Up @@ -304,8 +305,9 @@ def flash_static(handle, code):
handle.controlWrite(Panda.REQUEST_IN, 0xb1, 0, 0, b'')

# erase sectors 1 through 3
print("flash: erasing")
for i in range(1, 4):
num_sectors = math.ceil(len(code) / 0x4000)
print(f"flash: erasing {num_sectors} sectors")
for i in range(1, num_sectors + 1):
handle.controlWrite(Panda.REQUEST_IN, 0xb2, i, 0, b'')

# flash over EP2
Expand Down

0 comments on commit fce1215

Please sign in to comment.