Problems accessing flash memory
Posted: Sun Jun 27, 2021 8:39 am
Are there any check functions before using the read / write / erase functions of flash memory?
The code crashes periodically. I don't see any patterns. Maybe at the start, or maybe after half an hour of work. I read / write to 1 sector of flash memory every 10 seconds 16 bytes. And I get errors ...
idf: 4.2.2
ic: esp32-pico-v3-02
This crash occurred on the esp_partition_read function.
Maybe there is a way to do some kind of check before reading?
The code crashes periodically. I don't see any patterns. Maybe at the start, or maybe after half an hour of work. I read / write to 1 sector of flash memory every 10 seconds 16 bytes. And I get errors ...
idf: 4.2.2
ic: esp32-pico-v3-02
This crash occurred on the esp_partition_read function.
Code: Select all
I (367027) EVENT LOG: read page[0]
Re-enable cpu cache.
Guru Meditation Error: Core 0 panic'ed (Cache disabled but cached memory region accessed).
Core 0 register dump:
PC : 0x4000c2e2 PS : 0x00060134 A0 : 0x800972c6 A1 : 0x3ffe9890
A2 : 0x3ffedac4 A3 : 0x3ff42080 A4 : 0x00000040 A5 : 0x3ffedac4
A6 : 0xffffffff A7 : 0x00000004 A8 : 0x00000000 A9 : 0x3ffe9880
A10 : 0x00000001 A11 : 0x3ffce3a8 A12 : 0x00000001 A13 : 0x3ffbedcc
A14 : 0x3ffc2acc A15 : 0x00000001 SAR : 0x00000020 EXCCAUSE: 0x00000007
EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000003
Backtrace:0x4000c2df:0x3ffe9890 0x400972c3:0x3ffe98a0 0x40097643:0x3ffe98e0 0x400989d3:0x3ffe9900 0x4008be3a:0x3ffe9920 0x40142307:0x3ffe9950 0x400fc059:0x3ffe9980 0x400fc1e1:0x3ffe99e0 0x400fbd5e:0x3ffe9a00 0x400fa95d:0x3ffe9aa0 0x400fa0c5:0x3ffe9d30 0x4010df7a:0x3ffe9d50 0x40110d15:0x3ffe9d70 0x40125261:0x3ffe9db0 0x401264ab:0x3ffe9dd0
0x400972c3: spi_flash_ll_get_buffer_data at C:/esp/esp-idf/components/soc/src/esp32/include/hal/spi_flash_ll.h:146
0x40097643: spi_flash_hal_read at C:/esp/esp-idf/components/soc/src/hal/spi_flash_hal_common.inc:122
0x400989d3: spi_flash_chip_generic_read at C:/esp/esp-idf/components/spi_flash/spi_flash_chip_generic.c:155
0x4008be3a: esp_flash_read at C:/esp/esp-idf/components/spi_flash/esp_flash_api.c:557
0x40142307: esp_partition_read at C:/esp/esp-idf/components/spi_flash/partition.c:412
Code: Select all
const esp_partition_t * partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, "events");
assert(partition != NULL);
uint8_t * read_data = (uint8_t*) malloc(SPI_FLASH_SEC_SIZE);
if (read_data == NULL) {
ESP_LOGE(EVENT_LOG_TAG, "error memory");
return -1;
}
#ifdef ENABLED_EVENT_LOG
ESP_LOGI(EVENT_LOG_TAG, "read page[%d]", i);
#endif
// Прочитать блок по адресу
if (esp_partition_read(partition, i * SPI_FLASH_SEC_SIZE, read_data, SPI_FLASH_SEC_SIZE) == ESP_OK)
{
}