From fba5676b78f14c7d6cb79b48f264e74fd12c1f28 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 24 May 2021 22:59:32 +0200 Subject: [PATCH] Fix the hwOS Sport firmware upgrade Support for the S_BLOCK_WRITE2 command is only available since the hwOS Tech firmware v3.09 and the hwOS Sport firmware v10.64. In commit 9e92381be48866f3f13a11e98d59962575bb5ad3 it was enabled for all firmware versions newer than v3.09, causing the firmware upgrade to fail for older hwOS Sport firmware versions. Reported-by: Anton Lundin --- src/hw_ostc3.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/hw_ostc3.c b/src/hw_ostc3.c index 3ed6bc7..119af09 100644 --- a/src/hw_ostc3.c +++ b/src/hw_ostc3.c @@ -33,6 +33,10 @@ #define ISINSTANCE(device) dc_device_isinstance((device), &hw_ostc3_device_vtable) +#define OSTC3FW(major,minor) ( \ + (((major) & 0xFF) << 8) | \ + ((minor) & 0xFF)) + #define SZ_DISPLAY 16 #define SZ_CUSTOMTEXT 60 #define SZ_VERSION (SZ_CUSTOMTEXT + 4) @@ -1282,10 +1286,13 @@ hw_ostc3_firmware_block_write2 (hw_ostc3_device_t *device, unsigned int address, static dc_status_t hw_ostc3_firmware_block_write (hw_ostc3_device_t *device, unsigned int address, const unsigned char data[], unsigned int size) { - if (device->firmware >= 0x0309) { - return hw_ostc3_firmware_block_write2 (device, address, data, size); - } else { + // Support for the S_BLOCK_WRITE2 command is only available since the + // hwOS Tech firmware v3.09 and the hwOS Sport firmware v10.64. + if ((device->firmware < OSTC3FW(3,9)) || + (device->firmware >= OSTC3FW(10,0) && device->firmware < OSTC3FW(10,64))) { return hw_ostc3_firmware_block_write1 (device, address, data, size); + } else { + return hw_ostc3_firmware_block_write2 (device, address, data, size); } }