mirror of
https://github.com/Polprzewodnikowy/SummerCart64.git
synced 2024-12-26 13:01:55 +01:00
[SC64][SW] SW programing bug fixes
This commit is contained in:
parent
6def5b0efc
commit
3fc6229cea
@ -99,6 +99,12 @@ class SC64UpdateData:
|
||||
return (id, data)
|
||||
|
||||
def load(self, path: str, require_all: bool=False) -> None:
|
||||
self.__update_info = None
|
||||
self.__mcu_data = None
|
||||
self.__fpga_data = None
|
||||
self.__bootloader_data = None
|
||||
self.__primer_data = None
|
||||
|
||||
try:
|
||||
with open(path, 'rb') as f:
|
||||
if (f.read(len(self.__UPDATE_TOKEN)) != self.__UPDATE_TOKEN):
|
||||
@ -228,7 +234,7 @@ class STM32Bootloader:
|
||||
length = len(data)
|
||||
if (length == 0 or length > self.__MEMORY_RW_MAX_SIZE):
|
||||
raise ValueError('Wrong data size for write memory command')
|
||||
if (length % 4):
|
||||
if (((address % 4) != 0) or ((length % 4) != 0)):
|
||||
raise ValueError('Write memory command requires 4 byte alignment')
|
||||
self.__cmd_send(b'\x31')
|
||||
self.__data_write(address.to_bytes(4, byteorder='big'))
|
||||
@ -354,6 +360,8 @@ class LCMXO2Primer:
|
||||
length = len(data)
|
||||
if (length > (self.__FLASH_PAGE_SIZE * self.__FLASH_NUM_PAGES)):
|
||||
raise LCMXO2PrimerException('FPGA data size too big')
|
||||
if ((length % self.__FLASH_PAGE_SIZE) != 0):
|
||||
raise LCMXO2PrimerException('FPGA data size not aligned to page size')
|
||||
|
||||
self.__cmd_execute(self.__CMD_ENABLE_FLASH)
|
||||
|
||||
|
@ -460,7 +460,13 @@ class SC64:
|
||||
def upload_bootloader(self, data: bytes) -> None:
|
||||
if (len(data) > self.__Length.BOOTLOADER):
|
||||
raise ValueError('Bootloader size too big')
|
||||
self.__program_flash(self.__Address.BOOTLOADER, data)
|
||||
padded_data = data + (b'\xFF' * (self.__Length.BOOTLOADER - len(data)))
|
||||
if (self.__read_memory(self.__Address.BOOTLOADER, self.__Length.BOOTLOADER) != padded_data):
|
||||
self.__erase_flash_region(self.__Address.BOOTLOADER, self.__Length.BOOTLOADER)
|
||||
self.__write_memory(self.__Address.BOOTLOADER, data)
|
||||
self.__flash_wait_busy()
|
||||
if (self.__read_memory(self.__Address.BOOTLOADER, self.__Length.BOOTLOADER) != padded_data):
|
||||
raise ConnectionException('Bootloader program failure')
|
||||
|
||||
def set_rtc(self, t: datetime) -> None:
|
||||
to_bcd = lambda v: ((int((v / 10) % 10) << 4) | int(int(v) % 10))
|
||||
@ -739,7 +745,7 @@ if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='SC64 control software')
|
||||
parser.add_argument('--backup-firmware', metavar='file', help='backup SC64 firmware and write it to specified file')
|
||||
parser.add_argument('--update-firmware', metavar='file', help='update SC64 firmware from specified file')
|
||||
parser.add_argument('--bootloader', metavar='file', help='update SC64 bootloader (not recommended, use --update-firmware instead)')
|
||||
parser.add_argument('--update-bootloader', metavar='file', help='update SC64 bootloader (not recommended, use --update-firmware instead)')
|
||||
parser.add_argument('--reset-state', action='store_true', help='reset SC64 internal state')
|
||||
parser.add_argument('--print-state', action='store_true', help='print SC64 internal state')
|
||||
parser.add_argument('--boot', type=SC64.BootMode, action=EnumAction, help='set boot mode')
|
||||
@ -779,8 +785,8 @@ if __name__ == '__main__':
|
||||
sc64.update_firmware(f.read(), status_callback)
|
||||
print('done')
|
||||
|
||||
if (args.bootloader):
|
||||
with open(args.bootloader, 'rb') as f:
|
||||
if (args.update_bootloader):
|
||||
with open(args.update_bootloader, 'rb') as f:
|
||||
print('Uploading Bootloader... ', end='', flush=True)
|
||||
sc64.upload_bootloader(f.read())
|
||||
print('done')
|
||||
|
Loading…
Reference in New Issue
Block a user