Fix upgrade via microSD
This commit is contained in:
parent
ecfba51f23
commit
bc71abbb47
@ -217,7 +217,7 @@ async def microsd_upgrade(*a):
|
||||
failed = None
|
||||
|
||||
with CardSlot() as card:
|
||||
with open(fn, 'rb') as fp:
|
||||
with card.open(fn, 'rb') as fp:
|
||||
from version import has_psram
|
||||
if has_psram:
|
||||
from glob import PSRAM as SF
|
||||
@ -247,15 +247,17 @@ async def microsd_upgrade(*a):
|
||||
|
||||
dis.fullscreen("Loading...")
|
||||
|
||||
if not has_psram:
|
||||
buf = bytearray(256)
|
||||
pos = 0
|
||||
while pos < size:
|
||||
dis.progress_bar_show(pos/size)
|
||||
buf = bytearray(256 if not has_psram else 0x20000)
|
||||
pos = 0
|
||||
while pos < size:
|
||||
dis.progress_bar_show(pos/size)
|
||||
|
||||
here = fp.readinto(buf)
|
||||
if not here: break
|
||||
here = fp.readinto(buf)
|
||||
if not here: break
|
||||
|
||||
if has_psram:
|
||||
SF.write(pos, buf)
|
||||
else:
|
||||
if pos % 4096 == 0:
|
||||
# erase here
|
||||
SF.sector_erase(pos)
|
||||
@ -268,11 +270,7 @@ async def microsd_upgrade(*a):
|
||||
while SF.is_busy():
|
||||
await sleep_ms(1)
|
||||
|
||||
pos += here
|
||||
else:
|
||||
# just read it to where we want it
|
||||
dest = SF.write(0, size)
|
||||
fp.readinto(dest)
|
||||
pos += here
|
||||
|
||||
if failed:
|
||||
await ux_show_story(failed, title='Sorry!')
|
||||
@ -280,7 +278,7 @@ async def microsd_upgrade(*a):
|
||||
|
||||
# continue process...
|
||||
from auth import FirmwareUpgradeRequest
|
||||
m = FirmwareUpgradeRequest(hdr, size)
|
||||
m = FirmwareUpgradeRequest(hdr, size, psram_offset=(0 if has_psram else None))
|
||||
the_ux.push(m)
|
||||
|
||||
async def start_dfu(*a):
|
||||
|
||||
@ -1251,9 +1251,8 @@ Binary checksum and signature will be further verified before any changes are ma
|
||||
|
||||
callgate.show_logout(2)
|
||||
else:
|
||||
# Mk4 copies from PSRAM into SPI inside bootrom
|
||||
# - and does other stuff
|
||||
#print("offset=%d len=%d" % (self.psram_offset, self.length))
|
||||
# Mk4 copies from PSRAM to flash inside bootrom, we have
|
||||
# nothing to do here except start that process.
|
||||
from pincodes import pa
|
||||
pa.firmware_upgrade(self.psram_offset, self.length)
|
||||
# not reached, unless issue?
|
||||
|
||||
Loading…
Reference in New Issue
Block a user