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
This commit is contained in:
Brian S. Stephan 2024-01-03 12:24:05 -06:00
parent f2ed281053
commit 416157663d
Signed by: bss
GPG Key ID: 3DE06D3180895FCB
3 changed files with 6 additions and 6 deletions

View File

@ -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))
############

View File

@ -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:

View File

@ -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