s/pad_firmware_up_to_storage/pad_binary_up_to_user_config/
this is just to clarify the purpose of this since a related method is coming soon for the board config Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
This commit is contained in:
parent
1d912794c2
commit
8681a18d26
@ -41,7 +41,7 @@ def combine_firmware_and_config(firmware_binary: bytearray, config_binary: bytea
|
|||||||
Returns:
|
Returns:
|
||||||
the resulting correctly-offset binary suitable for a GP2040-CE board
|
the resulting correctly-offset binary suitable for a GP2040-CE board
|
||||||
"""
|
"""
|
||||||
return (pad_firmware_up_to_storage(firmware_binary, or_truncate=replace_extra) +
|
return (pad_binary_up_to_user_config(firmware_binary, or_truncate=replace_extra) +
|
||||||
pad_config_to_storage_size(config_binary))
|
pad_config_to_storage_size(config_binary))
|
||||||
|
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ def get_gp2040ce_from_usb() -> tuple[bytes, object, object]:
|
|||||||
return content, endpoint_out, endpoint_in
|
return content, endpoint_out, endpoint_in
|
||||||
|
|
||||||
|
|
||||||
def pad_firmware_up_to_storage(firmware: bytes, or_truncate: bool = False) -> bytearray:
|
def pad_binary_up_to_user_config(firmware: bytes, or_truncate: bool = False) -> bytearray:
|
||||||
"""Provide a copy of the firmware padded with zero bytes up to the provided position.
|
"""Provide a copy of the firmware padded with zero bytes up to the provided position.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -13,7 +13,7 @@ from decorator import decorator
|
|||||||
from gp2040ce_bintools import get_config_pb2
|
from gp2040ce_bintools import get_config_pb2
|
||||||
from gp2040ce_bintools.builder import (FirmwareLengthError, combine_firmware_and_config,
|
from gp2040ce_bintools.builder import (FirmwareLengthError, combine_firmware_and_config,
|
||||||
concatenate_firmware_and_storage_files, get_gp2040ce_from_usb,
|
concatenate_firmware_and_storage_files, get_gp2040ce_from_usb,
|
||||||
pad_firmware_up_to_storage, replace_config_in_binary,
|
pad_binary_up_to_user_config, replace_config_in_binary,
|
||||||
write_new_config_to_filename, write_new_config_to_usb)
|
write_new_config_to_filename, write_new_config_to_usb)
|
||||||
from gp2040ce_bintools.storage import get_config, get_config_footer, get_storage_section, serialize_config_with_footer
|
from gp2040ce_bintools.storage import get_config, get_config_footer, get_storage_section, serialize_config_with_footer
|
||||||
|
|
||||||
@ -79,13 +79,13 @@ def test_concatenate_to_usb(tmp_path):
|
|||||||
|
|
||||||
def test_padding_firmware(firmware_binary):
|
def test_padding_firmware(firmware_binary):
|
||||||
"""Test that firmware is padded to the expected size."""
|
"""Test that firmware is padded to the expected size."""
|
||||||
padded = pad_firmware_up_to_storage(firmware_binary)
|
padded = pad_binary_up_to_user_config(firmware_binary)
|
||||||
assert len(padded) == 2080768
|
assert len(padded) == 2080768
|
||||||
|
|
||||||
|
|
||||||
def test_padding_firmware_can_truncate():
|
def test_padding_firmware_can_truncate():
|
||||||
"""Test that firmware is padded to the expected size."""
|
"""Test that firmware is padded to the expected size."""
|
||||||
padded = pad_firmware_up_to_storage(bytearray(b'\x00' * 4 * 1024 * 1024), or_truncate=True)
|
padded = pad_binary_up_to_user_config(bytearray(b'\x00' * 4 * 1024 * 1024), or_truncate=True)
|
||||||
assert len(padded) == 2080768
|
assert len(padded) == 2080768
|
||||||
|
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ def test_replace_config_in_binary_not_big_enough(config_binary):
|
|||||||
def test_padding_firmware_too_big(firmware_binary):
|
def test_padding_firmware_too_big(firmware_binary):
|
||||||
"""Test that firmware is padded to the expected size."""
|
"""Test that firmware is padded to the expected size."""
|
||||||
with pytest.raises(FirmwareLengthError):
|
with pytest.raises(FirmwareLengthError):
|
||||||
_ = pad_firmware_up_to_storage(firmware_binary + firmware_binary + firmware_binary)
|
_ = pad_binary_up_to_user_config(firmware_binary + firmware_binary + firmware_binary)
|
||||||
|
|
||||||
|
|
||||||
@with_pb2s
|
@with_pb2s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user