updatehub: report error before rollback on unconfirmed image
Report the error state to the UpdateHub server before triggering a rollback in autohandler mode. This prevents the server from redeploying the same (failed) update after rollback, avoiding update loops. Also exposes a new public syscall: updatehub_report_error(), allowing manual mode users to report an error explicitly. Signed-off-by: Adrien Maillard <adrien.maillard@edu.hefr.ch>
This commit is contained in:
parent
d5a9a0fa87
commit
4d73cd3980
@ -284,6 +284,10 @@ New APIs and options
|
||||
* :kconfig:option:`CONFIG_DEBUG_COREDUMP_BACKEND_IN_MEMORY`
|
||||
* :kconfig:option:`CONFIG_DEBUG_COREDUMP_BACKEND_IN_MEMORY_SIZE`
|
||||
|
||||
* UpdateHub
|
||||
|
||||
* :c:func:`updatehub_report_error`
|
||||
|
||||
* Other
|
||||
|
||||
* :kconfig:option:`CONFIG_LV_Z_COLOR_MONO_HW_INVERSION`
|
||||
|
||||
@ -90,6 +90,15 @@ __syscall int updatehub_confirm(void);
|
||||
*/
|
||||
__syscall int updatehub_reboot(void);
|
||||
|
||||
/**
|
||||
* @brief Report an update failure to the UpdateHub server.
|
||||
*
|
||||
* @details This sends an ERROR state (UPDATEHUB_STATE_ERROR) for the last package.
|
||||
*
|
||||
* @return 0 on success, negative errno on failure.
|
||||
*/
|
||||
__syscall int updatehub_report_error(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1001,7 +1001,9 @@ static void autohandler(struct k_work *work)
|
||||
case UPDATEHUB_UNCONFIRMED_IMAGE:
|
||||
LOG_ERR("Image is unconfirmed. Rebooting to revert back to previous"
|
||||
"confirmed image.");
|
||||
|
||||
if (report(UPDATEHUB_STATE_ERROR) < 0) {
|
||||
LOG_ERR("Failed to report rollback error to server");
|
||||
}
|
||||
LOG_PANIC();
|
||||
updatehub_reboot();
|
||||
break;
|
||||
@ -1044,3 +1046,8 @@ void z_impl_updatehub_autohandler(void)
|
||||
k_work_init_delayable(&updatehub_work_handle, autohandler);
|
||||
k_work_reschedule(&updatehub_work_handle, K_NO_WAIT);
|
||||
}
|
||||
|
||||
int z_impl_updatehub_report_error(void)
|
||||
{
|
||||
return report(UPDATEHUB_STATE_ERROR);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user