mirror of
https://github.com/infiniteCable2/panda.git
synced 2026-02-18 09:13:52 +08:00
flashing speeeed (#2264)
* less sectors * why are we taking baby steps * revert * cleanup --------- Co-authored-by: Comma Device <device@comma.ai>
This commit is contained in:
@@ -431,7 +431,7 @@ class Panda:
|
||||
handle.controlWrite(Panda.REQUEST_IN, 0xb2, i, 0, b'')
|
||||
|
||||
# flash over EP2
|
||||
STEP = 0x10
|
||||
STEP = 0x200
|
||||
logger.info("flash: flashing")
|
||||
for i in range(0, len(code), STEP):
|
||||
handle.bulkWrite(2, code[i:i + STEP])
|
||||
|
||||
@@ -116,10 +116,11 @@ class PandaDFU:
|
||||
def program_bootstub(self, code_bootstub):
|
||||
self._handle.clear_status()
|
||||
|
||||
# erase all sectors
|
||||
for i in range(len(self._mcu_type.config.sector_sizes)):
|
||||
# erase bootstub + app sectors
|
||||
for i in (0, 1):
|
||||
self._handle.erase_sector(i)
|
||||
|
||||
# write bootstub
|
||||
self._handle.program(self._mcu_type.config.bootstub_address, code_bootstub)
|
||||
|
||||
def recover(self):
|
||||
|
||||
@@ -5,7 +5,6 @@ from panda import Panda, PandaDFU
|
||||
class GPIO:
|
||||
STM_RST_N = 124
|
||||
STM_BOOT0 = 134
|
||||
HUB_RST_N = 30
|
||||
|
||||
|
||||
def gpio_init(pin, output):
|
||||
@@ -18,32 +17,24 @@ def gpio_set(pin, high):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
for pin in (GPIO.STM_RST_N, GPIO.STM_BOOT0, GPIO.HUB_RST_N):
|
||||
for pin in (GPIO.STM_RST_N, GPIO.STM_BOOT0):
|
||||
gpio_init(pin, True)
|
||||
|
||||
# reset USB hub
|
||||
gpio_set(GPIO.HUB_RST_N, 0)
|
||||
time.sleep(0.5)
|
||||
gpio_set(GPIO.HUB_RST_N, 1)
|
||||
|
||||
# flash bootstub
|
||||
print("resetting into DFU")
|
||||
gpio_set(GPIO.STM_RST_N, 1)
|
||||
gpio_set(GPIO.STM_BOOT0, 1)
|
||||
time.sleep(1)
|
||||
time.sleep(0.2)
|
||||
gpio_set(GPIO.STM_RST_N, 0)
|
||||
gpio_set(GPIO.STM_BOOT0, 0)
|
||||
time.sleep(1)
|
||||
|
||||
# bootstub flash takes 2s and is limited by the 255 byte flashing chunk size
|
||||
print("flashing bootstub")
|
||||
assert Panda.wait_for_dfu(None, 5)
|
||||
PandaDFU(None).recover()
|
||||
|
||||
gpio_set(GPIO.STM_RST_N, 1)
|
||||
time.sleep(0.5)
|
||||
gpio_set(GPIO.STM_RST_N, 0)
|
||||
time.sleep(1)
|
||||
|
||||
print("flashing app")
|
||||
assert Panda.wait_for_panda(None, 5)
|
||||
p = Panda()
|
||||
assert p.bootstub
|
||||
p.flash()
|
||||
|
||||
Reference in New Issue
Block a user