[SC64][SW] Adjusted primer.py script

This commit is contained in:
Mateusz Faderewski 2023-02-17 12:03:26 +01:00
parent ed6d01a066
commit 8a8bf665f9
2 changed files with 40 additions and 28 deletions

View File

@ -97,4 +97,4 @@ Congratulations! Your SC64 flashcart should be ready for use!
*`primer.py` threw error on `Bootloader -> SC64 FLASH` step* *`primer.py` threw error on `Bootloader -> SC64 FLASH` step*
This issue can be attributed to incorrectly programmed FT232H EPPROM in first programming step. Check again in `FT_PROG` if device was configured properly. Once FPGA and microcontroller has been programmed successfully, `primer.py` script cannot be used again. Please use command `python3 sc64.py --update-firmware sc64_update_package.bin` to try programming bootloader again. This issue can be attributed to incorrectly programmed FT232H EEPROM in the first programming step. Check again in `FT_PROG` program if device was configured properly. Once FPGA and microcontroller has been programmed successfully `primer.py` script needs to be run in special mode. Please use command `python3 primer.py COMx sc64_update_package.bin --only-bootloader` to try programming bootloader again.

View File

@ -422,9 +422,10 @@ class SC64BringUp:
def get_update_info(self) -> str: def get_update_info(self) -> str:
return self.__sc64_update_data.get_update_info() return self.__sc64_update_data.get_update_info()
def start_bring_up(self, port: str) -> None: def start_bring_up(self, port: str, only_bootloader: bool=False) -> None:
link = None link = None
try: try:
if (not only_bootloader):
link = serial.Serial( link = serial.Serial(
port, port,
baudrate=self.__SERIAL_BAUD, baudrate=self.__SERIAL_BAUD,
@ -451,12 +452,11 @@ class SC64BringUp:
time.sleep(self.__INTERVAL_TIME) time.sleep(self.__INTERVAL_TIME)
link.read_all() link.read_all()
sc64 = SC64()
bootloader_description = 'Bootloader -> SC64 FLASH' bootloader_description = 'Bootloader -> SC64 FLASH'
bootloader_data = self.__sc64_update_data.get_bootloader_data() bootloader_data = self.__sc64_update_data.get_bootloader_data()
bootloader_length = len(bootloader_data) bootloader_length = len(bootloader_data)
self.__progress(bootloader_length, 0, bootloader_description) self.__progress(bootloader_length, 0, bootloader_description)
sc64.upload_bootloader(bootloader_data) SC64().upload_bootloader(bootloader_data)
self.__progress(bootloader_length, bootloader_length, bootloader_description) self.__progress(bootloader_length, bootloader_length, bootloader_description)
finally: finally:
if (link and link.is_open): if (link and link.is_open):
@ -464,11 +464,19 @@ class SC64BringUp:
if __name__ == '__main__': if __name__ == '__main__':
if (len(sys.argv) != 3): nargs = len(sys.argv)
Utils.die(f'Usage: {sys.argv[0]} serial_port update_file') if (nargs < 3 or nargs > 4):
Utils.die(f'Usage: {sys.argv[0]} serial_port update_file [--only-bootloader]')
port = sys.argv[1] port = sys.argv[1]
update_data_path = sys.argv[2] update_data_path = sys.argv[2]
only_bootloader = False
if (nargs == 4):
if (sys.argv[3] == '--only-bootloader'):
only_bootloader = True
else:
Utils.die(f'Unknown argument: {sys.argv[3]}')
utils = Utils() utils = Utils()
sc64_bring_up = SC64BringUp(progress=utils.progress) sc64_bring_up = SC64BringUp(progress=utils.progress)
@ -486,6 +494,10 @@ if __name__ == '__main__':
Utils.log(sc64_bring_up.get_update_info()) Utils.log(sc64_bring_up.get_update_info())
Utils.log() Utils.log()
if (only_bootloader):
Utils.log('Running in "only bootloader" mode')
Utils.log()
Utils.warning('[ CAUTION ]') Utils.warning('[ CAUTION ]')
Utils.warning('Configure FTDI chip with provided ft232h_config.xml before continuing') Utils.warning('Configure FTDI chip with provided ft232h_config.xml before continuing')
Utils.warning('Connect SC64 USB port to the same computer you\'re running this script') Utils.warning('Connect SC64 USB port to the same computer you\'re running this script')
@ -507,7 +519,7 @@ if __name__ == '__main__':
original_sigint_handler = signal.getsignal(signal.SIGINT) original_sigint_handler = signal.getsignal(signal.SIGINT)
try: try:
signal.signal(signal.SIGINT, lambda *kwargs: utils.exit_warning()) signal.signal(signal.SIGINT, lambda *kwargs: utils.exit_warning())
sc64_bring_up.start_bring_up(port) sc64_bring_up.start_bring_up(port, only_bootloader)
except (serial.SerialException, STM32BootloaderException, LCMXO2PrimerException) as e: except (serial.SerialException, STM32BootloaderException, LCMXO2PrimerException) as e:
if (utils.get_progress_active): if (utils.get_progress_active):
Utils.log() Utils.log()