Skip to content

Commit

Permalink
[SensorBHI260AP] Remove default firmware included in the build
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisxhe committed Jan 6, 2025
1 parent 0f1b88d commit c3acde2
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/SensorBHI260AP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ class SensorBHI260AP
* @param force_update: true, rewrite to flash or ram regardless of whether there is firmware, false, do not write if firmware is detected
* @retval None
*/
void setFirmware(const uint8_t *image, size_t image_len, bool write_flash, bool force_update = false)
void setFirmware(const uint8_t *image, size_t image_len, bool write_flash = false, bool force_update = false)
{
__firmware = image;
__firmware_size = image_len;
Expand Down Expand Up @@ -1091,28 +1091,38 @@ class SensorBHI260AP
log_d("Expected Host Interface Control (0x06) to have bit 0x%x to be set\r\n", BHY2_HIF_CTRL_ASYNC_STATUS_CHANNEL);
}

if (!__firmware) {
// Default write to ram
setFirmware(bhy2_firmware_image, sizeof(bhy2_firmware_image), false);
}
/*
if (!__firmware) {
// Default write to ram
setFirmware(bhy2_firmware_image, sizeof(bhy2_firmware_image), false);
}
*/

if (__boot_from_flash) {
if (!bootFromFlash() || __force_update) {
if (__force_update) {
log_i("Force update firmware.");
if (__force_update) {
if ((__firmware == NULL) || (__firmware_size == 0)) {
log_e("No valid firmware is set. Please use the \"setFirmware\" method to set the valid firmware.");
return false;
}
//** If the boot from flash fails, re-upload the firmware to flash
__error_code = bhy2_soft_reset(bhy2);
BHY2_RLST_CHECK(__error_code != BHY2_OK, "reset bhy2 failed!", false);

log_i("Force update firmware.");
if (!uploadFirmware(__firmware, __firmware_size, __write_flash)) {
log_e("uploadFirmware failed!");
return false;
}
}
if (!bootFromFlash()) {
return false;
}
} else {
if ((__firmware == NULL) || (__firmware_size == 0)) {
log_e("No valid firmware is set. Please use the \"setFirmware\" method to set the valid firmware.");
return false;
}

// ** Upload firmware to RAM
if (!uploadFirmware(__firmware, __firmware_size, __write_flash)) {
if (!uploadFirmware(__firmware, __firmware_size, false)) {
log_e("uploadFirmware failed!");
return false;
}
Expand Down

0 comments on commit c3acde2

Please sign in to comment.