Coredump

User avatar
urbanze
Posts: 295
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Coredump

Postby urbanze » Tue Mar 19, 2019 11:49 am

I will use coredump in products of my work to futures debugs and need to save it in flash to read later but...

How can I read this coredump in flash to (e.g) show in html or sms or.... ?

ESP_Sprite
Posts: 9051
Joined: Thu Nov 26, 2015 4:08 am

Re: Coredump

Postby ESP_Sprite » Tue Mar 19, 2019 12:40 pm

The coredump is written to a partition; you could read out that partition on the ESP32 and e.g. send its contents off to a server.

User avatar
urbanze
Posts: 295
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: Coredump

Postby urbanze » Tue Mar 19, 2019 12:50 pm

ESP_Sprite wrote:
Tue Mar 19, 2019 12:40 pm
The coredump is written to a partition; you could read out that partition on the ESP32 and e.g. send its contents off to a server.
Which functions do I use for this? I read what range of partition address?

ESP_Sprite
Posts: 9051
Joined: Thu Nov 26, 2015 4:08 am

Re: Coredump

Postby ESP_Sprite » Tue Mar 19, 2019 2:19 pm

ESP-IDF has a bunch of functions to find partitions and read/write them.

Ritesh
Posts: 1365
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Coredump

Postby Ritesh » Wed Mar 20, 2019 8:49 am

Hi,

You can also use SPIFFS file system to store crash logs into flash.

Also, There are support into ESP32 IDF using menuconfig to store crash dumps into SPI Flash directly so that you can read it on next reboot based on your requirements.
Regards,
Ritesh Prajapati

User avatar
urbanze
Posts: 295
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: Coredump

Postby urbanze » Wed Mar 20, 2019 4:21 pm

Tried with esp_partition() functions and getting some issues....

See printf() output: When I print(%s), notting usefull appears, but print(%c) or %x works and show some infos, I only can see task names between all >=127d chars.

https://i.imgur.com/lnzNdj3.png

1. What addresses (start/end) I will use to get correct coredump info? Now, I reading all partition to test.
2. How can I print this to "CTRL+C" and put in terminal+script_debug? Like coredump->uart...

Code: Select all

const esp_partition_t *pt = NULL;

pt = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_COREDUMP, "coredump");
uint8_t bf[pt->size];

if (pt != NULL)
{
	esp_err_t er = esp_partition_read(pt, 0, bf, pt->size);

	printf("\nCOREDUMP (%x %u %u): %s\n\n", er, pt->address, pt->size, bf);

	for (int32_t i = 0; i < pt->size; i++)
	{
		printf("%c ", bf[i]);
	}

	printf("\n\n\n");
}
part of output (in image):

Code: Select all

COREDUMP (0 3452928 65536): �Q

� Q           d    ` � � ?  � � ? X � � ? � � � ? � � � ? 2 J   � 5 � ? � 5 � ? ` � � ? � 5 � ?     � � � q p � � | ` � � ?         L � � ? l p _ B L I N K  (  � W F y  � � �  X � � ?                              ` � � ? � � � ? 0 � � ?                 = � @ ?     H   @                                                                                                                                                                                                        � � � � ?   � ?     ' " @ ? � � � ? � D � ? � 7 � ?             �   @ �   @ � � � � ' " @ ? � � � ? Y   @ � 
                                    � ?             � � ? �                             ' " @ ? � � � ? � D � ? � 7 � ?     � � � ?                                                 � � � ?                                                                                             � � � ? P � � ? � � � ? P � � ? � � � ?  � F � t 5 � ? � � � ? � � � ? l 5 � ?     � N &  t �  � � � � ?         � � � ? I D L E 1  � H � � � � Z � %      � � � ?     !                        ` � � ? � � � ? 0 � � ?                 = � @ ?     H   @

User avatar
urbanze
Posts: 295
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: Coredump

Postby urbanze » Thu Mar 21, 2019 1:07 pm

Ok, I found in cpu_start.h the function "esp_core_dump_image_get()" and getting size with this. In header of this fuction, explain about core dump header in Flash, but :?...

I priting coredump data in hex format to put in some file, but using espcoredump.py to debug no works. Whats wrong?

Command:

Code: Select all

python espcoredump.py info_corefile -t raw -c file.bin /home/ze/esp/LOGSIS/build/LOGSIS.elf
Output:

Code: Select all

A fatal error occurred: Core dump version '256' is not supported! Should be up to '1'.
Beggining of file.bin (printted with \x to use in ubuntu):

Code: Select all

\xbc\x51\x0\x0\x1\x0\x0\x0\x19\x0\x0\x0\x64\x1\x0\x0\x60\xf4\xfc\x3f\x10\xf3\xfc\x3f\x58\xf4\xfc\x3f\xb0\xf2\xfc\x3f\xf0\xf3\xfc\x3f\x32\x4a\x0\x0\x9c\x35\xfb\x3f\x9c\x35\xfb\x3f\x60\xf4\xfc\x3f\x94\x35\xfb\x3f\x17\x0\x0\x0\xd4\xbc\xdd\x71\x70\xba\

User avatar
urbanze
Posts: 295
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: Coredump

Postby urbanze » Sun Mar 24, 2019 1:27 pm

help? :(
Last edited by urbanze on Mon Mar 25, 2019 4:20 pm, edited 1 time in total.

User avatar
urbanze
Posts: 295
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: Coredump

Postby urbanze » Mon Mar 25, 2019 3:50 pm

More one try and... Sucess. :oops: :D

Steps:

1. Get core dump partition size
2. Read X bytes
3. Print Byte-Byte in 0x00 format (whitout '0x')
....
4. After all print occur, I drag this in hex -> b64 converter, save in file and use: espcoredump.py info_corefile -c COREDUMP PATH -t b64 -rom-elf PROJECT .ELF PATH

Code bellow is specific of my project, but can help someone... Basically, read 256B of partition and print (0x00 format).

Code: Select all

size_t size = 0;
size_t address = 0;
if (esp_core_dump_image_get(&address, &size) == ESP_OK)
{
	const esp_partition_t *pt = NULL;
	pt = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_COREDUMP, "coredump");
			

	if (pt != NULL)
	{
		uint8_t bf[256];
		char str_dst[640];
		int16_t toRead;

		for (int16_t i = 0; i < (size/256)+1; i++)
		{
			strcpy(str_dst, "");
			toRead = (size - i*256) > 256 ? 256 : (size - i*256);
					
			esp_err_t er = esp_partition_read(pt, i*256, bf, toRead);
			if (er != ESP_OK)
				{ESP_LOGE("ESP32", "FAIL [%x]", er); break;}

			for (int16_t j = 0; j < 256; j++)
			{
				char str_tmp[2];

				if (bf[j] <= 0x0F)
					{sprintf(str_tmp, "0%x", bf[j]);}
				else
					{sprintf(str_tmp, "%x", bf[j]);}

				strcat(str_dst, str_tmp);
			}

			printf("%s", str_dst);
		}
	}
	else
	{
		ESP_LOGE("ESP32", "Partition NULL");
	}
			
}
else
{
	ESP_LOGE("ESP32", "esp_core_dump_image_get() FAIL");
}

Simran
Posts: 2
Joined: Sat Mar 06, 2021 9:47 am

Re: Coredump

Postby Simran » Sat Mar 06, 2021 9:55 am

hi urbanze,
I have gone through this forum,I want to store crash code into esp32 flash.i am using arduino ide..esp idf master.Can you help me to write core dump to flash?How are the steps and how to config in sdkconfig at windows level.Can you share piece of code for writing core dump to flash?

Thanks you.

Who is online

Users browsing this forum: No registered users and 251 guests