-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/coredump_refactor_riscv_support_v4.3' into 'rel…
…ease/v4.3' espcoredump: code refactoring and add support for RISC-V implementation (backport v4.3) See merge request espressif/esp-idf!12680
- Loading branch information
Showing
21 changed files
with
2,125 additions
and
966 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,24 @@ | ||
idf_component_register(SRCS "src/core_dump_common.c" | ||
"src/core_dump_flash.c" | ||
"src/core_dump_port.c" | ||
"src/core_dump_uart.c" | ||
"src/core_dump_elf.c" | ||
set(srcs "src/core_dump_common.c" | ||
"src/core_dump_checksum.c" | ||
"src/core_dump_flash.c" | ||
"src/core_dump_uart.c" | ||
"src/core_dump_elf.c" | ||
"src/core_dump_binary.c") | ||
|
||
set(priv_includes "include_core_dump") | ||
|
||
idf_build_get_property(target IDF_TARGET) | ||
|
||
if(CONFIG_IDF_TARGET_ARCH_XTENSA) | ||
set(srcs ${srcs} "src/port/xtensa/core_dump_port.c") | ||
set(priv_includes ${priv_includes} "include_core_dump/port/xtensa") | ||
elseif(CONFIG_IDF_TARGET_ARCH_RISCV) | ||
set(srcs ${srcs} "src/port/riscv/core_dump_port.c") | ||
set(priv_includes ${priv_includes} "include_core_dump/port/riscv") | ||
endif() | ||
|
||
idf_component_register(SRCS ${srcs} | ||
INCLUDE_DIRS "include" | ||
PRIV_INCLUDE_DIRS "include_core_dump" | ||
PRIV_INCLUDE_DIRS ${priv_includes} | ||
LDFRAGMENTS linker.lf | ||
PRIV_REQUIRES spi_flash app_update mbedtls esp_rom soc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
components/espcoredump/include_core_dump/core_dump_binary.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
|
||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
#ifndef ESP_CORE_DUMP_BINARY_H_ | ||
#define ESP_CORE_DUMP_BINARY_H_ | ||
|
||
#include "esp_core_dump_types.h" | ||
|
||
/** | ||
* @brief Initiate the binary core dump generation. | ||
* | ||
* @param info Exception frame info generated when the panic occured. | ||
* @param write_cfg Structure containing the callbacks that will be called to | ||
* write the generated core dump file. | ||
* | ||
* @return ESP_OK on success, otherwise \see esp_err_t. | ||
*/ | ||
esp_err_t esp_core_dump_write_binary(core_dump_write_config_t *write_cfg); | ||
|
||
#endif |
117 changes: 117 additions & 0 deletions
117
components/espcoredump/include_core_dump/core_dump_checksum.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
|
||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/** | ||
* @file | ||
* @brief Core dump checksum interface. | ||
* | ||
* This file contains all the functions required by the core dump component to | ||
* calculate checksums for data to write (or already written) on the flash. | ||
* Currently, both CRC32 and SHA256 are supported, but this interface is | ||
* implementation independent. | ||
*/ | ||
|
||
#ifndef CORE_DUMP_CHECKSUM_H_ | ||
#define CORE_DUMP_CHECKSUM_H_ | ||
|
||
#include <stdint.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief Maximum possible length for a checksum (regardless of the | ||
* implentation). This can be modified in the future if a new implementation | ||
* requires a larger size. | ||
*/ | ||
#define COREDUMP_CHECKSUM_MAX_LEN 32 | ||
|
||
/** | ||
* @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; | ||
|
||
/** | ||
* @brief Type returned by `esp_core_dump_checksum_finish()`. It describes a | ||
* checksum as an array of bytes. It can also be provided to `esp_core_dump_print_checksum()`. | ||
*/ | ||
typedef uint8_t* core_dump_checksum_bytes; | ||
|
||
|
||
/** | ||
* @brief Get ELF core dump version. | ||
* | ||
* @note Currently, this is used in the core dump header to recognize the | ||
* checksum used for a certain dump, as the version varies with the checksum. | ||
* | ||
* @return Version of the core dump used. | ||
*/ | ||
uint32_t esp_core_dump_elf_version(void); | ||
|
||
/** | ||
* @brief Initialize checksum calculation for the given context. | ||
* | ||
* @param wr_data Core dump checksum context to fill. | ||
*/ | ||
void esp_core_dump_checksum_init(core_dump_checksum_ctx** wr_data); | ||
|
||
/** | ||
* @brief Update checksum calculation by integrating the given data in the context. | ||
* | ||
* @param wr_data Core dump checksum context. | ||
* @param data Pointer to the data to integrate in the checksum calculation. | ||
* 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); | ||
|
||
/** | ||
* @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 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); | ||
|
||
/** | ||
* @brief Return the size of the checksums. | ||
* | ||
* @note This is equivalent to `esp_core_dump_checksum_finish(NULL, NULL)`. | ||
* | ||
* @return The size, in bytes, of the checksums. | ||
*/ | ||
uint32_t esp_core_dump_checksum_size(void); | ||
|
||
/** | ||
* @brief Print a message followed by the checksum given as a parameter. | ||
* | ||
* @note The checksum will be printed in hex format and followed by \r\n. | ||
* | ||
* @param msg Message to print before the checksum. Can be NULL. | ||
* @param checksum Checksum to print. Must not be NULL. | ||
*/ | ||
void esp_core_dump_print_checksum(const char* msg, core_dump_checksum_bytes checksum); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.