From c6076a0c6caaf1059feb87342e053c0680a69f0c Mon Sep 17 00:00:00 2001 From: Tomasz Chyrowicz Date: Mon, 4 Nov 2024 15:05:23 +0100 Subject: [PATCH 1/3] sdfw_services: suit: Add services for companions Add services definitions that allow companiona applications to check the current execution context as well as request a different boot mode. Ref: NCSDK-29996 Signed-off-by: Tomasz Chyrowicz --- .../services/suit_service/suit_service.cddl | 66 +- .../zcbor_generated/suit_service_decode.c | 640 ++++++++---------- .../zcbor_generated/suit_service_decode.h | 2 +- .../zcbor_generated/suit_service_encode.c | 599 +++++++--------- .../zcbor_generated/suit_service_encode.h | 2 +- .../zcbor_generated/suit_service_types.h | 37 +- 6 files changed, 660 insertions(+), 686 deletions(-) diff --git a/subsys/sdfw_services/services/suit_service/suit_service.cddl b/subsys/sdfw_services/services/suit_service/suit_service.cddl index 7bb5eedb9ab4..6e3ec5766163 100644 --- a/subsys/sdfw_services/services/suit_service/suit_service.cddl +++ b/subsys/sdfw_services/services/suit_service/suit_service.cddl @@ -301,6 +301,58 @@ suit_chunk_status_rsp = ( chunk_info: [ 0*3 suit_chunk_info_entry], ) +; Read the current execution mode. +; This service is used to provide an execution context for the companion app. +suit_execution_mode_read_req = ( + 50, +) + +; See suit_execution_mode_t for execution_mode field possible values. +suit_execution_mode_read_rsp = ( + 50, + ret: int, + execution_mode: uint, +) + +; Confirm that the image was booted. +; This service is use by the companion app to release SUIT orchestrator in case +; of synchronous invocation. +suit_invoke_confirm_req = ( + 51, + ret: int, +) + +suit_invoke_confirm_rsp = ( + 51, + ret: int, +) + +; Reset all SUIT boot flags. +; This API will reboot the SDFW and attempt to boot the system from installed +; manifests. +suit_boot_flags_reset_req = ( + 52, +) + +suit_boot_flags_reset_rsp = ( + 52, + ret: int, +) + +; Reboot the system into a forground DFU mode. +; In this mode the SUIT orchestrator boots the application recovery image. +; The recovery image should check the context of invocation through +; the suit_execution_mode_read_req service. +; The foreground DFU may be left by providing update candidate or through +; the suit_boot_flags_reset_req service. +suit_foreground_dfu_required_req = ( + 53, +) + +suit_foreground_dfu_required_rsp = ( + 53, + ret: int, +) suit_req = [ ; Union of different requests @@ -321,7 +373,12 @@ suit_req = [ suit_evt_sub_req / suit_chunk_enqueue_req / - suit_chunk_status_req + suit_chunk_status_req / + + suit_execution_mode_read_req / + suit_invoke_confirm_req / + suit_boot_flags_reset_req / + suit_foreground_dfu_required_req ), ] @@ -344,7 +401,12 @@ suit_rsp = [ suit_evt_sub_rsp / suit_chunk_enqueue_rsp / - suit_chunk_status_rsp + suit_chunk_status_rsp / + + suit_execution_mode_read_rsp / + suit_invoke_confirm_rsp / + suit_boot_flags_reset_rsp / + suit_foreground_dfu_required_rsp ), ] diff --git a/subsys/sdfw_services/services/suit_service/zcbor_generated/suit_service_decode.c b/subsys/sdfw_services/services/suit_service/zcbor_generated/suit_service_decode.c index 759d65071ac1..2704ca3bdb0a 100644 --- a/subsys/sdfw_services/services/suit_service/zcbor_generated/suit_service_decode.c +++ b/subsys/sdfw_services/services/suit_service/zcbor_generated/suit_service_decode.c @@ -5,7 +5,7 @@ */ /* - * Generated using zcbor version 0.8.1 + * Generated using zcbor version 0.9.0 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 3 */ @@ -22,6 +22,17 @@ #error "The type file was generated with a different default_max_qty than this file" #endif +#define log_result(state, result, func) \ + do { \ + if (!result) { \ + zcbor_trace_file(state); \ + zcbor_log("%s error: %s\r\n", func, \ + zcbor_error_str(zcbor_peek_error(state))); \ + } else { \ + zcbor_log("%s success\r\n", func); \ + } \ + } while (0) + static bool decode_suit_missing_image_evt_nfy(zcbor_state_t *state, struct suit_missing_image_evt_nfy *result); static bool decode_suit_chunk_status_evt_nfy(zcbor_state_t *state, @@ -55,6 +66,8 @@ static bool decode_suit_chunk_enqueue_req(zcbor_state_t *state, struct suit_chunk_enqueue_req *result); static bool decode_suit_chunk_status_req(zcbor_state_t *state, struct suit_chunk_status_req *result); +static bool decode_suit_invoke_confirm_req(zcbor_state_t *state, + struct suit_invoke_confirm_req *result); static bool decode_suit_trigger_update_rsp(zcbor_state_t *state, struct suit_trigger_update_rsp *result); static bool decode_suit_check_installed_component_digest_rsp( @@ -90,6 +103,15 @@ static bool decode_suit_chunk_info_entry(zcbor_state_t *state, struct suit_chunk_info_entry *result); static bool decode_suit_chunk_status_rsp(zcbor_state_t *state, struct suit_chunk_status_rsp *result); +static bool decode_suit_execution_mode_read_rsp(zcbor_state_t *state, + struct suit_execution_mode_read_rsp *result); +static bool decode_suit_invoke_confirm_rsp(zcbor_state_t *state, + struct suit_invoke_confirm_rsp *result); +static bool decode_suit_boot_flags_reset_rsp(zcbor_state_t *state, + struct suit_boot_flags_reset_rsp *result); +static bool +decode_suit_foreground_dfu_required_rsp(zcbor_state_t *state, + struct suit_foreground_dfu_required_rsp *result); static bool decode_suit_nfy(zcbor_state_t *state, struct suit_nfy *result); static bool decode_suit_rsp(zcbor_state_t *state, struct suit_rsp *result); static bool decode_suit_req(zcbor_state_t *state, struct suit_req *result); @@ -99,20 +121,14 @@ static bool decode_suit_missing_image_evt_nfy(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = ((( + bool res = ((( ((zcbor_uint32_expect(state, (41)))) && ((zcbor_bstr_decode(state, (&(*result).suit_missing_image_evt_nfy_resource_id)))) && ((zcbor_uint32_decode( state, (&(*result).suit_missing_image_evt_nfy_stream_session_id))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool decode_suit_chunk_status_evt_nfy(zcbor_state_t *state, @@ -120,37 +136,23 @@ static bool decode_suit_chunk_status_evt_nfy(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_expect(state, (42)))) && - ((zcbor_uint32_decode( - state, (&(*result).suit_chunk_status_evt_nfy_stream_session_id))))))); + bool res = (((((zcbor_uint32_expect(state, (42)))) && + ((zcbor_uint32_decode( + state, (&(*result).suit_chunk_status_evt_nfy_stream_session_id))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool decode_suit_cache_info_entry(zcbor_state_t *state, struct suit_cache_info_entry *result) { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_decode(state, (&(*result).suit_cache_info_entry_addr)))) && - ((zcbor_uint32_decode(state, (&(*result).suit_cache_info_entry_size))))))); - - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } + bool res = (((((zcbor_uint32_decode(state, (&(*result).suit_cache_info_entry_addr)))) && + ((zcbor_uint32_decode(state, (&(*result).suit_cache_info_entry_size))))))); - return tmp_result; + log_result(state, res, __func__); + return res; } static bool decode_suit_trigger_update_req(zcbor_state_t *state, @@ -158,7 +160,7 @@ static bool decode_suit_trigger_update_req(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = (( + bool res = (( (((zcbor_uint32_expect(state, (1)))) && ((zcbor_uint32_decode(state, (&(*result).suit_trigger_update_req_addr)))) && ((zcbor_uint32_decode(state, (&(*result).suit_trigger_update_req_size)))) && @@ -167,19 +169,22 @@ static bool decode_suit_trigger_update_req(zcbor_state_t *state, 0, 6, &(*result).suit_trigger_update_req_caches_suit_cache_info_entry_m_count, (zcbor_decoder_t *)decode_suit_cache_info_entry, state, - (&(*result).suit_trigger_update_req_caches_suit_cache_info_entry_m), + (*&(*result).suit_trigger_update_req_caches_suit_cache_info_entry_m), sizeof(struct suit_cache_info_entry))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state)))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); + if (false) { + /* For testing that the types of the arguments are correct. + * A compiler error here means a bug in zcbor. + */ + decode_suit_cache_info_entry( + state, + (*&(*result).suit_trigger_update_req_caches_suit_cache_info_entry_m)); } - return tmp_result; + log_result(state, res, __func__); + return res; } static bool decode_suit_check_installed_component_digest_req( @@ -187,7 +192,7 @@ static bool decode_suit_check_installed_component_digest_req( { zcbor_log("%s\r\n", __func__); - bool tmp_result = (( + bool res = (( (((zcbor_uint32_expect(state, (2)))) && ((zcbor_bstr_decode( state, @@ -197,14 +202,8 @@ static bool decode_suit_check_installed_component_digest_req( ((zcbor_bstr_decode( state, (&(*result).suit_check_installed_component_digest_req_digest))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool @@ -213,20 +212,14 @@ decode_suit_get_installed_manifest_info_req(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = (( + bool res = (( (((zcbor_uint32_expect(state, (3)))) && ((zcbor_bstr_decode( state, (&(*result).suit_get_installed_manifest_info_req_manifest_class_id))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool decode_suit_authenticate_manifest_req(zcbor_state_t *state, @@ -234,7 +227,7 @@ static bool decode_suit_authenticate_manifest_req(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = ((( + bool res = ((( ((zcbor_uint32_expect(state, (10)))) && ((zcbor_bstr_decode( state, @@ -248,14 +241,8 @@ static bool decode_suit_authenticate_manifest_req(zcbor_state_t *state, ((zcbor_uint32_decode(state, (&(*result).suit_authenticate_manifest_req_data_size))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool @@ -264,20 +251,14 @@ decode_suit_authorize_unsigned_manifest_req(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = ((( + bool res = ((( ((zcbor_uint32_expect(state, (11)))) && ((zcbor_bstr_decode( state, (&(*result).suit_authorize_unsigned_manifest_req_manifest_component_id))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool decode_suit_authorize_seq_num_req(zcbor_state_t *state, @@ -285,7 +266,7 @@ static bool decode_suit_authorize_seq_num_req(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = (( + bool res = (( (((zcbor_uint32_expect(state, (12)))) && ((zcbor_bstr_decode( state, (&(*result).suit_authorize_seq_num_req_manifest_component_id)))) && @@ -293,14 +274,8 @@ static bool decode_suit_authorize_seq_num_req(zcbor_state_t *state, (&(*result).suit_authorize_seq_num_req_command_seq)))) && ((zcbor_uint32_decode(state, (&(*result).suit_authorize_seq_num_req_seq_num))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool @@ -309,7 +284,7 @@ decode_suit_check_component_compatibility_req(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = (( + bool res = (( (((zcbor_uint32_expect(state, (13)))) && ((zcbor_bstr_decode( state, @@ -318,14 +293,8 @@ decode_suit_check_component_compatibility_req(zcbor_state_t *state, state, (&(*result).suit_check_component_compatibility_req_component_id))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool @@ -334,19 +303,12 @@ decode_suit_get_supported_manifest_info_req(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_expect(state, (19)))) && - ((zcbor_int32_decode( - state, (&(*result).suit_get_supported_manifest_info_req_role))))))); - - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } + bool res = (((((zcbor_uint32_expect(state, (19)))) && + ((zcbor_int32_decode( + state, (&(*result).suit_get_supported_manifest_info_req_role))))))); - return tmp_result; + log_result(state, res, __func__); + return res; } static bool @@ -355,7 +317,7 @@ decode_suit_authorize_process_dependency_req(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = (( + bool res = (( (((zcbor_uint32_expect(state, (21)))) && ((zcbor_bstr_decode( state, @@ -366,32 +328,19 @@ decode_suit_authorize_process_dependency_req(zcbor_state_t *state, ((zcbor_int32_decode( state, (&(*result).suit_authorize_process_dependency_req_seq_id))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool decode_suit_evt_sub_req(zcbor_state_t *state, struct suit_evt_sub_req *result) { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_expect(state, (40)))) && - ((zcbor_bool_decode(state, (&(*result).suit_evt_sub_req_subscribe))))))); - - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } + bool res = (((((zcbor_uint32_expect(state, (40)))) && + ((zcbor_bool_decode(state, (&(*result).suit_evt_sub_req_subscribe))))))); - return tmp_result; + log_result(state, res, __func__); + return res; } static bool decode_suit_chunk_enqueue_req(zcbor_state_t *state, @@ -399,7 +348,7 @@ static bool decode_suit_chunk_enqueue_req(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = + bool res = (((((zcbor_uint32_expect(state, (43)))) && ((zcbor_uint32_decode(state, (&(*result).suit_chunk_enqueue_req_stream_session_id)))) && @@ -409,33 +358,32 @@ static bool decode_suit_chunk_enqueue_req(zcbor_state_t *state, ((zcbor_uint32_decode(state, (&(*result).suit_chunk_enqueue_req_addr)))) && ((zcbor_uint32_decode(state, (&(*result).suit_chunk_enqueue_req_size))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool decode_suit_chunk_status_req(zcbor_state_t *state, struct suit_chunk_status_req *result) { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_expect(state, (44)))) && - ((zcbor_uint32_decode(state, - (&(*result).suit_chunk_status_req_stream_session_id))))))); + bool res = (((((zcbor_uint32_expect(state, (44)))) && + ((zcbor_uint32_decode( + state, (&(*result).suit_chunk_status_req_stream_session_id))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } + log_result(state, res, __func__); + return res; +} - return tmp_result; +static bool decode_suit_invoke_confirm_req(zcbor_state_t *state, + struct suit_invoke_confirm_req *result) +{ + zcbor_log("%s\r\n", __func__); + + bool res = (((((zcbor_uint32_expect(state, (51)))) && + ((zcbor_int32_decode(state, (&(*result).suit_invoke_confirm_req_ret))))))); + + log_result(state, res, __func__); + return res; } static bool decode_suit_trigger_update_rsp(zcbor_state_t *state, @@ -443,18 +391,11 @@ static bool decode_suit_trigger_update_rsp(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_expect(state, (1)))) && - ((zcbor_int32_decode(state, (&(*result).suit_trigger_update_rsp_ret))))))); + bool res = (((((zcbor_uint32_expect(state, (1)))) && + ((zcbor_int32_decode(state, (&(*result).suit_trigger_update_rsp_ret))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool decode_suit_check_installed_component_digest_rsp( @@ -462,19 +403,13 @@ static bool decode_suit_check_installed_component_digest_rsp( { zcbor_log("%s\r\n", __func__); - bool tmp_result = + bool res = (((((zcbor_uint32_expect(state, (2)))) && ((zcbor_int32_decode( state, (&(*result).suit_check_installed_component_digest_rsp_ret))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool @@ -483,7 +418,7 @@ decode_suit_get_installed_manifest_info_rsp(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = ((( + bool res = ((( ((zcbor_uint32_expect(state, (3)))) && ((zcbor_int32_decode(state, (&(*result).suit_get_installed_manifest_info_rsp_ret)))) && @@ -493,7 +428,7 @@ decode_suit_get_installed_manifest_info_rsp(zcbor_state_t *state, ((zcbor_multi_decode( 0, 5, &(*result).suit_get_installed_manifest_info_rsp_semver_int_count, (zcbor_decoder_t *)zcbor_int32_decode, state, - (&(*result).suit_get_installed_manifest_info_rsp_semver_int), + (*&(*result).suit_get_installed_manifest_info_rsp_semver_int), sizeof(int32_t))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state))) && @@ -504,14 +439,16 @@ decode_suit_get_installed_manifest_info_rsp(zcbor_state_t *state, ((zcbor_bstr_decode(state, (&(*result).suit_get_installed_manifest_info_rsp_digest))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); + if (false) { + /* For testing that the types of the arguments are correct. + * A compiler error here means a bug in zcbor. + */ + zcbor_int32_decode(state, + (*&(*result).suit_get_installed_manifest_info_rsp_semver_int)); } - return tmp_result; + log_result(state, res, __func__); + return res; } static bool @@ -520,7 +457,7 @@ decode_suit_get_install_candidate_info_rsp(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = ((( + bool res = ((( ((zcbor_uint32_expect(state, (4)))) && ((zcbor_int32_decode(state, (&(*result).suit_get_install_candidate_info_rsp_ret)))) && @@ -533,7 +470,7 @@ decode_suit_get_install_candidate_info_rsp(zcbor_state_t *state, ((zcbor_multi_decode( 0, 5, &(*result).suit_get_install_candidate_info_rsp_semver_int_count, (zcbor_decoder_t *)zcbor_int32_decode, state, - (&(*result).suit_get_install_candidate_info_rsp_semver_int), + (*&(*result).suit_get_install_candidate_info_rsp_semver_int), sizeof(int32_t))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state))) && @@ -542,14 +479,16 @@ decode_suit_get_install_candidate_info_rsp(zcbor_state_t *state, ((zcbor_bstr_decode(state, (&(*result).suit_get_install_candidate_info_rsp_digest))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); + if (false) { + /* For testing that the types of the arguments are correct. + * A compiler error here means a bug in zcbor. + */ + zcbor_int32_decode(state, + (*&(*result).suit_get_install_candidate_info_rsp_semver_int)); } - return tmp_result; + log_result(state, res, __func__); + return res; } static bool decode_suit_authenticate_manifest_rsp(zcbor_state_t *state, @@ -557,18 +496,12 @@ static bool decode_suit_authenticate_manifest_rsp(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = (( + bool res = (( (((zcbor_uint32_expect(state, (10)))) && ((zcbor_int32_decode(state, (&(*result).suit_authenticate_manifest_rsp_ret))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool @@ -577,19 +510,12 @@ decode_suit_authorize_unsigned_manifest_rsp(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_expect(state, (11)))) && - ((zcbor_int32_decode(state, - (&(*result).suit_authorize_unsigned_manifest_rsp_ret))))))); - - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } + bool res = (((((zcbor_uint32_expect(state, (11)))) && + ((zcbor_int32_decode( + state, (&(*result).suit_authorize_unsigned_manifest_rsp_ret))))))); - return tmp_result; + log_result(state, res, __func__); + return res; } static bool decode_suit_authorize_seq_num_rsp(zcbor_state_t *state, @@ -597,18 +523,11 @@ static bool decode_suit_authorize_seq_num_rsp(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_expect(state, (12)))) && - ((zcbor_int32_decode(state, (&(*result).suit_authorize_seq_num_rsp_ret))))))); - - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } + bool res = (((((zcbor_uint32_expect(state, (12)))) && + ((zcbor_int32_decode(state, (&(*result).suit_authorize_seq_num_rsp_ret))))))); - return tmp_result; + log_result(state, res, __func__); + return res; } static bool @@ -617,19 +536,12 @@ decode_suit_check_component_compatibility_rsp(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_expect(state, (13)))) && - ((zcbor_int32_decode( - state, (&(*result).suit_check_component_compatibility_rsp_ret))))))); - - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } + bool res = (((((zcbor_uint32_expect(state, (13)))) && + ((zcbor_int32_decode( + state, (&(*result).suit_check_component_compatibility_rsp_ret))))))); - return tmp_result; + log_result(state, res, __func__); + return res; } static bool @@ -638,7 +550,7 @@ decode_suit_get_supported_manifest_roles_rsp(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = (( + bool res = (( (((zcbor_uint32_expect(state, (18)))) && ((zcbor_int32_decode(state, (&(*result).suit_get_supported_manifest_roles_rsp_ret)))) && @@ -646,19 +558,21 @@ decode_suit_get_supported_manifest_roles_rsp(zcbor_state_t *state, ((zcbor_multi_decode( 0, 20, &(*result).suit_get_supported_manifest_roles_rsp_roles_int_count, (zcbor_decoder_t *)zcbor_int32_decode, state, - (&(*result).suit_get_supported_manifest_roles_rsp_roles_int), + (*&(*result).suit_get_supported_manifest_roles_rsp_roles_int), sizeof(int32_t))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state)))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); + if (false) { + /* For testing that the types of the arguments are correct. + * A compiler error here means a bug in zcbor. + */ + zcbor_int32_decode(state, + (*&(*result).suit_get_supported_manifest_roles_rsp_roles_int)); } - return tmp_result; + log_result(state, res, __func__); + return res; } static bool @@ -667,7 +581,7 @@ decode_suit_get_supported_manifest_info_rsp(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = ((( + bool res = ((( ((zcbor_uint32_expect(state, (19)))) && ((zcbor_int32_decode(state, (&(*result).suit_get_supported_manifest_info_rsp_ret)))) && @@ -690,14 +604,8 @@ decode_suit_get_supported_manifest_info_rsp(zcbor_state_t *state, (&(*result) .suit_get_supported_manifest_info_rsp_signature_verification_policy))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool @@ -706,36 +614,23 @@ decode_suit_authorize_process_dependency_rsp(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_expect(state, (21)))) && - ((zcbor_int32_decode( - state, (&(*result).suit_authorize_process_dependency_rsp_ret))))))); - - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } + bool res = (((((zcbor_uint32_expect(state, (21)))) && + ((zcbor_int32_decode( + state, (&(*result).suit_authorize_process_dependency_rsp_ret))))))); - return tmp_result; + log_result(state, res, __func__); + return res; } static bool decode_suit_evt_sub_rsp(zcbor_state_t *state, struct suit_evt_sub_rsp *result) { zcbor_log("%s\r\n", __func__); - bool tmp_result = (((((zcbor_uint32_expect(state, (40)))) && - ((zcbor_int32_decode(state, (&(*result).suit_evt_sub_rsp_ret))))))); + bool res = (((((zcbor_uint32_expect(state, (40)))) && + ((zcbor_int32_decode(state, (&(*result).suit_evt_sub_rsp_ret))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool decode_suit_chunk_enqueue_rsp(zcbor_state_t *state, @@ -743,43 +638,29 @@ static bool decode_suit_chunk_enqueue_rsp(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_expect(state, (43)))) && - ((zcbor_int32_decode(state, (&(*result).suit_chunk_enqueue_rsp_ret))))))); + bool res = (((((zcbor_uint32_expect(state, (43)))) && + ((zcbor_int32_decode(state, (&(*result).suit_chunk_enqueue_rsp_ret))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool decode_suit_chunk_info_entry(zcbor_state_t *state, struct suit_chunk_info_entry *result) { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_decode(state, (&(*result).suit_chunk_info_entry_chunk_id)))) && - ((zcbor_uint32_decode(state, (&(*result).suit_chunk_info_entry_status))))))); - - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } + bool res = (((((zcbor_uint32_decode(state, (&(*result).suit_chunk_info_entry_chunk_id)))) && + ((zcbor_uint32_decode(state, (&(*result).suit_chunk_info_entry_status))))))); - return tmp_result; + log_result(state, res, __func__); + return res; } static bool decode_suit_chunk_status_rsp(zcbor_state_t *state, struct suit_chunk_status_rsp *result) { zcbor_log("%s\r\n", __func__); - bool tmp_result = ((( + bool res = ((( ((zcbor_uint32_expect(state, (44)))) && ((zcbor_int32_decode(state, (&(*result).suit_chunk_status_rsp_ret)))) && ((zcbor_list_start_decode(state) && @@ -787,19 +668,74 @@ static bool decode_suit_chunk_status_rsp(zcbor_state_t *state, struct suit_chunk 0, 3, &(*result).suit_chunk_status_rsp_chunk_info_suit_chunk_info_entry_m_count, (zcbor_decoder_t *)decode_suit_chunk_info_entry, state, - (&(*result).suit_chunk_status_rsp_chunk_info_suit_chunk_info_entry_m), + (*&(*result).suit_chunk_status_rsp_chunk_info_suit_chunk_info_entry_m), sizeof(struct suit_chunk_info_entry))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state)))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); + if (false) { + /* For testing that the types of the arguments are correct. + * A compiler error here means a bug in zcbor. + */ + decode_suit_chunk_info_entry( + state, + (*&(*result).suit_chunk_status_rsp_chunk_info_suit_chunk_info_entry_m)); } - return tmp_result; + log_result(state, res, __func__); + return res; +} + +static bool decode_suit_execution_mode_read_rsp(zcbor_state_t *state, + struct suit_execution_mode_read_rsp *result) +{ + zcbor_log("%s\r\n", __func__); + + bool res = + (((((zcbor_uint32_expect(state, (50)))) && + ((zcbor_int32_decode(state, (&(*result).suit_execution_mode_read_rsp_ret)))) && + ((zcbor_uint32_decode( + state, (&(*result).suit_execution_mode_read_rsp_execution_mode))))))); + + log_result(state, res, __func__); + return res; +} + +static bool decode_suit_invoke_confirm_rsp(zcbor_state_t *state, + struct suit_invoke_confirm_rsp *result) +{ + zcbor_log("%s\r\n", __func__); + + bool res = (((((zcbor_uint32_expect(state, (51)))) && + ((zcbor_int32_decode(state, (&(*result).suit_invoke_confirm_rsp_ret))))))); + + log_result(state, res, __func__); + return res; +} + +static bool decode_suit_boot_flags_reset_rsp(zcbor_state_t *state, + struct suit_boot_flags_reset_rsp *result) +{ + zcbor_log("%s\r\n", __func__); + + bool res = (((((zcbor_uint32_expect(state, (52)))) && + ((zcbor_int32_decode(state, (&(*result).suit_boot_flags_reset_rsp_ret))))))); + + log_result(state, res, __func__); + return res; +} + +static bool decode_suit_foreground_dfu_required_rsp(zcbor_state_t *state, + struct suit_foreground_dfu_required_rsp *result) +{ + zcbor_log("%s\r\n", __func__); + + bool res = ((( + ((zcbor_uint32_expect(state, (53)))) && + ((zcbor_int32_decode(state, (&(*result).suit_foreground_dfu_required_rsp_ret))))))); + + log_result(state, res, __func__); + return res; } static bool decode_suit_nfy(zcbor_state_t *state, struct suit_nfy *result) @@ -807,7 +743,7 @@ static bool decode_suit_nfy(zcbor_state_t *state, struct suit_nfy *result) zcbor_log("%s\r\n", __func__); bool int_res; - bool tmp_result = (( + bool res = (( (zcbor_list_start_decode(state) && ((((zcbor_union_start_code(state) && (int_res = @@ -828,14 +764,8 @@ static bool decode_suit_nfy(zcbor_state_t *state, struct suit_nfy *result) (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state)))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool decode_suit_rsp(zcbor_state_t *state, struct suit_rsp *result) @@ -843,7 +773,7 @@ static bool decode_suit_rsp(zcbor_state_t *state, struct suit_rsp *result) zcbor_log("%s\r\n", __func__); bool int_res; - bool tmp_result = ((( + bool res = ((( zcbor_list_start_decode(state) && ((((zcbor_union_start_code(state) && (int_res = @@ -947,19 +877,41 @@ static bool decode_suit_rsp(zcbor_state_t *state, struct suit_rsp *result) state, (&(*result).suit_rsp_msg_suit_chunk_status_rsp_m)))) && (((*result).suit_rsp_msg_choice = suit_rsp_msg_suit_chunk_status_rsp_m_c), + true))) || + (zcbor_union_elem_code(state) && + (((decode_suit_execution_mode_read_rsp( + state, + (&(*result).suit_rsp_msg_suit_execution_mode_read_rsp_m)))) && + (((*result).suit_rsp_msg_choice = + suit_rsp_msg_suit_execution_mode_read_rsp_m_c), + true))) || + (zcbor_union_elem_code(state) && + (((decode_suit_invoke_confirm_rsp( + state, + (&(*result).suit_rsp_msg_suit_invoke_confirm_rsp_m)))) && + (((*result).suit_rsp_msg_choice = + suit_rsp_msg_suit_invoke_confirm_rsp_m_c), + true))) || + (zcbor_union_elem_code(state) && + (((decode_suit_boot_flags_reset_rsp( + state, + (&(*result).suit_rsp_msg_suit_boot_flags_reset_rsp_m)))) && + (((*result).suit_rsp_msg_choice = + suit_rsp_msg_suit_boot_flags_reset_rsp_m_c), + true))) || + (zcbor_union_elem_code(state) && + (((decode_suit_foreground_dfu_required_rsp( + state, + (&(*result).suit_rsp_msg_suit_foreground_dfu_required_rsp_m)))) && + (((*result).suit_rsp_msg_choice = + suit_rsp_msg_suit_foreground_dfu_required_rsp_m_c), true)))), zcbor_union_end_code(state), int_res)))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state)))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool decode_suit_req(zcbor_state_t *state, struct suit_req *result) @@ -967,7 +919,7 @@ static bool decode_suit_req(zcbor_state_t *state, struct suit_req *result) zcbor_log("%s\r\n", __func__); bool int_res; - bool tmp_result = ((( + bool res = ((( zcbor_list_start_decode(state) && ((((zcbor_union_start_code(state) && (int_res = @@ -997,13 +949,12 @@ static bool decode_suit_req(zcbor_state_t *state, struct suit_req *result) (((*result).suit_req_msg_choice = suit_req_msg_suit_get_install_candidate_info_req_m_c), true)) || - (zcbor_union_elem_code(state) && - (((decode_suit_authenticate_manifest_req( - state, - (&(*result).suit_req_msg_suit_authenticate_manifest_req_m)))) && - (((*result).suit_req_msg_choice = - suit_req_msg_suit_authenticate_manifest_req_m_c), - true))) || + (((decode_suit_authenticate_manifest_req( + state, + (&(*result).suit_req_msg_suit_authenticate_manifest_req_m)))) && + (((*result).suit_req_msg_choice = + suit_req_msg_suit_authenticate_manifest_req_m_c), + true)) || (zcbor_union_elem_code(state) && (((decode_suit_authorize_unsigned_manifest_req( state, @@ -1031,14 +982,13 @@ static bool decode_suit_req(zcbor_state_t *state, struct suit_req *result) (((*result).suit_req_msg_choice = suit_req_msg_suit_get_supported_manifest_roles_req_m_c), true)) || - (zcbor_union_elem_code(state) && - (((decode_suit_get_supported_manifest_info_req( - state, - (&(*result) - .suit_req_msg_suit_get_supported_manifest_info_req_m)))) && - (((*result).suit_req_msg_choice = - suit_req_msg_suit_get_supported_manifest_info_req_m_c), - true))) || + (((decode_suit_get_supported_manifest_info_req( + state, + (&(*result) + .suit_req_msg_suit_get_supported_manifest_info_req_m)))) && + (((*result).suit_req_msg_choice = + suit_req_msg_suit_get_supported_manifest_info_req_m_c), + true)) || (zcbor_union_elem_code(state) && (((decode_suit_authorize_process_dependency_req( state, @@ -1063,19 +1013,31 @@ static bool decode_suit_req(zcbor_state_t *state, struct suit_req *result) state, (&(*result).suit_req_msg_suit_chunk_status_req_m)))) && (((*result).suit_req_msg_choice = suit_req_msg_suit_chunk_status_req_m_c), - true)))), + true))) || + (((zcbor_uint32_expect_union(state, (50)))) && + (((*result).suit_req_msg_choice = + suit_req_msg_suit_execution_mode_read_req_m_c), + true)) || + (((decode_suit_invoke_confirm_req( + state, + (&(*result).suit_req_msg_suit_invoke_confirm_req_m)))) && + (((*result).suit_req_msg_choice = + suit_req_msg_suit_invoke_confirm_req_m_c), + true)) || + (((zcbor_uint32_expect_union(state, (52)))) && + (((*result).suit_req_msg_choice = + suit_req_msg_suit_boot_flags_reset_req_m_c), + true)) || + (((zcbor_uint32_expect_union(state, (53)))) && + (((*result).suit_req_msg_choice = + suit_req_msg_suit_foreground_dfu_required_req_m_c), + true))), zcbor_union_end_code(state), int_res)))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state)))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } int cbor_decode_suit_req(const uint8_t *payload, size_t payload_len, struct suit_req *result, diff --git a/subsys/sdfw_services/services/suit_service/zcbor_generated/suit_service_decode.h b/subsys/sdfw_services/services/suit_service/zcbor_generated/suit_service_decode.h index b997a4b31857..69299a8d0e5e 100644 --- a/subsys/sdfw_services/services/suit_service/zcbor_generated/suit_service_decode.h +++ b/subsys/sdfw_services/services/suit_service/zcbor_generated/suit_service_decode.h @@ -5,7 +5,7 @@ */ /* - * Generated using zcbor version 0.8.1 + * Generated using zcbor version 0.9.0 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 3 */ diff --git a/subsys/sdfw_services/services/suit_service/zcbor_generated/suit_service_encode.c b/subsys/sdfw_services/services/suit_service/zcbor_generated/suit_service_encode.c index 9aba74cb7adc..cbdcd3c975d9 100644 --- a/subsys/sdfw_services/services/suit_service/zcbor_generated/suit_service_encode.c +++ b/subsys/sdfw_services/services/suit_service/zcbor_generated/suit_service_encode.c @@ -5,7 +5,7 @@ */ /* - * Generated using zcbor version 0.8.1 + * Generated using zcbor version 0.9.0 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 3 */ @@ -22,6 +22,17 @@ #error "The type file was generated with a different default_max_qty than this file" #endif +#define log_result(state, result, func) \ + do { \ + if (!result) { \ + zcbor_trace_file(state); \ + zcbor_log("%s error: %s\r\n", func, \ + zcbor_error_str(zcbor_peek_error(state))); \ + } else { \ + zcbor_log("%s success\r\n", func); \ + } \ + } while (0) + static bool encode_suit_missing_image_evt_nfy(zcbor_state_t *state, const struct suit_missing_image_evt_nfy *input); static bool encode_suit_chunk_status_evt_nfy(zcbor_state_t *state, @@ -52,6 +63,8 @@ static bool encode_suit_chunk_enqueue_req(zcbor_state_t *state, const struct suit_chunk_enqueue_req *input); static bool encode_suit_chunk_status_req(zcbor_state_t *state, const struct suit_chunk_status_req *input); +static bool encode_suit_invoke_confirm_req(zcbor_state_t *state, + const struct suit_invoke_confirm_req *input); static bool encode_suit_trigger_update_rsp(zcbor_state_t *state, const struct suit_trigger_update_rsp *input); static bool encode_suit_check_installed_component_digest_rsp( @@ -83,6 +96,15 @@ static bool encode_suit_chunk_info_entry(zcbor_state_t *state, const struct suit_chunk_info_entry *input); static bool encode_suit_chunk_status_rsp(zcbor_state_t *state, const struct suit_chunk_status_rsp *input); +static bool encode_suit_execution_mode_read_rsp(zcbor_state_t *state, + const struct suit_execution_mode_read_rsp *input); +static bool encode_suit_invoke_confirm_rsp(zcbor_state_t *state, + const struct suit_invoke_confirm_rsp *input); +static bool encode_suit_boot_flags_reset_rsp(zcbor_state_t *state, + const struct suit_boot_flags_reset_rsp *input); +static bool +encode_suit_foreground_dfu_required_rsp(zcbor_state_t *state, + const struct suit_foreground_dfu_required_rsp *input); static bool encode_suit_nfy(zcbor_state_t *state, const struct suit_nfy *input); static bool encode_suit_rsp(zcbor_state_t *state, const struct suit_rsp *input); static bool encode_suit_req(zcbor_state_t *state, const struct suit_req *input); @@ -92,20 +114,14 @@ static bool encode_suit_missing_image_evt_nfy(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = (( + bool res = (( (((zcbor_uint32_put(state, (41)))) && ((zcbor_bstr_encode(state, (&(*input).suit_missing_image_evt_nfy_resource_id)))) && ((zcbor_uint32_encode( state, (&(*input).suit_missing_image_evt_nfy_stream_session_id))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_chunk_status_evt_nfy(zcbor_state_t *state, @@ -113,19 +129,12 @@ static bool encode_suit_chunk_status_evt_nfy(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_put(state, (42)))) && - ((zcbor_uint32_encode( - state, (&(*input).suit_chunk_status_evt_nfy_stream_session_id))))))); - - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } + bool res = (((((zcbor_uint32_put(state, (42)))) && + ((zcbor_uint32_encode( + state, (&(*input).suit_chunk_status_evt_nfy_stream_session_id))))))); - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_cache_info_entry(zcbor_state_t *state, @@ -133,18 +142,11 @@ static bool encode_suit_cache_info_entry(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_encode(state, (&(*input).suit_cache_info_entry_addr)))) && - ((zcbor_uint32_encode(state, (&(*input).suit_cache_info_entry_size))))))); + bool res = (((((zcbor_uint32_encode(state, (&(*input).suit_cache_info_entry_addr)))) && + ((zcbor_uint32_encode(state, (&(*input).suit_cache_info_entry_size))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_trigger_update_req(zcbor_state_t *state, @@ -152,7 +154,7 @@ static bool encode_suit_trigger_update_req(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = (( + bool res = (( (((zcbor_uint32_put(state, (1)))) && ((zcbor_uint32_encode(state, (&(*input).suit_trigger_update_req_addr)))) && ((zcbor_uint32_encode(state, (&(*input).suit_trigger_update_req_size)))) && @@ -161,19 +163,13 @@ static bool encode_suit_trigger_update_req(zcbor_state_t *state, 0, 6, &(*input).suit_trigger_update_req_caches_suit_cache_info_entry_m_count, (zcbor_encoder_t *)encode_suit_cache_info_entry, state, - (&(*input).suit_trigger_update_req_caches_suit_cache_info_entry_m), + (*&(*input).suit_trigger_update_req_caches_suit_cache_info_entry_m), sizeof(struct suit_cache_info_entry))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_list_end_encode(state, 12)))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_check_installed_component_digest_req( @@ -181,7 +177,7 @@ static bool encode_suit_check_installed_component_digest_req( { zcbor_log("%s\r\n", __func__); - bool tmp_result = (( + bool res = (( (((zcbor_uint32_put(state, (2)))) && ((zcbor_bstr_encode( state, @@ -191,14 +187,8 @@ static bool encode_suit_check_installed_component_digest_req( ((zcbor_bstr_encode( state, (&(*input).suit_check_installed_component_digest_req_digest))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_get_installed_manifest_info_req( @@ -206,20 +196,14 @@ static bool encode_suit_get_installed_manifest_info_req( { zcbor_log("%s\r\n", __func__); - bool tmp_result = + bool res = (((((zcbor_uint32_put(state, (3)))) && ((zcbor_bstr_encode( state, (&(*input).suit_get_installed_manifest_info_req_manifest_class_id))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool @@ -228,7 +212,7 @@ encode_suit_authenticate_manifest_req(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = ((( + bool res = ((( ((zcbor_uint32_put(state, (10)))) && ((zcbor_bstr_encode( state, (&(*input).suit_authenticate_manifest_req_manifest_component_id)))) && @@ -240,14 +224,8 @@ encode_suit_authenticate_manifest_req(zcbor_state_t *state, ((zcbor_uint32_encode(state, (&(*input).suit_authenticate_manifest_req_data_size))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_authorize_unsigned_manifest_req( @@ -255,20 +233,14 @@ static bool encode_suit_authorize_unsigned_manifest_req( { zcbor_log("%s\r\n", __func__); - bool tmp_result = ((( + bool res = ((( ((zcbor_uint32_put(state, (11)))) && ((zcbor_bstr_encode( state, (&(*input).suit_authorize_unsigned_manifest_req_manifest_component_id))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_authorize_seq_num_req(zcbor_state_t *state, @@ -276,21 +248,15 @@ static bool encode_suit_authorize_seq_num_req(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = ((( + bool res = ((( ((zcbor_uint32_put(state, (12)))) && ((zcbor_bstr_encode( state, (&(*input).suit_authorize_seq_num_req_manifest_component_id)))) && ((zcbor_uint32_encode(state, (&(*input).suit_authorize_seq_num_req_command_seq)))) && ((zcbor_uint32_encode(state, (&(*input).suit_authorize_seq_num_req_seq_num))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_check_component_compatibility_req( @@ -298,7 +264,7 @@ static bool encode_suit_check_component_compatibility_req( { zcbor_log("%s\r\n", __func__); - bool tmp_result = ((( + bool res = ((( ((zcbor_uint32_put(state, (13)))) && ((zcbor_bstr_encode( state, @@ -306,14 +272,8 @@ static bool encode_suit_check_component_compatibility_req( ((zcbor_bstr_encode( state, (&(*input).suit_check_component_compatibility_req_component_id))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_get_supported_manifest_info_req( @@ -321,19 +281,12 @@ static bool encode_suit_get_supported_manifest_info_req( { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_put(state, (19)))) && - ((zcbor_int32_encode(state, - (&(*input).suit_get_supported_manifest_info_req_role))))))); + bool res = (((((zcbor_uint32_put(state, (19)))) && + ((zcbor_int32_encode( + state, (&(*input).suit_get_supported_manifest_info_req_role))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_authorize_process_dependency_req( @@ -341,7 +294,7 @@ static bool encode_suit_authorize_process_dependency_req( { zcbor_log("%s\r\n", __func__); - bool tmp_result = ((( + bool res = ((( ((zcbor_uint32_put(state, (21)))) && ((zcbor_bstr_encode( state, @@ -352,32 +305,19 @@ static bool encode_suit_authorize_process_dependency_req( ((zcbor_int32_encode(state, (&(*input).suit_authorize_process_dependency_req_seq_id))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_evt_sub_req(zcbor_state_t *state, const struct suit_evt_sub_req *input) { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_put(state, (40)))) && - ((zcbor_bool_encode(state, (&(*input).suit_evt_sub_req_subscribe))))))); + bool res = (((((zcbor_uint32_put(state, (40)))) && + ((zcbor_bool_encode(state, (&(*input).suit_evt_sub_req_subscribe))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_chunk_enqueue_req(zcbor_state_t *state, @@ -385,24 +325,17 @@ static bool encode_suit_chunk_enqueue_req(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_put(state, (43)))) && - ((zcbor_uint32_encode(state, - (&(*input).suit_chunk_enqueue_req_stream_session_id)))) && - ((zcbor_uint32_encode(state, (&(*input).suit_chunk_enqueue_req_chunk_id)))) && - ((zcbor_uint32_encode(state, (&(*input).suit_chunk_enqueue_req_offset)))) && - ((zcbor_bool_encode(state, (&(*input).suit_chunk_enqueue_req_last_chunk)))) && - ((zcbor_uint32_encode(state, (&(*input).suit_chunk_enqueue_req_addr)))) && - ((zcbor_uint32_encode(state, (&(*input).suit_chunk_enqueue_req_size))))))); - - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } + bool res = (((((zcbor_uint32_put(state, (43)))) && + ((zcbor_uint32_encode( + state, (&(*input).suit_chunk_enqueue_req_stream_session_id)))) && + ((zcbor_uint32_encode(state, (&(*input).suit_chunk_enqueue_req_chunk_id)))) && + ((zcbor_uint32_encode(state, (&(*input).suit_chunk_enqueue_req_offset)))) && + ((zcbor_bool_encode(state, (&(*input).suit_chunk_enqueue_req_last_chunk)))) && + ((zcbor_uint32_encode(state, (&(*input).suit_chunk_enqueue_req_addr)))) && + ((zcbor_uint32_encode(state, (&(*input).suit_chunk_enqueue_req_size))))))); - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_chunk_status_req(zcbor_state_t *state, @@ -410,19 +343,24 @@ static bool encode_suit_chunk_status_req(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_put(state, (44)))) && - ((zcbor_uint32_encode(state, - (&(*input).suit_chunk_status_req_stream_session_id))))))); + bool res = (((((zcbor_uint32_put(state, (44)))) && + ((zcbor_uint32_encode( + state, (&(*input).suit_chunk_status_req_stream_session_id))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } + log_result(state, res, __func__); + return res; +} + +static bool encode_suit_invoke_confirm_req(zcbor_state_t *state, + const struct suit_invoke_confirm_req *input) +{ + zcbor_log("%s\r\n", __func__); - return tmp_result; + bool res = (((((zcbor_uint32_put(state, (51)))) && + ((zcbor_int32_encode(state, (&(*input).suit_invoke_confirm_req_ret))))))); + + log_result(state, res, __func__); + return res; } static bool encode_suit_trigger_update_rsp(zcbor_state_t *state, @@ -430,18 +368,11 @@ static bool encode_suit_trigger_update_rsp(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_put(state, (1)))) && - ((zcbor_int32_encode(state, (&(*input).suit_trigger_update_rsp_ret))))))); - - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } + bool res = (((((zcbor_uint32_put(state, (1)))) && + ((zcbor_int32_encode(state, (&(*input).suit_trigger_update_rsp_ret))))))); - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_check_installed_component_digest_rsp( @@ -449,19 +380,13 @@ static bool encode_suit_check_installed_component_digest_rsp( { zcbor_log("%s\r\n", __func__); - bool tmp_result = + bool res = (((((zcbor_uint32_put(state, (2)))) && ((zcbor_int32_encode( state, (&(*input).suit_check_installed_component_digest_rsp_ret))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_get_installed_manifest_info_rsp( @@ -469,7 +394,7 @@ static bool encode_suit_get_installed_manifest_info_rsp( { zcbor_log("%s\r\n", __func__); - bool tmp_result = ((( + bool res = ((( ((zcbor_uint32_put(state, (3)))) && ((zcbor_int32_encode(state, (&(*input).suit_get_installed_manifest_info_rsp_ret)))) && @@ -479,7 +404,7 @@ static bool encode_suit_get_installed_manifest_info_rsp( ((zcbor_multi_encode_minmax( 0, 5, &(*input).suit_get_installed_manifest_info_rsp_semver_int_count, (zcbor_encoder_t *)zcbor_int32_encode, state, - (&(*input).suit_get_installed_manifest_info_rsp_semver_int), + (*&(*input).suit_get_installed_manifest_info_rsp_semver_int), sizeof(int32_t))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_list_end_encode(state, 5))) && @@ -490,14 +415,8 @@ static bool encode_suit_get_installed_manifest_info_rsp( ((zcbor_bstr_encode(state, (&(*input).suit_get_installed_manifest_info_rsp_digest))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool @@ -506,7 +425,7 @@ encode_suit_get_install_candidate_info_rsp(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = ((( + bool res = ((( ((zcbor_uint32_put(state, (4)))) && ((zcbor_int32_encode(state, (&(*input).suit_get_install_candidate_info_rsp_ret)))) && ((zcbor_bstr_encode( @@ -518,7 +437,7 @@ encode_suit_get_install_candidate_info_rsp(zcbor_state_t *state, ((zcbor_multi_encode_minmax( 0, 5, &(*input).suit_get_install_candidate_info_rsp_semver_int_count, (zcbor_encoder_t *)zcbor_int32_encode, state, - (&(*input).suit_get_install_candidate_info_rsp_semver_int), + (*&(*input).suit_get_install_candidate_info_rsp_semver_int), sizeof(int32_t))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_list_end_encode(state, 5))) && @@ -527,14 +446,8 @@ encode_suit_get_install_candidate_info_rsp(zcbor_state_t *state, ((zcbor_bstr_encode(state, (&(*input).suit_get_install_candidate_info_rsp_digest))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool @@ -543,18 +456,12 @@ encode_suit_authenticate_manifest_rsp(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = + bool res = (((((zcbor_uint32_put(state, (10)))) && ((zcbor_int32_encode(state, (&(*input).suit_authenticate_manifest_rsp_ret))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_authorize_unsigned_manifest_rsp( @@ -562,19 +469,12 @@ static bool encode_suit_authorize_unsigned_manifest_rsp( { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_put(state, (11)))) && - ((zcbor_int32_encode(state, - (&(*input).suit_authorize_unsigned_manifest_rsp_ret))))))); + bool res = (((((zcbor_uint32_put(state, (11)))) && + ((zcbor_int32_encode( + state, (&(*input).suit_authorize_unsigned_manifest_rsp_ret))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_authorize_seq_num_rsp(zcbor_state_t *state, @@ -582,18 +482,11 @@ static bool encode_suit_authorize_seq_num_rsp(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_put(state, (12)))) && - ((zcbor_int32_encode(state, (&(*input).suit_authorize_seq_num_rsp_ret))))))); - - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } + bool res = (((((zcbor_uint32_put(state, (12)))) && + ((zcbor_int32_encode(state, (&(*input).suit_authorize_seq_num_rsp_ret))))))); - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_check_component_compatibility_rsp( @@ -601,19 +494,12 @@ static bool encode_suit_check_component_compatibility_rsp( { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_put(state, (13)))) && - ((zcbor_int32_encode( - state, (&(*input).suit_check_component_compatibility_rsp_ret))))))); - - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } + bool res = (((((zcbor_uint32_put(state, (13)))) && + ((zcbor_int32_encode( + state, (&(*input).suit_check_component_compatibility_rsp_ret))))))); - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_get_supported_manifest_roles_rsp( @@ -621,7 +507,7 @@ static bool encode_suit_get_supported_manifest_roles_rsp( { zcbor_log("%s\r\n", __func__); - bool tmp_result = (( + bool res = (( (((zcbor_uint32_put(state, (18)))) && ((zcbor_int32_encode(state, (&(*input).suit_get_supported_manifest_roles_rsp_ret)))) && @@ -629,19 +515,13 @@ static bool encode_suit_get_supported_manifest_roles_rsp( ((zcbor_multi_encode_minmax( 0, 20, &(*input).suit_get_supported_manifest_roles_rsp_roles_int_count, (zcbor_encoder_t *)zcbor_int32_encode, state, - (&(*input).suit_get_supported_manifest_roles_rsp_roles_int), + (*&(*input).suit_get_supported_manifest_roles_rsp_roles_int), sizeof(int32_t))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_list_end_encode(state, 20)))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_get_supported_manifest_info_rsp( @@ -649,7 +529,7 @@ static bool encode_suit_get_supported_manifest_info_rsp( { zcbor_log("%s\r\n", __func__); - bool tmp_result = ((( + bool res = ((( ((zcbor_uint32_put(state, (19)))) && ((zcbor_int32_encode(state, (&(*input).suit_get_supported_manifest_info_rsp_ret)))) && @@ -669,14 +549,8 @@ static bool encode_suit_get_supported_manifest_info_rsp( state, (&(*input).suit_get_supported_manifest_info_rsp_signature_verification_policy))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_authorize_process_dependency_rsp( @@ -684,36 +558,23 @@ static bool encode_suit_authorize_process_dependency_rsp( { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_put(state, (21)))) && - ((zcbor_int32_encode(state, - (&(*input).suit_authorize_process_dependency_rsp_ret))))))); + bool res = (((((zcbor_uint32_put(state, (21)))) && + ((zcbor_int32_encode( + state, (&(*input).suit_authorize_process_dependency_rsp_ret))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_evt_sub_rsp(zcbor_state_t *state, const struct suit_evt_sub_rsp *input) { zcbor_log("%s\r\n", __func__); - bool tmp_result = (((((zcbor_uint32_put(state, (40)))) && - ((zcbor_int32_encode(state, (&(*input).suit_evt_sub_rsp_ret))))))); - - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } + bool res = (((((zcbor_uint32_put(state, (40)))) && + ((zcbor_int32_encode(state, (&(*input).suit_evt_sub_rsp_ret))))))); - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_chunk_enqueue_rsp(zcbor_state_t *state, @@ -721,18 +582,11 @@ static bool encode_suit_chunk_enqueue_rsp(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_put(state, (43)))) && - ((zcbor_int32_encode(state, (&(*input).suit_chunk_enqueue_rsp_ret))))))); + bool res = (((((zcbor_uint32_put(state, (43)))) && + ((zcbor_int32_encode(state, (&(*input).suit_chunk_enqueue_rsp_ret))))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_chunk_info_entry(zcbor_state_t *state, @@ -740,18 +594,11 @@ static bool encode_suit_chunk_info_entry(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_encode(state, (&(*input).suit_chunk_info_entry_chunk_id)))) && - ((zcbor_uint32_encode(state, (&(*input).suit_chunk_info_entry_status))))))); - - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } + bool res = (((((zcbor_uint32_encode(state, (&(*input).suit_chunk_info_entry_chunk_id)))) && + ((zcbor_uint32_encode(state, (&(*input).suit_chunk_info_entry_status))))))); - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_chunk_status_rsp(zcbor_state_t *state, @@ -759,7 +606,7 @@ static bool encode_suit_chunk_status_rsp(zcbor_state_t *state, { zcbor_log("%s\r\n", __func__); - bool tmp_result = ((( + bool res = ((( ((zcbor_uint32_put(state, (44)))) && ((zcbor_int32_encode(state, (&(*input).suit_chunk_status_rsp_ret)))) && ((zcbor_list_start_encode(state, 6) && @@ -767,26 +614,72 @@ static bool encode_suit_chunk_status_rsp(zcbor_state_t *state, 0, 3, &(*input).suit_chunk_status_rsp_chunk_info_suit_chunk_info_entry_m_count, (zcbor_encoder_t *)encode_suit_chunk_info_entry, state, - (&(*input).suit_chunk_status_rsp_chunk_info_suit_chunk_info_entry_m), + (*&(*input).suit_chunk_status_rsp_chunk_info_suit_chunk_info_entry_m), sizeof(struct suit_chunk_info_entry))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_list_end_encode(state, 6)))))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } + log_result(state, res, __func__); + return res; +} + +static bool encode_suit_execution_mode_read_rsp(zcbor_state_t *state, + const struct suit_execution_mode_read_rsp *input) +{ + zcbor_log("%s\r\n", __func__); + + bool res = (((((zcbor_uint32_put(state, (50)))) && + ((zcbor_int32_encode(state, (&(*input).suit_execution_mode_read_rsp_ret)))) && + ((zcbor_uint32_encode( + state, (&(*input).suit_execution_mode_read_rsp_execution_mode))))))); + + log_result(state, res, __func__); + return res; +} + +static bool encode_suit_invoke_confirm_rsp(zcbor_state_t *state, + const struct suit_invoke_confirm_rsp *input) +{ + zcbor_log("%s\r\n", __func__); - return tmp_result; + bool res = (((((zcbor_uint32_put(state, (51)))) && + ((zcbor_int32_encode(state, (&(*input).suit_invoke_confirm_rsp_ret))))))); + + log_result(state, res, __func__); + return res; +} + +static bool encode_suit_boot_flags_reset_rsp(zcbor_state_t *state, + const struct suit_boot_flags_reset_rsp *input) +{ + zcbor_log("%s\r\n", __func__); + + bool res = (((((zcbor_uint32_put(state, (52)))) && + ((zcbor_int32_encode(state, (&(*input).suit_boot_flags_reset_rsp_ret))))))); + + log_result(state, res, __func__); + return res; +} + +static bool +encode_suit_foreground_dfu_required_rsp(zcbor_state_t *state, + const struct suit_foreground_dfu_required_rsp *input) +{ + zcbor_log("%s\r\n", __func__); + + bool res = (( + (((zcbor_uint32_put(state, (53)))) && + ((zcbor_int32_encode(state, (&(*input).suit_foreground_dfu_required_rsp_ret))))))); + + log_result(state, res, __func__); + return res; } static bool encode_suit_nfy(zcbor_state_t *state, const struct suit_nfy *input) { zcbor_log("%s\r\n", __func__); - bool tmp_result = ((( + bool res = ((( zcbor_list_start_encode(state, 3) && ((((((*input).suit_nfy_msg_choice == suit_nfy_msg_suit_missing_image_evt_nfy_m_c) ? ((encode_suit_missing_image_evt_nfy( @@ -800,21 +693,15 @@ static bool encode_suit_nfy(zcbor_state_t *state, const struct suit_nfy *input) (zcbor_list_map_end_force_encode(state), false)) && zcbor_list_end_encode(state, 3)))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_rsp(zcbor_state_t *state, const struct suit_rsp *input) { zcbor_log("%s\r\n", __func__); - bool tmp_result = ((( + bool res = ((( zcbor_list_start_encode(state, 8) && ((((((*input).suit_rsp_msg_choice == suit_rsp_msg_suit_trigger_update_rsp_m_c) ? ((encode_suit_trigger_update_rsp( @@ -884,25 +771,39 @@ static bool encode_suit_rsp(zcbor_state_t *state, const struct suit_rsp *input) ((encode_suit_chunk_status_rsp( state, (&(*input).suit_rsp_msg_suit_chunk_status_rsp_m)))) : - false)))))))))))))))) || + (((*input).suit_rsp_msg_choice == + suit_rsp_msg_suit_execution_mode_read_rsp_m_c) ? + ((encode_suit_execution_mode_read_rsp( + state, + (&(*input).suit_rsp_msg_suit_execution_mode_read_rsp_m)))) : + (((*input).suit_rsp_msg_choice == + suit_rsp_msg_suit_invoke_confirm_rsp_m_c) ? + ((encode_suit_invoke_confirm_rsp( + state, + (&(*input).suit_rsp_msg_suit_invoke_confirm_rsp_m)))) : + (((*input).suit_rsp_msg_choice == + suit_rsp_msg_suit_boot_flags_reset_rsp_m_c) ? + ((encode_suit_boot_flags_reset_rsp( + state, + (&(*input).suit_rsp_msg_suit_boot_flags_reset_rsp_m)))) : + (((*input).suit_rsp_msg_choice == + suit_rsp_msg_suit_foreground_dfu_required_rsp_m_c) ? + ((encode_suit_foreground_dfu_required_rsp( + state, + (&(*input).suit_rsp_msg_suit_foreground_dfu_required_rsp_m)))) : + false)))))))))))))))))))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_list_end_encode(state, 8)))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } static bool encode_suit_req(zcbor_state_t *state, const struct suit_req *input) { zcbor_log("%s\r\n", __func__); - bool tmp_result = ((( + bool res = ((( zcbor_list_start_encode(state, 7) && ((((((*input).suit_req_msg_choice == suit_req_msg_suit_trigger_update_req_m_c) ? ((encode_suit_trigger_update_req( @@ -970,18 +871,32 @@ static bool encode_suit_req(zcbor_state_t *state, const struct suit_req *input) ((encode_suit_chunk_status_req( state, (&(*input).suit_req_msg_suit_chunk_status_req_m)))) : - false)))))))))))))))) || + (((*input).suit_req_msg_choice == + suit_req_msg_suit_execution_mode_read_req_m_c) ? + ((zcbor_uint32_put( + state, + (50)))) : + (((*input).suit_req_msg_choice == + suit_req_msg_suit_invoke_confirm_req_m_c) ? + ((encode_suit_invoke_confirm_req( + state, + (&(*input).suit_req_msg_suit_invoke_confirm_req_m)))) : + (((*input).suit_req_msg_choice == + suit_req_msg_suit_boot_flags_reset_req_m_c) ? + ((zcbor_uint32_put( + state, + (52)))) : + (((*input).suit_req_msg_choice == + suit_req_msg_suit_foreground_dfu_required_req_m_c) ? + ((zcbor_uint32_put( + state, + (53)))) : + false)))))))))))))))))))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_list_end_encode(state, 7)))); - if (!tmp_result) { - zcbor_trace_file(state); - zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); - } else { - zcbor_log("%s success\r\n", __func__); - } - - return tmp_result; + log_result(state, res, __func__); + return res; } int cbor_encode_suit_req(uint8_t *payload, size_t payload_len, const struct suit_req *input, diff --git a/subsys/sdfw_services/services/suit_service/zcbor_generated/suit_service_encode.h b/subsys/sdfw_services/services/suit_service/zcbor_generated/suit_service_encode.h index 2a7fbee1c648..91c8efaca0b0 100644 --- a/subsys/sdfw_services/services/suit_service/zcbor_generated/suit_service_encode.h +++ b/subsys/sdfw_services/services/suit_service/zcbor_generated/suit_service_encode.h @@ -5,7 +5,7 @@ */ /* - * Generated using zcbor version 0.8.1 + * Generated using zcbor version 0.9.0 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 3 */ diff --git a/subsys/sdfw_services/services/suit_service/zcbor_generated/suit_service_types.h b/subsys/sdfw_services/services/suit_service/zcbor_generated/suit_service_types.h index acd90121b9c0..0e48f78bb051 100644 --- a/subsys/sdfw_services/services/suit_service/zcbor_generated/suit_service_types.h +++ b/subsys/sdfw_services/services/suit_service/zcbor_generated/suit_service_types.h @@ -5,7 +5,7 @@ */ /* - * Generated using zcbor version 0.8.1 + * Generated using zcbor version 0.9.0 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 3 */ @@ -124,6 +124,10 @@ struct suit_chunk_status_req { uint32_t suit_chunk_status_req_stream_session_id; }; +struct suit_invoke_confirm_req { + int32_t suit_invoke_confirm_req_ret; +}; + struct suit_req { union { struct suit_trigger_update_req suit_req_msg_suit_trigger_update_req_m; @@ -144,6 +148,7 @@ struct suit_req { struct suit_evt_sub_req suit_req_msg_suit_evt_sub_req_m; struct suit_chunk_enqueue_req suit_req_msg_suit_chunk_enqueue_req_m; struct suit_chunk_status_req suit_req_msg_suit_chunk_status_req_m; + struct suit_invoke_confirm_req suit_req_msg_suit_invoke_confirm_req_m; }; enum { suit_req_msg_suit_trigger_update_req_m_c, @@ -160,6 +165,10 @@ struct suit_req { suit_req_msg_suit_evt_sub_req_m_c, suit_req_msg_suit_chunk_enqueue_req_m_c, suit_req_msg_suit_chunk_status_req_m_c, + suit_req_msg_suit_execution_mode_read_req_m_c, + suit_req_msg_suit_invoke_confirm_req_m_c, + suit_req_msg_suit_boot_flags_reset_req_m_c, + suit_req_msg_suit_foreground_dfu_required_req_m_c, } suit_req_msg_choice; }; @@ -246,6 +255,23 @@ struct suit_chunk_status_rsp { size_t suit_chunk_status_rsp_chunk_info_suit_chunk_info_entry_m_count; }; +struct suit_execution_mode_read_rsp { + int32_t suit_execution_mode_read_rsp_ret; + uint32_t suit_execution_mode_read_rsp_execution_mode; +}; + +struct suit_invoke_confirm_rsp { + int32_t suit_invoke_confirm_rsp_ret; +}; + +struct suit_boot_flags_reset_rsp { + int32_t suit_boot_flags_reset_rsp_ret; +}; + +struct suit_foreground_dfu_required_rsp { + int32_t suit_foreground_dfu_required_rsp_ret; +}; + struct suit_rsp { union { struct suit_trigger_update_rsp suit_rsp_msg_suit_trigger_update_rsp_m; @@ -270,6 +296,11 @@ struct suit_rsp { struct suit_evt_sub_rsp suit_rsp_msg_suit_evt_sub_rsp_m; struct suit_chunk_enqueue_rsp suit_rsp_msg_suit_chunk_enqueue_rsp_m; struct suit_chunk_status_rsp suit_rsp_msg_suit_chunk_status_rsp_m; + struct suit_execution_mode_read_rsp suit_rsp_msg_suit_execution_mode_read_rsp_m; + struct suit_invoke_confirm_rsp suit_rsp_msg_suit_invoke_confirm_rsp_m; + struct suit_boot_flags_reset_rsp suit_rsp_msg_suit_boot_flags_reset_rsp_m; + struct suit_foreground_dfu_required_rsp + suit_rsp_msg_suit_foreground_dfu_required_rsp_m; }; enum { suit_rsp_msg_suit_trigger_update_rsp_m_c, @@ -286,6 +317,10 @@ struct suit_rsp { suit_rsp_msg_suit_evt_sub_rsp_m_c, suit_rsp_msg_suit_chunk_enqueue_rsp_m_c, suit_rsp_msg_suit_chunk_status_rsp_m_c, + suit_rsp_msg_suit_execution_mode_read_rsp_m_c, + suit_rsp_msg_suit_invoke_confirm_rsp_m_c, + suit_rsp_msg_suit_boot_flags_reset_rsp_m_c, + suit_rsp_msg_suit_foreground_dfu_required_rsp_m_c, } suit_rsp_msg_choice; }; From bf439852834ef46bf18b571bcd4c285a19f37b50 Mon Sep 17 00:00:00 2001 From: Tomasz Chyrowicz Date: Mon, 4 Nov 2024 15:07:44 +0100 Subject: [PATCH 2/3] sdfw_services: Add SUIT invoke services handlers Add implementation of SUIT SSF invoke services. Ref: NCSDK-29996 Signed-off-by: Tomasz Chyrowicz --- include/sdfw/sdfw_services/suit_service.h | 44 ++++++++ .../services/suit_service/CMakeLists.txt | 1 + .../services/suit_service/Kconfig | 1 - .../services/suit_service/suit_auth.c | 13 ++- .../services/suit_service/suit_invoke.c | 106 ++++++++++++++++++ 5 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 subsys/sdfw_services/services/suit_service/suit_invoke.c diff --git a/include/sdfw/sdfw_services/suit_service.h b/include/sdfw/sdfw_services/suit_service.h index f6ee477c1e1e..88b7622490e7 100644 --- a/include/sdfw/sdfw_services/suit_service.h +++ b/include/sdfw/sdfw_services/suit_service.h @@ -23,6 +23,9 @@ #include #include #include +#ifdef CONFIG_SUIT_EXECUTION_MODE +#include +#endif /* CONFIG_SUIT_EXECUTION_MODE */ #ifdef __cplusplus extern "C" { @@ -177,6 +180,47 @@ suit_ssf_err_t suit_get_supported_manifest_roles(suit_manifest_role_t *roles, si suit_ssf_err_t suit_get_supported_manifest_info(suit_manifest_role_t role, suit_ssf_manifest_class_info_t *class_info); +#ifdef CONFIG_SUIT_EXECUTION_MODE +/** @brief Read the current execution mode value. + * + * @param[out] mode Current execution mode. + * + * @retval SUIT_PLAT_SUCCESS if successful. + * @retval SUIT_PLAT_ERR_INVAL if input parameter is invalid. + * @retval SUIT_PLAT_ERR_IPC in case of SSF protocol error. + */ +suit_ssf_err_t suit_execution_mode_read(suit_execution_mode_t *mode); +#endif /* CONFIG_SUIT_EXECUTION_MODE */ + +/** @brief Confirm that the invoke command finished. + * + * @param[in] ret Invoke command return code. + * + * @retval SUIT_PLAT_SUCCESS if successful. + * @retval SUIT_PLAT_ERR_IPC in case of SSF protocol error. + */ +suit_ssf_err_t suit_invoke_confirm(int ret); + +/** @brief Reset SUIT boot flags. + * + * @note After resetting the SUIT boot flags the system will be reset and a regular boot procedure + * will be executed. + * + * @retval SUIT_PLAT_SUCCESS if successful. + * @retval SUIT_PLAT_ERR_IPC in case of SSF protocol error. + */ +suit_ssf_err_t suit_boot_flags_reset(void); + +/** @brief Request a foreground DFU procedure. + * + * @note After setting the foreground DFU boot flag the system will be reset and a recovery image + * will be booted. + * + * @retval SUIT_PLAT_SUCCESS if successful. + * @retval SUIT_PLAT_ERR_IPC in case of SSF protocol error. + */ +suit_ssf_err_t suit_foreground_dfu_required(void); + #ifdef __cplusplus } #endif diff --git a/subsys/sdfw_services/services/suit_service/CMakeLists.txt b/subsys/sdfw_services/services/suit_service/CMakeLists.txt index 6194bc9fb070..09496933abcb 100644 --- a/subsys/sdfw_services/services/suit_service/CMakeLists.txt +++ b/subsys/sdfw_services/services/suit_service/CMakeLists.txt @@ -9,6 +9,7 @@ zephyr_library() zephyr_library_sources(suit_service.c) zephyr_library_sources(suit_update.c) zephyr_library_sources(suit_mci.c) +zephyr_library_sources(suit_invoke.c) zephyr_library_sources_ifdef(CONFIG_SUIT_PROCESSOR suit_auth.c) zephyr_library_link_libraries(suit_utils) diff --git a/subsys/sdfw_services/services/suit_service/Kconfig b/subsys/sdfw_services/services/suit_service/Kconfig index 147d6d96d47c..b12e2e250865 100644 --- a/subsys/sdfw_services/services/suit_service/Kconfig +++ b/subsys/sdfw_services/services/suit_service/Kconfig @@ -9,7 +9,6 @@ menuconfig SSF_SUIT_SERVICE_ENABLED depends on SDFW_SERVICES_ENABLED depends on SUIT_UTILS depends on SUIT_METADATA - depends on ZCBOR_CANONICAL if SSF_SUIT_SERVICE_ENABLED diff --git a/subsys/sdfw_services/services/suit_service/suit_auth.c b/subsys/sdfw_services/services/suit_service/suit_auth.c index eda8ab2ef478..991a16fc4cf5 100644 --- a/subsys/sdfw_services/services/suit_service/suit_auth.c +++ b/subsys/sdfw_services/services/suit_service/suit_auth.c @@ -16,6 +16,13 @@ #include LOG_MODULE_REGISTER(suit_srvc_auth, CONFIG_SSF_SUIT_SERVICE_LOG_LEVEL); +/* __ALIGNED macro is not defines on NATIVE POSIX. This platform uses __aligned macro. */ +#ifndef __ALIGNED +#ifdef __aligned +#define __ALIGNED __aligned +#endif +#endif + #ifdef CONFIG_DCACHE_LINE_SIZE #define CACHE_ALIGNMENT CONFIG_DCACHE_LINE_SIZE #else @@ -33,12 +40,16 @@ int suit_plat_authenticate_manifest(struct zcbor_string *manifest_component_id, struct suit_rsp rsp; struct suit_authenticate_manifest_req *req_data; uint8_t aligned_auth_data[ROUND_UP(SUIT_SUIT_SIG_STRUCTURE1_MAX_LENGTH, - CACHE_ALIGNMENT)] __ALIGNED(CACHE_ALIGNMENT) = {0}; + CACHE_ALIGNMENT)] __ALIGNED(CACHE_ALIGNMENT) = { 0 }; if (manifest_component_id == NULL || key_id == NULL || signature == NULL || data == NULL) { return SUIT_ERR_DECODING; } + if (data->len > sizeof(aligned_auth_data)) { + return SUIT_ERR_DECODING; + } + memset(&req, 0, sizeof(struct suit_req)); req.suit_req_msg_choice = SSF_SUIT_REQ_CHOICE(authenticate_manifest); diff --git a/subsys/sdfw_services/services/suit_service/suit_invoke.c b/subsys/sdfw_services/services/suit_service/suit_invoke.c new file mode 100644 index 000000000000..0ec445de2a4d --- /dev/null +++ b/subsys/sdfw_services/services/suit_service/suit_invoke.c @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include +#include "suit_service_types.h" +#include +#include "suit_service_utils.h" + +#include +LOG_MODULE_REGISTER(suit_srvc_invoke, CONFIG_SSF_SUIT_SERVICE_LOG_LEVEL); + +extern const struct ssf_client_srvc suit_srvc; + +suit_ssf_err_t suit_execution_mode_read(suit_execution_mode_t *mode) +{ + int ret; + struct suit_req req; + struct suit_rsp rsp; + struct suit_execution_mode_read_rsp *rsp_data; + const uint8_t *rsp_pkt; + + if (mode == NULL) { + return SUIT_PLAT_ERR_INVAL; + } + + memset(&req, 0, sizeof(struct suit_req)); + req.suit_req_msg_choice = SSF_SUIT_REQ_CHOICE(execution_mode_read); + + ret = ssf_client_send_request(&suit_srvc, &req, &rsp, &rsp_pkt); + if (ret != 0) { + ssf_client_decode_done(rsp_pkt); + return SUIT_PLAT_ERR_IPC; + } + + rsp_data = &rsp.SSF_SUIT_RSP(execution_mode_read); + ret = rsp_data->SSF_SUIT_RSP_ARG(execution_mode_read, ret); + if (ret != SUIT_PLAT_SUCCESS) { + ssf_client_decode_done(rsp_pkt); + return ret; + } + + *mode = (suit_execution_mode_t)rsp_data->SSF_SUIT_RSP_ARG(execution_mode_read, + execution_mode); + + ssf_client_decode_done(rsp_pkt); + + return ret; +} + +suit_ssf_err_t suit_invoke_confirm(int ret); +{ + int ret; + struct suit_req req; + struct suit_rsp rsp; + struct suit_invoke_confirm_req *req_data; + + memset(&req, 0, sizeof(struct suit_req)); + req.suit_req_msg_choice = SSF_SUIT_REQ_CHOICE(invoke_confirm); + req_data = &req.SSF_SUIT_REQ(invoke_confirm); + req_data->SSF_SUIT_REQ_ARG(invoke_confirm, ret) = ret; + + ret = ssf_client_send_request(&suit_srvc, &req, &rsp, NULL); + if (ret != 0) { + return SUIT_PLAT_ERR_IPC; + } + + return rsp.SSF_SUIT_RSP(invoke_confirm).SSF_SUIT_RSP_ARG(invoke_confirm, ret); +} + +suit_ssf_err_t suit_boot_flags_reset(void) +{ + int ret; + struct suit_req req; + struct suit_rsp rsp; + + memset(&req, 0, sizeof(struct suit_req)); + req.suit_req_msg_choice = SSF_SUIT_REQ_CHOICE(boot_flags_reset); + + ret = ssf_client_send_request(&suit_srvc, &req, &rsp, NULL); + if (ret != 0) { + return SUIT_PLAT_ERR_IPC; + } + + return rsp.SSF_SUIT_RSP(boot_flags_reset).SSF_SUIT_RSP_ARG(boot_flags_reset, ret); +} + +suit_ssf_err_t suit_foreground_dfu_required(void) +{ + int ret; + struct suit_req req; + struct suit_rsp rsp; + + memset(&req, 0, sizeof(struct suit_req)); + req.suit_req_msg_choice = SSF_SUIT_REQ_CHOICE(foreground_dfu_required); + + ret = ssf_client_send_request(&suit_srvc, &req, &rsp, NULL); + if (ret != 0) { + return SUIT_PLAT_ERR_IPC; + } + + return rsp.SSF_SUIT_RSP(foreground_dfu_required) + .SSF_SUIT_RSP_ARG(foreground_dfu_required, ret); +} From 3a8f98b1640a9a8a92bfa8e124c45c49c7a7a1c0 Mon Sep 17 00:00:00 2001 From: Tomasz Chyrowicz Date: Mon, 4 Nov 2024 15:09:04 +0100 Subject: [PATCH 3/3] suit: Introduce foreground DFU states Introduce missing values for foreground DFU in SUIT execution mode as well as SUIT orchestrator module. Ref: NCSDK-29996 Signed-off-by: Tomasz Chyrowicz --- .../include/suit_execution_mode.h | 36 +++-- .../execution_mode/src/suit_execution_mode.c | 32 +++++ subsys/suit/mci/src/suit_mci_nrf54h20.c | 8 +- .../orchestrator/src/suit_orchestrator_sdfw.c | 132 +++++++++++++++--- 4 files changed, 174 insertions(+), 34 deletions(-) diff --git a/subsys/suit/execution_mode/include/suit_execution_mode.h b/subsys/suit/execution_mode/include/suit_execution_mode.h index e0ad434eba78..5fdfc1cb603c 100644 --- a/subsys/suit/execution_mode/include/suit_execution_mode.h +++ b/subsys/suit/execution_mode/include/suit_execution_mode.h @@ -14,21 +14,31 @@ extern "C" { #endif +/** + * @brief SUIT orchestrator execution mode. + * + * @note Do not modify existing values. + * They are sent over SSF to the application companion images. + */ typedef enum { EXECUTION_MODE_STARTUP = 0, - EXECUTION_MODE_INVOKE, - EXECUTION_MODE_INVOKE_RECOVERY, - EXECUTION_MODE_INSTALL, - EXECUTION_MODE_INSTALL_RECOVERY, - EXECUTION_MODE_POST_INVOKE, - EXECUTION_MODE_POST_INVOKE_RECOVERY, - EXECUTION_MODE_FAIL_NO_MPI, - EXECUTION_MODE_FAIL_MPI_INVALID, - EXECUTION_MODE_FAIL_MPI_INVALID_MISSING, - EXECUTION_MODE_FAIL_MPI_UNSUPPORTED, - EXECUTION_MODE_FAIL_INVOKE_RECOVERY, - EXECUTION_MODE_FAIL_INSTALL_NORDIC_TOP, - EXECUTION_MODE_FAIL_STARTUP, + EXECUTION_MODE_INVOKE = 1, + EXECUTION_MODE_INVOKE_FDFU = 2, + EXECUTION_MODE_INVOKE_RECOVERY = 3, + EXECUTION_MODE_INSTALL = 4, + EXECUTION_MODE_INSTALL_FDFU = 5, + EXECUTION_MODE_INSTALL_RECOVERY = 6, + EXECUTION_MODE_POST_INVOKE = 7, + EXECUTION_MODE_POST_INVOKE_FDFU = 8, + EXECUTION_MODE_POST_INVOKE_RECOVERY = 9, + EXECUTION_MODE_FAIL_NO_MPI = 10, + EXECUTION_MODE_FAIL_MPI_INVALID = 11, + EXECUTION_MODE_FAIL_MPI_INVALID_MISSING = 12, + EXECUTION_MODE_FAIL_MPI_UNSUPPORTED = 13, + EXECUTION_MODE_FAIL_INVOKE_FDFU = 14, + EXECUTION_MODE_FAIL_INVOKE_RECOVERY = 15, + EXECUTION_MODE_FAIL_INSTALL_NORDIC_TOP = 16, + EXECUTION_MODE_FAIL_STARTUP = 17, } suit_execution_mode_t; /** diff --git a/subsys/suit/execution_mode/src/suit_execution_mode.c b/subsys/suit/execution_mode/src/suit_execution_mode.c index b9ffba4e322a..aed32a6b82d7 100644 --- a/subsys/suit/execution_mode/src/suit_execution_mode.c +++ b/subsys/suit/execution_mode/src/suit_execution_mode.c @@ -33,10 +33,14 @@ void suit_execution_mode_startup_failed(void) case EXECUTION_MODE_FAIL_INSTALL_NORDIC_TOP: /* SUIT processes update candiadate. */ case EXECUTION_MODE_INSTALL: + /* SUIT processes recovery as foreground update. */ + case EXECUTION_MODE_INSTALL_FDFU: /* SUIT processes recovery update. */ case EXECUTION_MODE_INSTALL_RECOVERY: /* SUIT boots from root manifest. */ case EXECUTION_MODE_INVOKE: + /* SUIT boots from recovery manifest as foreground update. */ + case EXECUTION_MODE_INVOKE_FDFU: /* SUIT boots from recovery manifest. */ case EXECUTION_MODE_INVOKE_RECOVERY: current_execution_mode = EXECUTION_MODE_FAIL_STARTUP; @@ -50,10 +54,14 @@ void suit_execution_mode_startup_failed(void) case EXECUTION_MODE_FAIL_MPI_INVALID_MISSING: /* System not booted, MPI misconfigured. */ case EXECUTION_MODE_FAIL_MPI_UNSUPPORTED: + /* System not booted, unable to boot recovery manifest as foreground update. */ + case EXECUTION_MODE_FAIL_INVOKE_FDFU: /* System not booted, unable to boot recovery manifest. */ case EXECUTION_MODE_FAIL_INVOKE_RECOVERY: /* System booted from root manifest. */ case EXECUTION_MODE_POST_INVOKE: + /* System booted from recovery manifest as foreground update. */ + case EXECUTION_MODE_POST_INVOKE_FDFU: /* System booted from recovery manifest. */ case EXECUTION_MODE_POST_INVOKE_RECOVERY: /* System failed before invoking SUIT orchestrator. */ @@ -68,12 +76,16 @@ bool suit_execution_mode_booting(void) switch (current_execution_mode) { /* SUIT processes update candiadate. */ case EXECUTION_MODE_INSTALL: + /* SUIT processes recovery as foreground update. */ + case EXECUTION_MODE_INSTALL_FDFU: /* SUIT processes recovery update. */ case EXECUTION_MODE_INSTALL_RECOVERY: /* System is unprovisioned, SUIT updates Nordic components. */ case EXECUTION_MODE_FAIL_INSTALL_NORDIC_TOP: /* System booted from root manifest. */ case EXECUTION_MODE_POST_INVOKE: + /* System booted from recovery manifest as foreground update. */ + case EXECUTION_MODE_POST_INVOKE_FDFU: /* System booted from recovery manifest. */ case EXECUTION_MODE_POST_INVOKE_RECOVERY: /* System not booted, application MPI missing. */ @@ -84,6 +96,8 @@ bool suit_execution_mode_booting(void) case EXECUTION_MODE_FAIL_MPI_INVALID_MISSING: /* System not booted, MPI misconfigured. */ case EXECUTION_MODE_FAIL_MPI_UNSUPPORTED: + /* System not booted, unable to boot recovery manifest as foreground update. */ + case EXECUTION_MODE_FAIL_INVOKE_FDFU: /* System not booted, unable to boot recovery manifest. */ case EXECUTION_MODE_FAIL_INVOKE_RECOVERY: /* System failed before invoking SUIT orchestrator. */ @@ -94,6 +108,8 @@ bool suit_execution_mode_booting(void) case EXECUTION_MODE_STARTUP: /* SUIT boots from root manifest. */ case EXECUTION_MODE_INVOKE: + /* SUIT boots from recovery manifest as foreground update. */ + case EXECUTION_MODE_INVOKE_FDFU: /* SUIT boots from recovery manifest. */ case EXECUTION_MODE_INVOKE_RECOVERY: break; @@ -108,10 +124,14 @@ bool suit_execution_mode_updating(void) switch (current_execution_mode) { /* SUIT boots from root manifest. */ case EXECUTION_MODE_INVOKE: + /* SUIT boots from recovery manifest as foreground update. */ + case EXECUTION_MODE_INVOKE_FDFU: /* SUIT boots from recovery manifest. */ case EXECUTION_MODE_INVOKE_RECOVERY: /* System booted from root manifest. */ case EXECUTION_MODE_POST_INVOKE: + /* System booted from recovery manifest as foreground update. */ + case EXECUTION_MODE_POST_INVOKE_FDFU: /* System booted from recovery manifest. */ case EXECUTION_MODE_POST_INVOKE_RECOVERY: /* System not booted, application MPI missing. */ @@ -122,6 +142,8 @@ bool suit_execution_mode_updating(void) case EXECUTION_MODE_FAIL_MPI_INVALID_MISSING: /* System not booted, MPI misconfigured. */ case EXECUTION_MODE_FAIL_MPI_UNSUPPORTED: + /* System not booted, unable to boot recovery manifest as foreground update. */ + case EXECUTION_MODE_FAIL_INVOKE_FDFU: /* System not booted, unable to boot recovery manifest. */ case EXECUTION_MODE_FAIL_INVOKE_RECOVERY: /* System failed before invoking SUIT orchestrator. */ @@ -132,6 +154,8 @@ bool suit_execution_mode_updating(void) case EXECUTION_MODE_STARTUP: /* SUIT processes update candiadate. */ case EXECUTION_MODE_INSTALL: + /* SUIT processes recovery as foreground update. */ + case EXECUTION_MODE_INSTALL_FDFU: /* SUIT processes recovery update. */ case EXECUTION_MODE_INSTALL_RECOVERY: /* System is unprovisioned, SUIT updates Nordic components. */ @@ -150,14 +174,20 @@ bool suit_execution_mode_failed(void) case EXECUTION_MODE_STARTUP: /* SUIT processes update candiadate. */ case EXECUTION_MODE_INSTALL: + /* SUIT processes recovery as foreground update. */ + case EXECUTION_MODE_INSTALL_FDFU: /* SUIT processes recovery update. */ case EXECUTION_MODE_INSTALL_RECOVERY: /* SUIT boots from root manifest. */ case EXECUTION_MODE_INVOKE: + /* SUIT boots from recovery manifest as foreground update. */ + case EXECUTION_MODE_INVOKE_FDFU: /* SUIT boots from recovery manifest. */ case EXECUTION_MODE_INVOKE_RECOVERY: /* System booted from root manifest. */ case EXECUTION_MODE_POST_INVOKE: + /* System booted from recovery manifest as foreground update. */ + case EXECUTION_MODE_POST_INVOKE_FDFU: /* System booted from recovery manifest. */ case EXECUTION_MODE_POST_INVOKE_RECOVERY: /* System is unprovisioned, SUIT updates Nordic components. */ @@ -172,6 +202,8 @@ bool suit_execution_mode_failed(void) case EXECUTION_MODE_FAIL_MPI_INVALID_MISSING: /* System not booted, MPI misconfigured. */ case EXECUTION_MODE_FAIL_MPI_UNSUPPORTED: + /* System not booted, unable to boot recovery manifest as foreground update. */ + case EXECUTION_MODE_FAIL_INVOKE_FDFU: /* System not booted, unable to boot recovery manifest. */ case EXECUTION_MODE_FAIL_INVOKE_RECOVERY: /* System failed before invoking SUIT orchestrator. */ diff --git a/subsys/suit/mci/src/suit_mci_nrf54h20.c b/subsys/suit/mci/src/suit_mci_nrf54h20.c index ba0ee1b09b30..05ffef40ee3e 100644 --- a/subsys/suit/mci/src/suit_mci_nrf54h20.c +++ b/subsys/suit/mci/src/suit_mci_nrf54h20.c @@ -60,6 +60,7 @@ mci_err_t suit_mci_invoke_order_get(const suit_manifest_class_id_t **class_id, s } break; + case EXECUTION_MODE_INVOKE_FDFU: case EXECUTION_MODE_INVOKE_RECOVERY: if (suit_storage_mpi_class_get(SUIT_MANIFEST_SEC_TOP, &class_id[0]) != SUIT_PLAT_SUCCESS) { @@ -143,8 +144,11 @@ mci_err_t suit_mci_independent_update_policy_get(const suit_manifest_class_id_t * update candidate before resetting the SoC. */ switch (suit_execution_mode_get()) { + case EXECUTION_MODE_INVOKE_FDFU: case EXECUTION_MODE_INVOKE_RECOVERY: + case EXECUTION_MODE_INSTALL_FDFU: case EXECUTION_MODE_INSTALL_RECOVERY: + case EXECUTION_MODE_POST_INVOKE_FDFU: case EXECUTION_MODE_POST_INVOKE_RECOVERY: if ((role == SUIT_MANIFEST_APP_RECOVERY) || (role == SUIT_MANIFEST_RAD_RECOVERY)) { *policy = SUIT_INDEPENDENT_UPDATE_DENIED; @@ -248,7 +252,7 @@ mci_err_t suit_mci_signing_key_id_validate(const suit_manifest_class_id_t *class return SUIT_PLAT_SUCCESS; } else if ((mpi->signature_verification_policy == SUIT_MPI_SIGNATURE_CHECK_ENABLED_ON_UPDATE) && - (suit_execution_mode_get() == EXECUTION_MODE_INVOKE)) { + suit_execution_mode_booting()) { /* By allowing key_id == 0 in the invoke path, the platform will verify * the signature only during updates. */ @@ -641,6 +645,7 @@ suit_mci_manifest_process_dependency_validate(const suit_manifest_class_id_t *pa } break; + case EXECUTION_MODE_INSTALL_FDFU: case EXECUTION_MODE_INSTALL_RECOVERY: if ((parent_role == SUIT_MANIFEST_SEC_TOP) && ((child_role == SUIT_MANIFEST_SEC_SYSCTRL) || @@ -658,6 +663,7 @@ suit_mci_manifest_process_dependency_validate(const suit_manifest_class_id_t *pa } break; + case EXECUTION_MODE_INVOKE_FDFU: case EXECUTION_MODE_INVOKE_RECOVERY: if ((parent_role == SUIT_MANIFEST_SEC_TOP) && ((child_role == SUIT_MANIFEST_SEC_SYSCTRL) || diff --git a/subsys/suit/orchestrator/src/suit_orchestrator_sdfw.c b/subsys/suit/orchestrator/src/suit_orchestrator_sdfw.c index 74f785cbfafa..c35b8c447fcc 100644 --- a/subsys/suit/orchestrator/src/suit_orchestrator_sdfw.c +++ b/subsys/suit/orchestrator/src/suit_orchestrator_sdfw.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -29,10 +30,12 @@ LOG_MODULE_REGISTER(suit_orchestrator, CONFIG_SUIT_LOG_LEVEL); enum suit_orchestrator_state { STATE_STARTUP, STATE_INVOKE, + STATE_INVOKE_FDFU, STATE_INVOKE_RECOVERY, STATE_INSTALL, STATE_INSTALL_RECOVERY, STATE_POST_INVOKE, + STATE_POST_INVOKE_FDFU, STATE_POST_INVOKE_RECOVERY, STATE_POST_INSTALL, STATE_ENTER_RECOVERY, @@ -40,36 +43,45 @@ enum suit_orchestrator_state { STATE_POST_INSTALL_NORDIC_TOP, }; -static suit_plat_err_t storage_emergency_flag_get(bool *flag) +static suit_plat_err_t storage_boot_flags_get(bool *recovery_flag, bool *fdfu_flag) { const uint8_t *fail_report; size_t fail_report_len; suit_plat_err_t ret = suit_storage_report_read(0, &fail_report, &fail_report_len); - if (flag == NULL) { + if ((recovery_flag == NULL) || (fdfu_flag == NULL)) { return SUIT_PLAT_ERR_INVAL; } + *fdfu_flag = false; + if (ret == SUIT_PLAT_ERR_NOT_FOUND) { - *flag = false; + *recovery_flag = false; } else if (ret == SUIT_PLAT_SUCCESS) { - *flag = true; + if (fail_report_len > 0) { + *recovery_flag = true; + } else { + *recovery_flag = false; + *fdfu_flag = true; + } } else { LOG_ERR("Unable to read recovery flag: %d", ret); - *flag = true; + *recovery_flag = true; return ret; } return SUIT_PLAT_SUCCESS; } -static int enter_emergency_recovery(void) +static int enter_emergency_recovery(int ret) { - /* TODO: Report boot status */ - suit_plat_err_t ret = suit_storage_report_save(0, NULL, 0); + uint32_t orchestrator_ret = (uint32_t)ret; - if (ret != SUIT_PLAT_SUCCESS) { - LOG_ERR("Unable to set recovery flag: %d", ret); + suit_plat_err_t plat_ret = suit_storage_report_save(0, (const uint8_t *)&orchestrator_ret, + sizeof(orchestrator_ret)); + + if (plat_ret != SUIT_PLAT_SUCCESS) { + LOG_ERR("Unable to set recovery flag: %d", plat_ret); return -EIO; } @@ -327,22 +339,69 @@ static int boot_envelope(const suit_manifest_class_id_t *class_id) return 0; } +static int orchestrator_error(const suit_manifest_class_id_t *class_id, int ret) +{ + suit_manifest_role_t role = SUIT_MANIFEST_UNKNOWN; + uint32_t mode = 0b111111; + + /* Return zero if error code should not be saved. */ + if (ret == 0) { + return ret; + } + + /* Filter error codes, that cannot be saved on 8 bits. */ + if ((ret > 0) || (ret < -255)) { + ret = 255; + } else { + ret = -ret; + } + + /* Fetch the manifest role, for which the error happened. */ + if (class_id != NULL) { + if (suit_storage_mpi_role_get(class_id, &role) != SUIT_PLAT_SUCCESS) { + role = SUIT_MANIFEST_UNKNOWN; + } + } + /* Filter roles, that cannot be saved on 8 bits. */ + if ((uint32_t)role > 0xFF) { + role = (suit_manifest_role_t)0xFF; + } + + /* Fetch the execution mode, in which the error happened. */ + mode = (uint32_t)suit_execution_mode_get(); + /* Filter execution modes, that cannot be saved on 6 bits. */ + if (mode > 0b00111111) { + mode = 0b00111111; + } + + return (mode << 24) | ((uint32_t)role << 16) | (ret << 8); +} + +static int orchestrator_error_to_zephyr_err(int ret) +{ + int zephyr_ret = ret & 0xFF00; + + zephyr_ret >>= 8; + + return -zephyr_ret; +} + static int boot_path(bool emergency) { const suit_manifest_class_id_t *class_ids_to_boot[CONFIG_SUIT_STORAGE_N_ENVELOPES] = {NULL}; size_t class_ids_to_boot_len = ARRAY_SIZE(class_ids_to_boot); + const suit_manifest_class_id_t *class_id = NULL; int ret = 0; mci_err_t mci_ret = suit_mci_invoke_order_get( (const suit_manifest_class_id_t **)&class_ids_to_boot, &class_ids_to_boot_len); if (mci_ret != SUIT_PLAT_SUCCESS) { LOG_ERR("Unable to get invoke order (MCI err: %d)", mci_ret); - return -ENOEXEC; + return orchestrator_error(class_id, -ENOEXEC); } for (size_t i = 0; i < class_ids_to_boot_len; i++) { - const suit_manifest_class_id_t *class_id = - (const suit_manifest_class_id_t *)class_ids_to_boot[i]; + class_id = (const suit_manifest_class_id_t *)class_ids_to_boot[i]; ret = boot_envelope(class_id); if (ret != 0) { @@ -357,7 +416,7 @@ static int boot_path(bool emergency) */ continue; } - return ret; + return orchestrator_error(class_id, ret); } LOG_INF("Manifest %d/%d booted", i + 1, class_ids_to_boot_len); @@ -365,12 +424,13 @@ static int boot_path(bool emergency) SUIT_MANIFEST_CLASS_ID_LOG_ARGS(class_id)); } - return ret; + return orchestrator_error(class_id, ret); } int suit_orchestrator_init(void) { bool emergency_flag = true; + bool fdfu_flag = false; const suit_plat_mreg_t *update_regions = NULL; size_t update_regions_len = 0; @@ -453,20 +513,24 @@ int suit_orchestrator_init(void) update_regions_len = 0; } - plat_err = storage_emergency_flag_get(&emergency_flag); + plat_err = storage_boot_flags_get(&emergency_flag, &fdfu_flag); if (plat_err != SUIT_PLAT_SUCCESS) { LOG_WRN("Unable to read emergency flag: %d", plat_err); emergency_flag = true; } if (update_regions_len > 0) { - if (emergency_flag == false) { + if (fdfu_flag == true) { + plat_err = suit_execution_mode_set(EXECUTION_MODE_INSTALL_FDFU); + } else if (emergency_flag == false) { plat_err = suit_execution_mode_set(EXECUTION_MODE_INSTALL); } else { plat_err = suit_execution_mode_set(EXECUTION_MODE_INSTALL_RECOVERY); } } else { - if (emergency_flag == false) { + if (fdfu_flag == true) { + plat_err = suit_execution_mode_set(EXECUTION_MODE_INVOKE_FDFU); + } else if (emergency_flag == false) { plat_err = suit_execution_mode_set(EXECUTION_MODE_INVOKE); } else { plat_err = suit_execution_mode_set(EXECUTION_MODE_INVOKE_RECOVERY); @@ -492,12 +556,16 @@ static int suit_orchestrator_run(void) case EXECUTION_MODE_INVOKE: state = STATE_INVOKE; break; + case EXECUTION_MODE_INVOKE_FDFU: + state = STATE_INVOKE_FDFU; + break; case EXECUTION_MODE_INVOKE_RECOVERY: state = STATE_INVOKE_RECOVERY; break; case EXECUTION_MODE_INSTALL: state = STATE_INSTALL; break; + case EXECUTION_MODE_INSTALL_FDFU: case EXECUTION_MODE_INSTALL_RECOVERY: state = STATE_INSTALL_RECOVERY; break; @@ -514,9 +582,11 @@ static int suit_orchestrator_run(void) case EXECUTION_MODE_FAIL_MPI_UNSUPPORTED: return -ENOTSUP; + case EXECUTION_MODE_FAIL_INVOKE_FDFU: case EXECUTION_MODE_FAIL_INVOKE_RECOVERY: case EXECUTION_MODE_STARTUP: case EXECUTION_MODE_POST_INVOKE: + case EXECUTION_MODE_POST_INVOKE_FDFU: case EXECUTION_MODE_POST_INVOKE_RECOVERY: default: break; @@ -602,10 +672,16 @@ static int suit_orchestrator_run(void) state = STATE_POST_INVOKE_RECOVERY; break; + case STATE_INVOKE_FDFU: + LOG_INF("Foreground update boot path"); + ret = boot_path(true); + state = STATE_POST_INVOKE_FDFU; + break; + case STATE_ENTER_RECOVERY: LOG_INF("Enter recovery mode"); - ret = enter_emergency_recovery(); + ret = enter_emergency_recovery(ret); if (ret != 0) { LOG_WRN("Unable to enter emergency recovery: %d", ret); } @@ -638,7 +714,23 @@ static int suit_orchestrator_run(void) "RECOVERY"); } } - return ret; + return orchestrator_error_to_zephyr_err(ret); + + case STATE_POST_INVOKE_FDFU: + if (ret == 0) { + if (suit_execution_mode_set(EXECUTION_MODE_POST_INVOKE_FDFU) != + SUIT_PLAT_SUCCESS) { + LOG_WRN("Unable to change execution mode to INVOKE " + "FDFU"); + } + } else { + if (suit_execution_mode_set(EXECUTION_MODE_FAIL_INVOKE_FDFU) != + SUIT_PLAT_SUCCESS) { + LOG_WRN("Unable to change execution mode to FAIL INVOKE " + "FDFU"); + } + } + return orchestrator_error_to_zephyr_err(ret); default: LOG_ERR("Invalid state: %d", state);