@@ -762,39 +762,31 @@ typedef struct {
762762 void * n_ptr ;
763763} elf_note_content_t ;
764764
765+ esp_err_t esp_core_dump_partition_and_size_get (const esp_partition_t * * partition , uint32_t * size );
766+
765767/* Below are the helper function to parse the core dump ELF stored in flash */
766768static esp_err_t elf_core_dump_image_mmap (esp_partition_mmap_handle_t * core_data_handle , const void * * map_addr )
767769{
768- size_t out_size ;
770+ const esp_partition_t * core_part = NULL ;
771+ uint32_t out_size ;
769772 assert (core_data_handle );
770773 assert (map_addr );
771774
772- /* Find the partition that could potentially contain a (previous) core dump. */
773- const esp_partition_t * core_part = esp_partition_find_first (ESP_PARTITION_TYPE_DATA ,
774- ESP_PARTITION_SUBTYPE_DATA_COREDUMP ,
775- NULL );
776- if (!core_part ) {
777- ESP_COREDUMP_LOGE ("Core dump partition not found!" );
778- return ESP_ERR_NOT_FOUND ;
779- }
780- if (core_part -> size < sizeof (uint32_t )) {
781- ESP_COREDUMP_LOGE ("Core dump partition too small!" );
782- return ESP_ERR_INVALID_SIZE ;
775+ /* Retrieve the partition and size. */
776+ esp_err_t err = esp_core_dump_partition_and_size_get (& core_part , & out_size );
777+ if (err != ESP_OK ) {
778+ return err ;
783779 }
780+
784781 /* Data read from the mmapped core dump partition will be garbage if flash
785782 * encryption is enabled in hardware and core dump partition is not encrypted
786783 */
787784 if (esp_flash_encryption_enabled () && !core_part -> encrypted ) {
788785 ESP_COREDUMP_LOGE ("Flash encryption enabled in hardware and core dump partition is not encrypted!" );
789786 return ESP_ERR_NOT_SUPPORTED ;
790787 }
791- /* Read the size of the core dump file from the partition */
792- esp_err_t ret = esp_partition_read (core_part , 0 , & out_size , sizeof (uint32_t ));
793- if (ret != ESP_OK ) {
794- ESP_COREDUMP_LOGE ("Failed to read core dump data size" );
795- return ret ;
796- }
797- /* map the full core dump parition, including the checksum. */
788+
789+ /* map the full core dump partition, including the checksum. */
798790 return esp_partition_mmap (core_part , 0 , out_size , ESP_PARTITION_MMAP_DATA ,
799791 map_addr , core_data_handle );
800792}
0 commit comments