refactor(gui,config): rename file path fields and split BIN selector

- Rename bit_path -> bootloader_bit_path for clarity
- Rename elf_path -> bootloader_elf_path for clarity
- Split single bin_path into bootloader_bin_path (flash) and
  firmware_bin_path (TFTP upload)
- Reorder Configuration panel: BIT -> ELF -> Bootloader BIN ->
  Firmware BIN
- Update display names with file extensions and context labels
- Update all step references (Step 2 flash, Step 3 bootloader,
  Step 4 TFTP) to use new field names
This commit is contained in:
Jeremy Shen
2026-06-09 16:58:45 +08:00
parent bd39023ba7
commit 5277c88e3d
3 changed files with 72 additions and 50 deletions
+10 -3
View File
@@ -13,9 +13,16 @@ serial_port: ""
serial_baudrate: 115200 serial_baudrate: 115200
# File paths (relative to config file directory) # File paths (relative to config file directory)
bin_path: ""
elf_path: "" # Bootloader files (Step 3: Load Bootloader)
bit_path: "" 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 settings
reboot_timeout: 30 reboot_timeout: 30
+12 -9
View File
@@ -20,9 +20,10 @@ DEFAULT_CONFIG: dict[str, Any] = {
"tftp_upload_name": "z7bin", "tftp_upload_name": "z7bin",
"serial_port": "", "serial_port": "",
"serial_baudrate": 115200, "serial_baudrate": 115200,
"bin_path": "", "bootloader_bit_path": "",
"elf_path": "", "bootloader_elf_path": "",
"bit_path": "", "bootloader_bin_path": "",
"firmware_bin_path": "",
"reboot_timeout": 30, "reboot_timeout": 30,
"ping_timeout": 5, "ping_timeout": 5,
"ping_count": 3, "ping_count": 3,
@@ -42,9 +43,10 @@ class Config:
tftp_upload_name: str = "z7bin" tftp_upload_name: str = "z7bin"
serial_port: str = "" serial_port: str = ""
serial_baudrate: int = 115200 serial_baudrate: int = 115200
bin_path: str = "" bootloader_bit_path: str = ""
elf_path: str = "" bootloader_elf_path: str = ""
bit_path: str = "" bootloader_bin_path: str = ""
firmware_bin_path: str = ""
reboot_timeout: int = 30 reboot_timeout: int = 30
ping_timeout: int = 5 ping_timeout: int = 5
ping_count: int = 3 ping_count: int = 3
@@ -142,9 +144,10 @@ class Config:
"tftp_upload_name": self.tftp_upload_name, "tftp_upload_name": self.tftp_upload_name,
"serial_port": self.serial_port, "serial_port": self.serial_port,
"serial_baudrate": self.serial_baudrate, "serial_baudrate": self.serial_baudrate,
"bin_path": self._relative_path(self.bin_path), "bootloader_bit_path": self._relative_path(self.bootloader_bit_path),
"elf_path": self._relative_path(self.elf_path), "bootloader_elf_path": self._relative_path(self.bootloader_elf_path),
"bit_path": self._relative_path(self.bit_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, "reboot_timeout": self.reboot_timeout,
"ping_timeout": self.ping_timeout, "ping_timeout": self.ping_timeout,
"ping_count": self.ping_count, "ping_count": self.ping_count,
+50 -38
View File
@@ -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 = 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) self._ip_entry.grid(row=0, column=1, sticky="nsew", padx=PADDING_SMALL)
# BIN path # BIT path (Bootloader)
self._bin_selector = FileSelector( self._bit_selector = FileSelector(
panel, panel,
label_text="BIN File:", label_text="Bootloader BIT (.bit):",
file_types=[("BIN files", "*.bin"), ("All files", "*")], file_types=[("BIT files", "*.bit"), ("All files", "*")],
) )
if self._config.bin_path: if self._config.bootloader_bit_path:
resolved = self._config.resolve_path(self._config.bin_path) resolved = self._config.resolve_path(self._config.bootloader_bit_path)
self._bin_selector.set_path(str(resolved)) self._bit_selector.set_path(str(resolved))
self._bin_selector.grid(row=2, column=0, sticky="nsew", padx=PADDING, pady=PADDING_SMALL) self._bit_selector.grid(row=2, column=0, sticky="nsew", padx=PADDING, pady=PADDING_SMALL)
# ELF path # ELF path (Bootloader)
self._elf_selector = FileSelector( self._elf_selector = FileSelector(
panel, panel,
label_text="ELF File:", label_text="Bootloader ELF (.elf):",
file_types=[("ELF files", "*.elf"), ("All files", "*")], file_types=[("ELF files", "*.elf"), ("All files", "*")],
) )
if self._config.elf_path: if self._config.bootloader_elf_path:
resolved = self._config.resolve_path(self._config.elf_path) resolved = self._config.resolve_path(self._config.bootloader_elf_path)
self._elf_selector.set_path(str(resolved)) self._elf_selector.set_path(str(resolved))
self._elf_selector.grid(row=3, column=0, sticky="nsew", padx=PADDING, pady=PADDING_SMALL) self._elf_selector.grid(row=3, column=0, sticky="nsew", padx=PADDING, pady=PADDING_SMALL)
# BIT path # Bootloader BIN path (Flash programming)
self._bit_selector = FileSelector( self._bootloader_bin_selector = FileSelector(
panel, panel,
label_text="BIT File:", label_text="Bootloader BIN (.bin):",
file_types=[("BIT files", "*.bit"), ("All files", "*")], file_types=[("BIN files", "*.bin"), ("All files", "*")],
) )
if self._config.bit_path: if self._config.bootloader_bin_path:
resolved = self._config.resolve_path(self._config.bit_path) resolved = self._config.resolve_path(self._config.bootloader_bin_path)
self._bit_selector.set_path(str(resolved)) self._bootloader_bin_selector.set_path(str(resolved))
self._bit_selector.grid(row=4, column=0, sticky="nsew", padx=PADDING, pady=PADDING_SMALL) 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 button
save_btn = ctk.CTkButton( save_btn = ctk.CTkButton(
@@ -448,12 +459,13 @@ class MainWindow(ctk.CTk):
"""Get selected file paths from the UI. """Get selected file paths from the UI.
Returns: Returns:
Dictionary with bin_path, elf_path, bit_path. Dictionary with bootloader_bit_path, bootloader_elf_path, bootloader_bin_path, firmware_bin_path.
""" """
return { return {
"bin_path": self._bin_selector.get_path(), "bootloader_bit_path": self._bit_selector.get_path(),
"elf_path": self._elf_selector.get_path(), "bootloader_elf_path": self._elf_selector.get_path(),
"bit_path": self._bit_selector.get_path(), "bootloader_bin_path": self._bootloader_bin_selector.get_path(),
"firmware_bin_path": self._firmware_bin_selector.get_path(),
} }
# ── Step Implementations ─────────────────────────────────── # ── Step Implementations ───────────────────────────────────
@@ -503,14 +515,14 @@ class MainWindow(ctk.CTk):
return False return False
files = self._get_selected_files() files = self._get_selected_files()
if not files["bin_path"]: if not files["bootloader_bin_path"]:
self._log_message(" No BIN file selected") self._log_message(" No Bootloader BIN file selected")
return False 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: 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) results = full_flash_program(self._config, bin_path, self._flash_callback)
for result in results: for result in results:
@@ -532,18 +544,18 @@ class MainWindow(ctk.CTk):
return False return False
files = self._get_selected_files() files = self._get_selected_files()
if not files["bit_path"]: if not files["bootloader_bit_path"]:
self._log_message(" No BIT file selected") self._log_message(" No Bootloader BIT file selected")
return False return False
self._log_message(f"Step 3: Loading bootloader (BIT + ELF)...") self._log_message(f"Step 3: Loading bootloader (BIT + ELF)...")
self._log_message(f" BIT: {files['bit_path']}") self._log_message(f" BIT: {files['bootloader_bit_path']}")
if files["elf_path"]: if files["bootloader_elf_path"]:
self._log_message(f" ELF: {files['elf_path']}") self._log_message(f" ELF: {files['bootloader_elf_path']}")
try: try:
bit_path = Path(files["bit_path"]) bit_path = Path(files["bootloader_bit_path"])
elf_path = Path(files["elf_path"]) if files["elf_path"] else bit_path.parent / "temp.elf" elf_path = Path(files["bootloader_elf_path"]) if files["bootloader_elf_path"] else bit_path.parent / "temp.elf"
results = full_bitstream_program( results = full_bitstream_program(
self._config, bit_path, elf_path, self._config, bit_path, elf_path,
@@ -569,8 +581,8 @@ class MainWindow(ctk.CTk):
return False return False
files = self._get_selected_files() files = self._get_selected_files()
if not files["bin_path"]: if not files["firmware_bin_path"]:
self._log_message(" No BIN file selected") self._log_message(" No Firmware BIN file selected")
return False return False
all_results: list[bool] = [] all_results: list[bool] = []
@@ -578,7 +590,7 @@ class MainWindow(ctk.CTk):
# 4a: TFTP upload # 4a: TFTP upload
self._log_message("Step 4a: TFTP upload & verify...") self._log_message("Step 4a: TFTP upload & verify...")
try: try:
bin_path = Path(files["bin_path"]) bin_path = Path(files["firmware_bin_path"])
tftp_result = tftp_upload_verify( tftp_result = tftp_upload_verify(
self._config, bin_path, self._config, bin_path,
callback=self._tftp_callback, callback=self._tftp_callback,