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 <glance@acc.umu.se>
This commit is contained in:
Jef Driesen 2021-05-24 22:59:32 +02:00
parent 14fd0296d4
commit fba5676b78

View File

@ -33,6 +33,10 @@
#define ISINSTANCE(device) dc_device_isinstance((device), &hw_ostc3_device_vtable) #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_DISPLAY 16
#define SZ_CUSTOMTEXT 60 #define SZ_CUSTOMTEXT 60
#define SZ_VERSION (SZ_CUSTOMTEXT + 4) #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 static dc_status_t
hw_ostc3_firmware_block_write (hw_ostc3_device_t *device, unsigned int address, const unsigned char data[], unsigned int size) hw_ostc3_firmware_block_write (hw_ostc3_device_t *device, unsigned int address, const unsigned char data[], unsigned int size)
{ {
if (device->firmware >= 0x0309) { // Support for the S_BLOCK_WRITE2 command is only available since the
return hw_ostc3_firmware_block_write2 (device, address, data, size); // hwOS Tech firmware v3.09 and the hwOS Sport firmware v10.64.
} else { 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); return hw_ostc3_firmware_block_write1 (device, address, data, size);
} else {
return hw_ostc3_firmware_block_write2 (device, address, data, size);
} }
} }