Fix upgrade via microSD

This commit is contained in:
Peter D. Gray 2021-12-14 11:26:10 -05:00
parent ecfba51f23
commit bc71abbb47
No known key found for this signature in database
GPG Key ID: F0E6CC6AFC16CF7B
2 changed files with 14 additions and 17 deletions

View File

@ -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):

View File

@ -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?