Skip to content

Commit

Permalink
fix command offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
dexter93 committed Sep 7, 2024
1 parent f9670dd commit 6b011f6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sonixflasher.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ bool protocol_init(hid_device *dev, bool oem_reboot, char *oem_option) {
clear_buffer(buf, REPORT_SIZE);
buf[0] = CMD_GET_FW_VERSION;
write_buffer_16(buf + 1, CMD_BASE);
write_buffer_16(buf + 3, code_option);
write_buffer_16(buf + 4, code_option);
uint8_t attempt_no = 1;
while (!hid_set_feature(dev, buf, REPORT_SIZE) && attempt_no <= MAX_ATTEMPTS) // Try {MAX ATTEMPTS} to init flash.
{
Expand All @@ -409,7 +409,7 @@ bool protocol_init(hid_device *dev, bool oem_reboot, char *oem_option) {
if (oem_reboot && reboot_fail) {
fprintf(stderr, "ERROR: Failed to initialize: response cmd is 0x%08x, expected 0x%08x.\n", resp, 0);
} else
fprintf(stderr, "ERROR: Failed to initialize: response cmd is 0x%08x, expected 0x%08x.\n", resp, CMD_GET_FW_VERSION);
fprintf(stderr, "ERROR: Failed to initialize: response cmd is 0x%08x, expected 0x%08x.\n", resp, CMD_VERIFY(CMD_GET_FW_VERSION));
return false;
}
return true;
Expand All @@ -422,7 +422,7 @@ bool protocol_code_option_check(hid_device *dev) {
clear_buffer(buf, REPORT_SIZE);
buf[0] = CMD_COMPARE_CODE_OPTION;
write_buffer_16(buf + 1, CMD_BASE);
write_buffer_16(buf + 3, code_option);
write_buffer_16(buf + 4, code_option);
if (!hid_set_feature(dev, buf, REPORT_SIZE)) return false;
clear_buffer(buf, REPORT_SIZE);
return true;
Expand All @@ -435,8 +435,8 @@ bool protocol_reset_cs(hid_device *dev) {
clear_buffer(buf, REPORT_SIZE);
buf[0] = CMD_SET_ENCRYPTION_ALGO;
write_buffer_16(buf + 1, CMD_BASE);
write_buffer_16(buf + 3, code_option);
write_buffer_16(buf + 5, CS0); // WARNING THIS SETS CS0
write_buffer_16(buf + 4, code_option);
write_buffer_16(buf + 6, CS0); // WARNING THIS SETS CS0
if (!hid_set_feature(dev, buf, REPORT_SIZE)) return false;
if (!hid_get_feature(dev, buf, CMD_SET_ENCRYPTION_ALGO)) return false;
clear_buffer(buf, REPORT_SIZE);
Expand Down

0 comments on commit 6b011f6

Please sign in to comment.