From 416157663d76b57ce44e13d3e356b13206df63ec Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Wed, 3 Jan 2024 12:24:05 -0600 Subject: [PATCH] STORAGE_BOOTSEL_ADDRESS is a better name than _MEMORY_ this is also just a different addressing mode with the same binary offset from the start, so derive it from the binary location --- gp2040ce_bintools/builder.py | 4 ++-- gp2040ce_bintools/gui.py | 4 ++-- gp2040ce_bintools/storage.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gp2040ce_bintools/builder.py b/gp2040ce_bintools/builder.py index 11dfdc8..7daca37 100644 --- a/gp2040ce_bintools/builder.py +++ b/gp2040ce_bintools/builder.py @@ -11,7 +11,7 @@ from google.protobuf.message import Message from gp2040ce_bintools import core_parser from gp2040ce_bintools.rp2040 import get_bootsel_endpoints, read, write -from gp2040ce_bintools.storage import (STORAGE_BINARY_LOCATION, STORAGE_MEMORY_ADDRESS, STORAGE_SIZE, +from gp2040ce_bintools.storage import (STORAGE_BINARY_LOCATION, STORAGE_BOOTSEL_ADDRESS, STORAGE_SIZE, pad_config_to_storage_size, serialize_config_with_footer) logger = logging.getLogger(__name__) @@ -168,7 +168,7 @@ def write_new_config_to_usb(config: Message, endpoint_out: object, endpoint_in: logger.debug("length: %s with %s bytes of padding", len(serialized), padding) binary = bytearray(b'\x00' * padding) + serialized logger.debug("binary for writing: %s", binary) - write(endpoint_out, endpoint_in, STORAGE_MEMORY_ADDRESS + (STORAGE_SIZE - len(binary)), bytes(binary)) + write(endpoint_out, endpoint_in, STORAGE_BOOTSEL_ADDRESS + (STORAGE_SIZE - len(binary)), bytes(binary)) ############ diff --git a/gp2040ce_bintools/gui.py b/gp2040ce_bintools/gui.py index 873a442..8e4368e 100644 --- a/gp2040ce_bintools/gui.py +++ b/gp2040ce_bintools/gui.py @@ -22,7 +22,7 @@ from textual.widgets.tree import TreeNode from gp2040ce_bintools import core_parser, handler from gp2040ce_bintools.builder import write_new_config_to_filename, write_new_config_to_usb from gp2040ce_bintools.rp2040 import get_bootsel_endpoints, read -from gp2040ce_bintools.storage import (STORAGE_MEMORY_ADDRESS, STORAGE_SIZE, ConfigReadError, get_config, +from gp2040ce_bintools.storage import (STORAGE_BOOTSEL_ADDRESS, STORAGE_SIZE, ConfigReadError, get_config, get_config_from_file, get_new_config) logger = logging.getLogger(__name__) @@ -324,7 +324,7 @@ class ConfigEditor(App): if self.usb: try: self.endpoint_out, self.endpoint_in = get_bootsel_endpoints() - config_binary = read(self.endpoint_out, self.endpoint_in, STORAGE_MEMORY_ADDRESS, STORAGE_SIZE) + config_binary = read(self.endpoint_out, self.endpoint_in, STORAGE_BOOTSEL_ADDRESS, STORAGE_SIZE) self.config = get_config(bytes(config_binary)) except ConfigReadError: if self.create_new: diff --git a/gp2040ce_bintools/storage.py b/gp2040ce_bintools/storage.py index 314a666..b345516 100644 --- a/gp2040ce_bintools/storage.py +++ b/gp2040ce_bintools/storage.py @@ -17,7 +17,7 @@ from gp2040ce_bintools.rp2040 import get_bootsel_endpoints, read logger = logging.getLogger(__name__) STORAGE_BINARY_LOCATION = 0x1FC000 -STORAGE_MEMORY_ADDRESS = 0x101FC000 +STORAGE_BOOTSEL_ADDRESS = 0x10000000 + STORAGE_BINARY_LOCATION STORAGE_SIZE = 16384 FOOTER_SIZE = 12 @@ -158,7 +158,7 @@ def get_config_from_usb() -> tuple[Message, object, object]: endpoint_out, endpoint_in = get_bootsel_endpoints() logger.debug("reading DEVICE ID %s:%s, bus %s, address %s", hex(endpoint_out.device.idVendor), hex(endpoint_out.device.idProduct), endpoint_out.device.bus, endpoint_out.device.address) - storage = read(endpoint_out, endpoint_in, STORAGE_MEMORY_ADDRESS, STORAGE_SIZE) + storage = read(endpoint_out, endpoint_in, STORAGE_BOOTSEL_ADDRESS, STORAGE_SIZE) return get_config(bytes(storage)), endpoint_out, endpoint_in