From 0cb7f4a7e767278aeadc6e596dfb4366602b2ebf Mon Sep 17 00:00:00 2001 From: Thomas Griffiths Date: Fri, 4 Sep 2026 15:08:00 +0100 Subject: [PATCH] splashasm: Add port option and bump version With the rp1 support, the port cannot be assumed as there are now multiple usable ports. Add in a port option, since this is a silently breaking change, bump version --- splashasm/README.md | 9 ++++++--- splashasm/splash_assembler.py | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/splashasm/README.md b/splashasm/README.md index 514ed44..6cd82d1 100644 --- a/splashasm/README.md +++ b/splashasm/README.md @@ -109,7 +109,7 @@ What are valid params for each instruction are better defined in the binary docs +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Protocol four cc | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size | Reserved | + | Size | Port | Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | : : Parameters : @@ -119,7 +119,11 @@ What are valid params for each instruction are better defined in the binary docs Protocol : A four cc code, currently either "SPI " or "I2C " Size : length in bytes of the parameters block that follows. This is unique to a four cc and file version - Reserved : three pad bytes (struct alignment after Size), always 0x00 + Port : Sets the output block we will be writing to, this + needs to be in agreement with the pins to get an + output. Not relevant for Pis earlier than the Pi 5 + Reserved : three pad bytes (struct alignment after Size), always + 0x00 Defines are implicitly numbered: the index used later by COMMAND's "Out idx" field is just the order in which DEFINE @@ -211,7 +215,6 @@ What are valid params for each instruction are better defined in the binary docs ## Limitations -- This is currently incompatible with the Pi 5 family - You can have a maximum of 4 SPI defines - You can have a maximum of 10 I2C defines - The delays are blocking and therefore a long splash description will slow down a boot diff --git a/splashasm/splash_assembler.py b/splashasm/splash_assembler.py index 8536905..a10d00d 100755 --- a/splashasm/splash_assembler.py +++ b/splashasm/splash_assembler.py @@ -59,12 +59,14 @@ class SPI_PARAMS(Enum): CPHA: Param = Param(default=1, allowed_values=(1, 2)) CSPOL: Param = Param(default=1, allowed_values=(1, 2)) FREQ: Param = Param(default=25000000) + PORT: Param = Param(default=0) class I2C_PARAMS(Enum): SDA: Param = Param(default=2, allowed_values=(2,)) SCL: Param = Param(default=3, allowed_values=(3,)) ADDR: Param = Param(default=0xFF) FREQ: Param = Param(default=100000) + PORT: Param = Param(default=1) class State: lines: str @@ -316,7 +318,7 @@ def _do_emit_binary(self, state, arr_ptr): print(f"Didn't specify nessercary param {p.name} in {self.__class__.__name__} on in file {self.file_name} on line {self.start_line}, defaulting to {p.value.default}") values[p.name] = p.value.default elif p.name in values.keys() and not p.value.check(values[p.name]): - raise ValueError(f"{p.name} cannot be set to {values[p.name]}, the only valid options are {", ".join(str(v) for v in p.value.allowed_values)}") + print(f"{p.name} set to {values[p.name]}, the options are {", ".join(str(v) for v in p.value.allowed_values)} are you sure?") elif p.name not in values.keys() and p.value.default is None: values[p.name] = 0xFF @@ -331,7 +333,8 @@ def _do_emit_binary(self, state, arr_ptr): packed += values["FREQ"].to_bytes(4, byteorder='little') arr_ptr.append(len(packed)) - arr_ptr.extend(b'\x00\x00\x00') # reserved (struct padding after param_len) + arr_ptr.append(values["PORT"] & 0xff) + arr_ptr.extend(b'\x00\x00') # reserved (struct padding after param_len) arr_ptr.extend(packed) class Delay(Instruction): @@ -593,7 +596,7 @@ def pretty_print(data): def make_file(input_file): buf = bytearray() buf.extend(MAGIC) # magic - buf.append(1) # version + buf.append(2) # version buf.extend(compile_file(input_file))