Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes from 1.2.1 #1873

Merged
merged 2 commits into from Aug 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion hal/src/core/ota_flash_hal.c
Expand Up @@ -69,12 +69,18 @@ int HAL_FLASH_OTA_Validate(hal_module_t* mod, bool userDepsOptional, module_vali
return 0;
}

hal_update_complete_t HAL_FLASH_ApplyPendingUpdate(hal_module_t* module, bool dryRun, void* reserved)
hal_update_complete_t HAL_FLASH_End(hal_module_t* reserved)
{
FLASH_End();
return HAL_UPDATE_APPLIED_PENDING_RESTART;
}

hal_update_complete_t HAL_FLASH_ApplyPendingUpdate(hal_module_t* module, bool dryRun, void* reserved)
{
// Not implemented for Core
return HAL_UPDATE_ERROR;
}

void HAL_FLASH_Read_ServerAddress(ServerAddress* server_addr)
{
uint8_t buf[EXTERNAL_FLASH_SERVER_DOMAIN_LENGTH];
Expand Down
7 changes: 6 additions & 1 deletion system/src/main.cpp
Expand Up @@ -767,7 +767,12 @@ void app_setup_and_loop(void)
bool threaded = system_thread_get_state(NULL) != spark::feature::DISABLED &&
(system_mode()!=SAFE_MODE);

if (HAL_FLASH_ApplyPendingUpdate(nullptr /*module*/, false /*dryRun*/, nullptr /*reserved*/)==HAL_UPDATE_APPLIED_PENDING_RESTART) {
// Checks for bootloader update applied from DFU to OTA region + special OTA flag of 0xA5
// In that case, HAL_UPDATE_APPLIED is returned and a reset is required to ensure we don't
// remain in Safe Mode due to bootloader dependency checks. HAL_UPDATE_APPLIED_PENDING_RESTART won't
// be returned when updating the bootloader, but we check for it just in case so we can reset if necessary.
hal_update_complete_t pendingUpdateResult = HAL_FLASH_ApplyPendingUpdate(nullptr /*module*/, false /*dryRun*/, nullptr /*reserved*/);
if (pendingUpdateResult == HAL_UPDATE_APPLIED_PENDING_RESTART || pendingUpdateResult == HAL_UPDATE_APPLIED) {
// the regular OTA update delays 100 milliseconds so maintaining the same behavior.
HAL_Delay_Milliseconds(100);
HAL_Core_System_Reset_Ex(RESET_REASON_UPDATE, 0, nullptr);
Expand Down