diff --git a/config/default_config.yaml b/config/default_config.yaml index 1ec5202..c9f4307 100644 --- a/config/default_config.yaml +++ b/config/default_config.yaml @@ -13,9 +13,16 @@ serial_port: "" serial_baudrate: 115200 # File paths (relative to config file directory) -bin_path: "" -elf_path: "" -bit_path: "" + +# Bootloader files (Step 3: Load Bootloader) +bootloader_bit_path: "" +bootloader_elf_path: "" + +# Flash programming (Step 2: Program & Verify Flash) +bootloader_bin_path: "" + +# Firmware upload (Step 4: Load Main Program via TFTP) +firmware_bin_path: "" # Reboot settings reboot_timeout: 30 diff --git a/src/config_manager.py b/src/config_manager.py index 72cfd2b..73941cd 100644 --- a/src/config_manager.py +++ b/src/config_manager.py @@ -20,9 +20,10 @@ DEFAULT_CONFIG: dict[str, Any] = { "tftp_upload_name": "z7bin", "serial_port": "", "serial_baudrate": 115200, - "bin_path": "", - "elf_path": "", - "bit_path": "", + "bootloader_bit_path": "", + "bootloader_elf_path": "", + "bootloader_bin_path": "", + "firmware_bin_path": "", "reboot_timeout": 30, "ping_timeout": 5, "ping_count": 3, @@ -42,9 +43,10 @@ class Config: tftp_upload_name: str = "z7bin" serial_port: str = "" serial_baudrate: int = 115200 - bin_path: str = "" - elf_path: str = "" - bit_path: str = "" + bootloader_bit_path: str = "" + bootloader_elf_path: str = "" + bootloader_bin_path: str = "" + firmware_bin_path: str = "" reboot_timeout: int = 30 ping_timeout: int = 5 ping_count: int = 3 @@ -142,9 +144,10 @@ class Config: "tftp_upload_name": self.tftp_upload_name, "serial_port": self.serial_port, "serial_baudrate": self.serial_baudrate, - "bin_path": self._relative_path(self.bin_path), - "elf_path": self._relative_path(self.elf_path), - "bit_path": self._relative_path(self.bit_path), + "bootloader_bit_path": self._relative_path(self.bootloader_bit_path), + "bootloader_elf_path": self._relative_path(self.bootloader_elf_path), + "bootloader_bin_path": self._relative_path(self.bootloader_bin_path), + "firmware_bin_path": self._relative_path(self.firmware_bin_path), "reboot_timeout": self.reboot_timeout, "ping_timeout": self.ping_timeout, "ping_count": self.ping_count, diff --git a/src/gui/main_window.py b/src/gui/main_window.py index 5d8d55d..3c5e54b 100644 --- a/src/gui/main_window.py +++ b/src/gui/main_window.py @@ -325,38 +325,49 @@ class MainWindow(ctk.CTk): self._ip_entry = ctk.CTkEntry(ip_frame, textvariable=ctk.StringVar(value=self._config.zynq_ip)) self._ip_entry.grid(row=0, column=1, sticky="nsew", padx=PADDING_SMALL) - # BIN path - self._bin_selector = FileSelector( + # BIT path (Bootloader) + self._bit_selector = FileSelector( panel, - label_text="BIN File:", - file_types=[("BIN files", "*.bin"), ("All files", "*")], + label_text="Bootloader BIT (.bit):", + file_types=[("BIT files", "*.bit"), ("All files", "*")], ) - if self._config.bin_path: - resolved = self._config.resolve_path(self._config.bin_path) - self._bin_selector.set_path(str(resolved)) - self._bin_selector.grid(row=2, column=0, sticky="nsew", padx=PADDING, pady=PADDING_SMALL) + if self._config.bootloader_bit_path: + resolved = self._config.resolve_path(self._config.bootloader_bit_path) + self._bit_selector.set_path(str(resolved)) + self._bit_selector.grid(row=2, column=0, sticky="nsew", padx=PADDING, pady=PADDING_SMALL) - # ELF path + # ELF path (Bootloader) self._elf_selector = FileSelector( panel, - label_text="ELF File:", + label_text="Bootloader ELF (.elf):", file_types=[("ELF files", "*.elf"), ("All files", "*")], ) - if self._config.elf_path: - resolved = self._config.resolve_path(self._config.elf_path) + if self._config.bootloader_elf_path: + resolved = self._config.resolve_path(self._config.bootloader_elf_path) self._elf_selector.set_path(str(resolved)) self._elf_selector.grid(row=3, column=0, sticky="nsew", padx=PADDING, pady=PADDING_SMALL) - # BIT path - self._bit_selector = FileSelector( + # Bootloader BIN path (Flash programming) + self._bootloader_bin_selector = FileSelector( panel, - label_text="BIT File:", - file_types=[("BIT files", "*.bit"), ("All files", "*")], + label_text="Bootloader BIN (.bin):", + file_types=[("BIN files", "*.bin"), ("All files", "*")], ) - if self._config.bit_path: - resolved = self._config.resolve_path(self._config.bit_path) - self._bit_selector.set_path(str(resolved)) - self._bit_selector.grid(row=4, column=0, sticky="nsew", padx=PADDING, pady=PADDING_SMALL) + if self._config.bootloader_bin_path: + resolved = self._config.resolve_path(self._config.bootloader_bin_path) + self._bootloader_bin_selector.set_path(str(resolved)) + self._bootloader_bin_selector.grid(row=4, column=0, sticky="nsew", padx=PADDING, pady=PADDING_SMALL) + + # Firmware BIN path (TFTP upload) + self._firmware_bin_selector = FileSelector( + panel, + label_text="Firmware BIN (.bin):", + file_types=[("BIN files", "*.bin"), ("All files", "*")], + ) + if self._config.firmware_bin_path: + resolved = self._config.resolve_path(self._config.firmware_bin_path) + self._firmware_bin_selector.set_path(str(resolved)) + self._firmware_bin_selector.grid(row=5, column=0, sticky="nsew", padx=PADDING, pady=PADDING_SMALL) # Save button save_btn = ctk.CTkButton( @@ -448,12 +459,13 @@ class MainWindow(ctk.CTk): """Get selected file paths from the UI. Returns: - Dictionary with bin_path, elf_path, bit_path. + Dictionary with bootloader_bit_path, bootloader_elf_path, bootloader_bin_path, firmware_bin_path. """ return { - "bin_path": self._bin_selector.get_path(), - "elf_path": self._elf_selector.get_path(), - "bit_path": self._bit_selector.get_path(), + "bootloader_bit_path": self._bit_selector.get_path(), + "bootloader_elf_path": self._elf_selector.get_path(), + "bootloader_bin_path": self._bootloader_bin_selector.get_path(), + "firmware_bin_path": self._firmware_bin_selector.get_path(), } # ── Step Implementations ─────────────────────────────────── @@ -503,14 +515,14 @@ class MainWindow(ctk.CTk): return False files = self._get_selected_files() - if not files["bin_path"]: - self._log_message(" No BIN file selected") + if not files["bootloader_bin_path"]: + self._log_message(" No Bootloader BIN file selected") return False - self._log_message(f"Step 2: Programming Flash with {files['bin_path']}...") + self._log_message(f"Step 2: Programming Flash with {files['bootloader_bin_path']}...") try: - bin_path = Path(files["bin_path"]) + bin_path = Path(files["bootloader_bin_path"]) results = full_flash_program(self._config, bin_path, self._flash_callback) for result in results: @@ -532,18 +544,18 @@ class MainWindow(ctk.CTk): return False files = self._get_selected_files() - if not files["bit_path"]: - self._log_message(" No BIT file selected") + if not files["bootloader_bit_path"]: + self._log_message(" No Bootloader BIT file selected") return False self._log_message(f"Step 3: Loading bootloader (BIT + ELF)...") - self._log_message(f" BIT: {files['bit_path']}") - if files["elf_path"]: - self._log_message(f" ELF: {files['elf_path']}") + self._log_message(f" BIT: {files['bootloader_bit_path']}") + if files["bootloader_elf_path"]: + self._log_message(f" ELF: {files['bootloader_elf_path']}") try: - bit_path = Path(files["bit_path"]) - elf_path = Path(files["elf_path"]) if files["elf_path"] else bit_path.parent / "temp.elf" + bit_path = Path(files["bootloader_bit_path"]) + elf_path = Path(files["bootloader_elf_path"]) if files["bootloader_elf_path"] else bit_path.parent / "temp.elf" results = full_bitstream_program( self._config, bit_path, elf_path, @@ -569,8 +581,8 @@ class MainWindow(ctk.CTk): return False files = self._get_selected_files() - if not files["bin_path"]: - self._log_message(" No BIN file selected") + if not files["firmware_bin_path"]: + self._log_message(" No Firmware BIN file selected") return False all_results: list[bool] = [] @@ -578,7 +590,7 @@ class MainWindow(ctk.CTk): # 4a: TFTP upload self._log_message("Step 4a: TFTP upload & verify...") try: - bin_path = Path(files["bin_path"]) + bin_path = Path(files["firmware_bin_path"]) tftp_result = tftp_upload_verify( self._config, bin_path, callback=self._tftp_callback,