|
| 1 | +/* |
| 2 | + * Copyright (c) 2025 Nordic Semiconductor ASA |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | + |
| 6 | +#ifndef ZEPHYR_INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_NRF_IRONSIDE_UPDATE_H_ |
| 7 | +#define ZEPHYR_INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_NRF_IRONSIDE_UPDATE_H_ |
| 8 | + |
| 9 | +#include <stdint.h> |
| 10 | +#include <stddef.h> |
| 11 | + |
| 12 | +/** |
| 13 | + * @name Update service error codes. |
| 14 | + * @{ |
| 15 | + */ |
| 16 | + |
| 17 | +/** Caller does not have access to the provided update candidate buffer. */ |
| 18 | +#define IRONSIDE_UPDATE_ERROR_NOT_PERMITTED (1) |
| 19 | +/** Failed to write the update metadata to SICR. */ |
| 20 | +#define IRONSIDE_UPDATE_ERROR_SICR_WRITE_FAILED (2) |
| 21 | + |
| 22 | +/** |
| 23 | + * @} |
| 24 | + */ |
| 25 | + |
| 26 | +/** Length of the update manifest in bytes */ |
| 27 | +#define IRONSIDE_UPDATE_MANIFEST_LENGTH (256) |
| 28 | +/** Length of the update public key in bytes. */ |
| 29 | +#define IRONSIDE_UPDATE_PUBKEY_LENGTH (32) |
| 30 | +/** Length of the update signature in bytes. */ |
| 31 | +#define IRONSIDE_UPDATE_SIGNATURE_LENGTH (64) |
| 32 | + |
| 33 | +/* IRONside call identifiers with implicit versions. |
| 34 | + * |
| 35 | + * With the initial "version 0", the service ABI is allowed to break until the |
| 36 | + * first production release of IRONside SE. |
| 37 | + */ |
| 38 | +#define IRONSIDE_CALL_ID_UPDATE_SERVICE_V0 1 |
| 39 | + |
| 40 | +/* Index of the update blob pointer within the service buffer. */ |
| 41 | +#define IRONSIDE_UPDATE_SERVICE_UPDATE_PTR_IDX (0) |
| 42 | +/* Index of the return code within the service buffer. */ |
| 43 | +#define IRONSIDE_UPDATE_SERVICE_RETCODE_IDX (0) |
| 44 | + |
| 45 | +/** |
| 46 | + * @brief IRONside update blob. |
| 47 | + */ |
| 48 | +struct ironside_update_blob { |
| 49 | + uint8_t manifest[IRONSIDE_UPDATE_MANIFEST_LENGTH]; |
| 50 | + uint8_t pubkey[IRONSIDE_UPDATE_PUBKEY_LENGTH]; |
| 51 | + uint8_t signature[IRONSIDE_UPDATE_SIGNATURE_LENGTH]; |
| 52 | + uint32_t firmware[]; |
| 53 | +}; |
| 54 | + |
| 55 | +/** |
| 56 | + * @brief Request a firmware upgrade of the IRONside SE. |
| 57 | + * |
| 58 | + * This invokes the IRONside SE update service. The device must be restarted for the update |
| 59 | + * to be installed. Check the update status in the application boot report to see if the update |
| 60 | + * was successfully installed. |
| 61 | + * |
| 62 | + * @param update Pointer to update blob |
| 63 | + * |
| 64 | + * @retval -IRONSIDE_UPDATE_ERROR_NOT_PERMITTED if missing access to the update candidate. |
| 65 | + * @retval -IRONSIDE_UPDATE_ERROR_SICR_WRITE_FAILED if writing update parameters to SICR failed. |
| 66 | + * @returns Positive non-0 error status if reported by IRONside call. |
| 67 | + * @returns 0 on a successful request (although the update itself may still fail). |
| 68 | + * |
| 69 | + */ |
| 70 | +int ironside_update(const struct ironside_update_blob *update); |
| 71 | + |
| 72 | +#endif /* ZEPHYR_INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_NRF_IRONSIDE_UPDATE_H_ */ |
0 commit comments