mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-23 05:33:52 +08:00
openpilot v0.7.9 release
This commit is contained in:
@@ -7,7 +7,7 @@ import json
|
||||
import io
|
||||
|
||||
def flash_release(path=None, st_serial=None):
|
||||
from panda import Panda, PandaDFU, ESPROM, CesantaFlasher
|
||||
from panda import Panda, PandaDFU
|
||||
from zipfile import ZipFile
|
||||
|
||||
def status(x):
|
||||
@@ -23,33 +23,28 @@ def flash_release(path=None, st_serial=None):
|
||||
st_serial = panda_list[0]
|
||||
print("Using panda with serial %s" % st_serial)
|
||||
|
||||
if path is not None:
|
||||
if path is None:
|
||||
print("Fetching latest firmware from github.com/commaai/panda-artifacts")
|
||||
r = requests.get("https://raw.githubusercontent.com/commaai/panda-artifacts/master/latest.json")
|
||||
url = json.loads(r.text)['url']
|
||||
r = requests.get(url)
|
||||
print("Fetching firmware from %s" % url)
|
||||
path = io.StringIO(r.content)
|
||||
path = io.BytesIO(r.content)
|
||||
|
||||
zf = ZipFile(path)
|
||||
zf.printdir()
|
||||
|
||||
version = zf.read("version")
|
||||
status("0. Preparing to flash " + version)
|
||||
version = zf.read("version").decode()
|
||||
status("0. Preparing to flash " + str(version))
|
||||
|
||||
code_bootstub = zf.read("bootstub.panda.bin")
|
||||
code_panda = zf.read("panda.bin")
|
||||
|
||||
code_boot_15 = zf.read("boot_v1.5.bin")
|
||||
code_boot_15 = code_boot_15[0:2] + "\x00\x30" + code_boot_15[4:]
|
||||
|
||||
code_user1 = zf.read("user1.bin")
|
||||
code_user2 = zf.read("user2.bin")
|
||||
|
||||
# enter DFU mode
|
||||
status("1. Entering DFU mode")
|
||||
panda = Panda(st_serial)
|
||||
panda.enter_bootloader()
|
||||
panda.reset(enter_bootstub=True)
|
||||
panda.reset(enter_bootloader=True)
|
||||
time.sleep(1)
|
||||
|
||||
# program bootstub
|
||||
@@ -64,29 +59,8 @@ def flash_release(path=None, st_serial=None):
|
||||
panda.flash(code=code_panda)
|
||||
panda.close()
|
||||
|
||||
# flashing ESP
|
||||
if panda.is_white():
|
||||
status("4. Flashing ESP (slow!)")
|
||||
|
||||
def align(x, sz=0x1000):
|
||||
x + "\xFF" * ((sz - len(x)) % sz)
|
||||
|
||||
esp = ESPROM(st_serial)
|
||||
esp.connect()
|
||||
flasher = CesantaFlasher(esp, 230400)
|
||||
flasher.flash_write(0x0, align(code_boot_15), True)
|
||||
flasher.flash_write(0x1000, align(code_user1), True)
|
||||
flasher.flash_write(0x81000, align(code_user2), True)
|
||||
flasher.flash_write(0x3FE000, "\xFF" * 0x1000)
|
||||
flasher.boot_fw()
|
||||
del flasher
|
||||
del esp
|
||||
time.sleep(1)
|
||||
else:
|
||||
status("4. No ESP in non-white panda")
|
||||
|
||||
# check for connection
|
||||
status("5. Verifying version")
|
||||
status("4. Verifying version")
|
||||
panda = Panda(st_serial)
|
||||
my_version = panda.get_version()
|
||||
print("dongle id: %s" % panda.get_serial()[0])
|
||||
|
||||
Reference in New Issue
Block a user