From 806ff5ec23ff89423adee3f966a9173b6348e2b1 Mon Sep 17 00:00:00 2001 From: Jiaxing Hu Date: Tue, 10 Nov 2026 16:41:08 +1300 Subject: [PATCH] Burn Image: write at the address the menu means, in any language MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Burn Image read the address from the menu's label: the text in parentheses, as in "boot (0x8000)". The full-firmware item is the other way round, "0x0 (完整固件)" in Chinese, so rkdeveloptool got "wl 完整固件 " and refused it ("Begin is invalid"). In English "0x0 (Full Firmware)" didn't match and the whole label went through, which rkdeveloptool happened to read as 0. Each menu item now carries its address as item data, and Burn Image and the custom-address field use that. The custom address is trimmed. Fixes #85 --- rkdeveloptool-gui/operations.py | 12 +++------ rkdeveloptool-gui/ui_panels.py | 7 ++--- rkdeveloptool-gui/ui_text_updates.py | 13 +++++++--- tests/smoke.py | 38 ++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 16 deletions(-) diff --git a/rkdeveloptool-gui/operations.py b/rkdeveloptool-gui/operations.py index b85690a..3b47b1c 100644 --- a/rkdeveloptool-gui/operations.py +++ b/rkdeveloptool-gui/operations.py @@ -25,7 +25,7 @@ PartitionPPTWorker, CommandWorker, RKFWPrepWorker, FileHashWorker, DecompressWorker, CallWorker ) -from .ui_text_updates import populate_address_combo +from .ui_text_updates import CUSTOM_ADDRESS, populate_address_combo def _is_sector_zero(address): @@ -1251,13 +1251,9 @@ def burn_image(gui): gui.show_message("Warning", "select_image_address", "Warning") return - address = gui.address_combo.currentText() - if gui.tr("custom_address") in address: - address = gui.custom_address.text() - else: - match = re.search(r'\((\S+)\)', address) - if match: - address = match.group(1) + address = gui.address_combo.currentData() + if address == CUSTOM_ADDRESS: + address = gui.custom_address.text().strip() if not address: gui.show_message("Warning", "select_image_address", "Warning") diff --git a/rkdeveloptool-gui/ui_panels.py b/rkdeveloptool-gui/ui_panels.py index a7d129c..08c452e 100644 --- a/rkdeveloptool-gui/ui_panels.py +++ b/rkdeveloptool-gui/ui_panels.py @@ -914,11 +914,8 @@ def create_log_panel(gui): def on_address_changed(gui): """Handle address combo change""" - text = gui.address_combo.currentText() - if gui.tr("custom_address") in text: - gui.custom_address.setEnabled(True) - else: - gui.custom_address.setEnabled(False) + from .ui_text_updates import CUSTOM_ADDRESS + gui.custom_address.setEnabled(gui.address_combo.currentData() == CUSTOM_ADDRESS) def change_storage(gui): diff --git a/rkdeveloptool-gui/ui_text_updates.py b/rkdeveloptool-gui/ui_text_updates.py index 0bb7128..6f9587d 100644 --- a/rkdeveloptool-gui/ui_text_updates.py +++ b/rkdeveloptool-gui/ui_text_updates.py @@ -295,6 +295,10 @@ def update_statusbar_texts(gui): gui.update_device_status() +# Item data of the address combo's "custom address" entry. +CUSTOM_ADDRESS = "custom" + + def populate_address_combo(gui): """Populate address combo box in download tab. @@ -305,14 +309,17 @@ def populate_address_combo(gui): try: current_idx = gui.address_combo.currentIndex() gui.address_combo.clear() - gui.address_combo.addItem(gui.tr("address_full_firmware")) - gui.address_combo.addItem(gui.tr("custom_address")) + # Each item carries its address as data: the labels differ by + # language, and parsing them sent "完整固件" to rkdeveloptool as the + # address (#85). + gui.address_combo.addItem(gui.tr("address_full_firmware"), "0x0") + gui.address_combo.addItem(gui.tr("custom_address"), CUSTOM_ADDRESS) # Add parsed partitions if available if hasattr(gui, 'partitions') and gui.partitions: for name, info in gui.partitions.items(): addr = info.get('address', '') - gui.address_combo.addItem(f"{name} ({addr})") + gui.address_combo.addItem(f"{name} ({addr})", addr) if 0 <= current_idx < gui.address_combo.count(): gui.address_combo.setCurrentIndex(current_idx) diff --git a/tests/smoke.py b/tests/smoke.py index 8192df3..d97e27c 100644 --- a/tests/smoke.py +++ b/tests/smoke.py @@ -3160,6 +3160,43 @@ def check_theme_poll(app): app.processEvents() +def check_burn_address(app): + """Burn Image writes at the address the combo means, in every language. + The Chinese full-firmware label "0x0 (完整固件)" was parsed as the + address "完整固件" (#85).""" + from rkdeveloptool_gui import operations as ops + from rkdeveloptool_gui.ui_text_updates import populate_address_combo + + work = tempfile.mkdtemp(dir=_tmp) + image = os.path.join(work, "disk.img") + with open(image, "wb") as f: + f.write(b"\0" * 510 + b"\x55\xaa" + b"\0" * 1536) + got, real = [], ops._burn_file + ops._burn_file = lambda gui, path, address, build: got.append(address) + try: + for lang in ("zh", "en"): + window = RKDevToolGUI(TranslationManager(lang=lang, settings=AppSettings()), + settings=AppSettings()) + window.stop_device_detection() + window.partitions = {"boot": {"address": "0x8000"}} + populate_address_combo(window) + window.image_path.setText(image) + window.custom_address.setText(" 0x4000 ") + got.clear() + for index in range(3): + window.address_combo.setCurrentIndex(index) + ops.burn_image(window) + if got != ["0x0", "0x4000", "0x8000"]: + errors.append(f"Burn Image addresses in {lang}: {got}") + if window.custom_address.isEnabled(): + errors.append("the custom address field stays enabled for a partition") + window.cleanup() + window.deleteLater() + app.processEvents() + finally: + ops._burn_file = real + + def run_window(app, lang): settings = AppSettings() manager = TranslationManager(lang=lang, settings=settings) @@ -3206,6 +3243,7 @@ def main(): check_translations() check_qt_translation(app) + check_burn_address(app) check_theme_poll(app) check_partition_backup(app) check_first_run_wizard(app)