Skip to content

Commit

Permalink
[SC64][SW] Adjusted primer.py script
Browse files Browse the repository at this point in the history
  • Loading branch information
Polprzewodnikowy committed Feb 17, 2023
1 parent ed6d01a commit 8a8bf66
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 33 deletions.
2 changes: 1 addition & 1 deletion docs/06_manufacturing_guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ Congratulations! Your SC64 flashcart should be ready for use!

*`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.
76 changes: 44 additions & 32 deletions sw/pc/primer.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,53 +422,61 @@ def load_update_data(self, path: str) -> None:
def get_update_info(self) -> str:
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
try:
link = serial.Serial(
port,
baudrate=self.__SERIAL_BAUD,
parity=serial.PARITY_EVEN,
timeout=self.__SERIAL_TIMEOUT,
write_timeout=self.__SERIAL_TIMEOUT
)

stm32_bootloader = STM32Bootloader(link.write, link.read, self.__progress)
lcmxo2_primer = LCMXO2Primer(link.write, link.read, self.__progress)

stm32_bootloader.connect(stm32_bootloader.DEV_ID_STM32G030XX)
stm32_bootloader.load_ram_and_run(self.__sc64_update_data.get_primer_data(), 'FPGA primer -> STM32 RAM')
time.sleep(self.__INTERVAL_TIME)
link.read_all()

lcmxo2_primer.connect(lcmxo2_primer.DEV_ID_LCMXO2_7000HC)
lcmxo2_primer.load_flash_and_run(self.__sc64_update_data.get_fpga_data(), 'FPGA configuration -> LCMXO2 FLASH')
time.sleep(self.__INTERVAL_TIME)
link.read_all()

stm32_bootloader.connect(stm32_bootloader.DEV_ID_STM32G030XX)
stm32_bootloader.load_flash_and_run(self.__sc64_update_data.get_mcu_data(), 'MCU software -> STM32 FLASH')
time.sleep(self.__INTERVAL_TIME)
link.read_all()

sc64 = SC64()
if (not only_bootloader):
link = serial.Serial(
port,
baudrate=self.__SERIAL_BAUD,
parity=serial.PARITY_EVEN,
timeout=self.__SERIAL_TIMEOUT,
write_timeout=self.__SERIAL_TIMEOUT
)

stm32_bootloader = STM32Bootloader(link.write, link.read, self.__progress)
lcmxo2_primer = LCMXO2Primer(link.write, link.read, self.__progress)

stm32_bootloader.connect(stm32_bootloader.DEV_ID_STM32G030XX)
stm32_bootloader.load_ram_and_run(self.__sc64_update_data.get_primer_data(), 'FPGA primer -> STM32 RAM')
time.sleep(self.__INTERVAL_TIME)
link.read_all()

lcmxo2_primer.connect(lcmxo2_primer.DEV_ID_LCMXO2_7000HC)
lcmxo2_primer.load_flash_and_run(self.__sc64_update_data.get_fpga_data(), 'FPGA configuration -> LCMXO2 FLASH')
time.sleep(self.__INTERVAL_TIME)
link.read_all()

stm32_bootloader.connect(stm32_bootloader.DEV_ID_STM32G030XX)
stm32_bootloader.load_flash_and_run(self.__sc64_update_data.get_mcu_data(), 'MCU software -> STM32 FLASH')
time.sleep(self.__INTERVAL_TIME)
link.read_all()

bootloader_description = 'Bootloader -> SC64 FLASH'
bootloader_data = self.__sc64_update_data.get_bootloader_data()
bootloader_length = len(bootloader_data)
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)
finally:
if (link and link.is_open):
link.close()


if __name__ == '__main__':
if (len(sys.argv) != 3):
Utils.die(f'Usage: {sys.argv[0]} serial_port update_file')
nargs = len(sys.argv)
if (nargs < 3 or nargs > 4):
Utils.die(f'Usage: {sys.argv[0]} serial_port update_file [--only-bootloader]')

port = sys.argv[1]
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()
sc64_bring_up = SC64BringUp(progress=utils.progress)

Expand All @@ -486,6 +494,10 @@ def start_bring_up(self, port: str) -> None:
Utils.log(sc64_bring_up.get_update_info())
Utils.log()

if (only_bootloader):
Utils.log('Running in "only bootloader" mode')
Utils.log()

Utils.warning('[ CAUTION ]')
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')
Expand All @@ -507,7 +519,7 @@ def start_bring_up(self, port: str) -> None:
original_sigint_handler = signal.getsignal(signal.SIGINT)
try:
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:
if (utils.get_progress_active):
Utils.log()
Expand Down

0 comments on commit 8a8bf66

Please sign in to comment.