feat(coredump): use SHA ROM functions for all targets except ESP32

For ESP32, continue using mbedtls due to a required ROM patch for the SHA implementation.
For other targets, we can now leverage the ROM functions.
This commit is contained in:
Erhan Kurubas
2024-01-10 13:41:18 +01:00
parent cba1665639
commit f1d5f97719
12 changed files with 261 additions and 205 deletions
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -34,7 +34,7 @@ extern "C" {
* @brief Type describing a checksum context. It is an abstract type as it is
* implementation independent, it is defined in the C source counterpart.
*/
typedef struct core_dump_checksum_ctx core_dump_checksum_ctx;
typedef void* core_dump_checksum_ctx;
/**
* @brief Type returned by `esp_core_dump_checksum_finish()`. It describes a
@@ -42,7 +42,6 @@ typedef struct core_dump_checksum_ctx core_dump_checksum_ctx;
*/
typedef uint8_t* core_dump_checksum_bytes;
/**
* @brief Get ELF core dump version.
*
@@ -58,7 +57,7 @@ uint32_t esp_core_dump_elf_version(void);
*
* @param wr_data Core dump checksum context to fill.
*/
void esp_core_dump_checksum_init(core_dump_checksum_ctx** wr_data);
void esp_core_dump_checksum_init(void ** wr_data);
/**
* @brief Update checksum calculation by integrating the given data in the context.
@@ -68,20 +67,19 @@ void esp_core_dump_checksum_init(core_dump_checksum_ctx** wr_data);
* This is usually the new data to write (or already written) on
* the flash.
*/
void esp_core_dump_checksum_update(core_dump_checksum_ctx* wr_data, void* data, size_t data_len);
void esp_core_dump_checksum_update(void* wr_data, void* data, size_t data_len);
/**
* @brief Terminate and return checksum calculated for the given context.
*
* @param wr_data Core dump checksum context. It can be NULL only if chs_ptr is
* also NULL.
* @param wr_data Core dump checksum context.
* @param chs_ptr Pointer used to return the checksum calculated. It can be
* NULL, in this case, it will be ignored but the correct size
* of the checksum will be returned.
*
* @return The size, in bytes, of the checksum.
*/
uint32_t esp_core_dump_checksum_finish(core_dump_checksum_ctx* wr_data, core_dump_checksum_bytes* chs_ptr);
uint32_t esp_core_dump_checksum_finish(void* wr_data, core_dump_checksum_bytes* chs_ptr);
/**
* @brief Return the size of the checksums.
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -96,16 +96,14 @@ extern "C" {
*/
#define COREDUMP_VERSION_CHIP CONFIG_IDF_FIRMWARE_CHIP_ID
typedef struct _core_dump_write_data_t
{
uint32_t off; /*!< Current offset of data being written */
uint8_t cached_data[COREDUMP_CACHE_SIZE]; /*!< Cache used to write to flash */
uint8_t cached_bytes; /*!< Number of bytes filled in the cached */
core_dump_checksum_ctx* checksum_ctx; /*!< Checksum context */
void *checksum_ctx; /*!< Checksum context */
} core_dump_write_data_t;
/**
* @brief Types below define the signatures of the callbacks that are used
* to output a core dump. The destination of the dump is implementation