Reading core dump from flash
Posted: Tue Apr 16, 2019 10:55 am
Hey everyone,
I wrote the following portion of code to read the coredump from flash:
This seems to be perfectly fine in my opinion although it returns the following:
Anyone know what could be causing this?
I'm executing it like this:
The abort call after coreD generates the coredump for testing purposes.
I've also tried running coreD prior to initializing the flash with the same result.
Any help will really be appreciated
I wrote the following portion of code to read the coredump from flash:
Code: Select all
oid coreD(void){
const esp_partition_t *pt = NULL;
size_t bytestoread = 256;
size_t bytesread = 0;
char str_dst[256];
pt = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_COREDUMP, "coredump");
if (pt != NULL)
{
size = pt->size;
printf("POINTER IS NOT NULL \n");
while(bytestoread > 0)
{
printf("STARTING PARTION READ \n");
printf("Remaining partition size : %zu \n",size);
esp_err_t er = esp_partition_read(pt, bytesread ,str_dst, bytestoread);
printf("PARTITION READ \n");
printf("%s",str_dst);
if (er != ESP_OK)
{
printf("READ IS NOT OK!\n");
ESP_LOGE(TAG,"Partition read error : %s", esp_err_to_name(er));
return ;
}
else if (er == ESP_OK)
{
printf("\n READ IS OK!\n");
bytesread = bytesread +256;
size = size - 256;
if(size <= 256)
{
bytestoread = size;
}
}
}
}
}
Code: Select all
TARTING PARTION READ
PARTITION READ
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒@READ IS OK!
STARTING PARTION READ
PARTITION READ
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒@READ IS OK!
STARTING PARTION READ
PARTITION READ
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒@READ IS OK!
I'm executing it like this:
Code: Select all
void app_main()
{
extern struct tm timeinfo;
extern char strftime_buf[64];
char buf[30];
//define variables for determining wakeup time
int TfutH = 17+15;
int TfutM = 60;
int TfutS = 60;
uint64_t TdiffH;
uint64_t TdiffM;
uint64_t TdiffS;
uint64_t Tdiff;
//allocate memory to the heap
char* datep = (char*)malloc(sizeof(char)*(sizeof(buf)+1));
if(datep == NULL){
abort();
}
void* work = NULL;
work = ff_memalloc(FF_MAX_SS);
if(work == NULL){
abort();
}
char* test = malloc((74)*sizeof(char));
if(test == NULL){
abort();
}
char* location = malloc(50*sizeof(char));
if(location == NULL){
abort();
}
char* errorcond = (char*)malloc(sizeof(char) * 40);
if(errorcond == NULL){
abort();
}
size_t ersize = sizeof(errorcond);
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK(ret);
//initialize wifi and wait for it to be connected
app_wifi_initialise();
app_wifi_wait_connected();
coreD();
abort();
...
...
...
}
I've also tried running coreD prior to initializing the flash with the same result.
Any help will really be appreciated