Skip to content

Commit

Permalink
add sonix reboot option
Browse files Browse the repository at this point in the history
  • Loading branch information
dexter93 committed Sep 14, 2024
1 parent 1f9341c commit f83799c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ make sonixflasher
- `--offset -o` Set flashing offset (default: 0).
- `--file -f` Binary of the firmware to flash (*.bin extension).
- `--jumploader -j` Define if flashing a jumploader.
- `--reboot -r` Request bootloader reboot in OEM firmware (options: evision, hfd).
- `--reboot -r` Request bootloader reboot in OEM firmware (options: sonix, evision, hfd).
- `--debug -d` Enable debug mode.
- `--list-vidpid -l` Display supported VID/PID pairs.
- `--nooffset -k` Disable offset checks.
Expand Down
14 changes: 7 additions & 7 deletions sonixflasher.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static void print_usage(char *m_name) {
" --offset -o Set flashing offset (default: 0)\n"
" --file -f Binary of the firmware to flash (*.bin extension) \n"
" --jumploader -j Define if we are flashing a jumploader \n"
" --reboot -r Request bootloader reboot in OEM firmware (options: evision, hfd) \n"
" --reboot -r Request bootloader reboot in OEM firmware (options: sonix, evision, hfd) \n"
" --debug -d Enable debug mode \n"
" --nooffset -k Disable offset checks \n"
" --list-vidpid -l Display supported VID/PID pairs \n"
Expand Down Expand Up @@ -469,15 +469,15 @@ bool send_magic_command(hid_device *dev, const uint32_t *command) {
}

bool reboot_to_bootloader(hid_device *dev, char *oem_option) {
uint32_t evision_reboot[2] = {0x5AA555AA, 0xCC3300FF};
uint32_t hfd_reboot[2] = {0x5A8942AA, 0xCC6271FF};
uint32_t sonix_reboot[2] = {0x5AA555AA, 0xCC3300FF};
uint32_t hfd_reboot[2] = {0x5A8942AA, 0xCC6271FF};

if (oem_option == NULL) {
printf("ERROR: reboot option cannot be null.\n");
return false;
}
if (strcmp(oem_option, "evision") == 0) {
return send_magic_command(dev, evision_reboot);
if (strcmp(oem_option, "sonix") == 0 || strcmp(oem_option, "evision") == 0) {
return send_magic_command(dev, sonix_reboot);
} else if (strcmp(oem_option, "hfd") == 0) {
return send_magic_command(dev, hfd_reboot);
}
Expand All @@ -493,9 +493,9 @@ bool protocol_init(hid_device *dev, bool oem_reboot, char *oem_option) {
if (oem_reboot) {
printf("Requesting bootloader reboot...\n");
if (reboot_to_bootloader(dev, oem_option))
printf("Bootloader reboot succesfull.\n");
printf("Bootloader reboot request success.\n");
else {
printf("ERROR: Bootloader reboot failed.\n");
printf("ERROR: Bootloader reboot request failed.\n");
return false;
}
}
Expand Down

0 comments on commit f83799c

Please sign in to comment.