Skip to content

Conversation

@mikeller
Copy link
Member

Fix the firmware upload sequence in the case of the OSTC4 being in the
Bootloader (e.g. no firmware installed, recovery from failed firmware
upload). The command 0x60 (HARDWARE2) results is buggy in the
bootloader, so we resort to trying 0x69 (HARDWARE) first.

Bootloader.

Fix the firmware upload sequence in the case of the OSTC4 being in the
Bootloader (e.g. no firmware installed, recovery from failed firmware
upload). The command 0x60 (HARDWARE2) results is buggy in the
bootloader, so we resort to trying 0x69 (HARDWARE) first.

Signed-off-by: Michael Keller <[email protected]>
@mikeller mikeller force-pushed the fix_hw_ostc4_bootloader_firmware_upload branch from d0128ce to 7aabd4b Compare April 18, 2025 09:58
@mikeller mikeller requested a review from Copilot April 20, 2025 07:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the firmware upload sequence for the OSTC4 bootloader situation by trying the HARDWARE command first and conditionally falling back to HARDWARE2 if the initial response indicates a non-OSTC4 device.

  • Prioritize sending the HARDWARE command to avoid a Bluetooth disconnect in bootloader mode.
  • Add logic to re-request HARDWARE2 data when the first two bytes do not match OSTC4 and adjust device initialization accordingly.
Comments suppressed due to low confidence (2)

src/hw_ostc3.c:491

  • Transferring the HARDWARE command response into 'hardware + 1' may leave the first byte uninitialized, which affects the subsequent call to array_uint16_be(hardware). Consider writing to the complete 'hardware' buffer if the protocol expects a full response.
status = hw_ostc3_transfer(device, NULL, HARDWARE, NULL, 0, hardware + 1, SZ_HARDWARE, NULL, NODELAY);

src/hw_ostc3.c:495

  • Since the HARDWARE command writes its response starting from hardware+1, the comparison using array_uint16_be(hardware) may not correctly reflect the intended hardware identifier. Verify that the correct offset is used when checking against OSTC4.
if (size == SZ_HARDWARE2 && array_uint16_be(hardware) != OSTC4) {

@mikeller mikeller merged commit 644b7d7 into subsurface:Subsurface-DS9 Apr 21, 2025
8 checks passed
@mikeller mikeller deleted the fix_hw_ostc4_bootloader_firmware_upload branch April 21, 2025 23:48
theCarlG pushed a commit to theCarlG/libdc that referenced this pull request Jul 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant